Search:  
Gentoo Wiki

TIP_Running_out_of_space_use_a_loopback_device

This article is part of the Tips & Tricks series.
Terminals / Shells Network X Window System Portage System Filesystems Kernel Other
Code:
 # mkdir /mnt/windows 
 # mount -t smbfs //windows/linuxtmp /mnt/windows 
 # dd if=/dev/zero of=/mnt/windows/portage-loop seek=1k bs=1k count=1000000 
 # losetup /dev/loop1 /mnt/windows/portage-loop 
 # mkfs.ext3 /dev/loop1 
 # mount -t ext3 /dev/loop1 /var/tmp 
 # emerge xorg-x11 (or something big)
 # umount /var/tmp 
 # losetup -d /dev/loop1 
 # rm -f /mnt/windows/portage-loop 
 # umount /mnt/windows

This is performed:


It's possible to make this operation go much faster on filesystems that support sparse files.

Follow the instructions as above, but replace the dd step with:

Code:
 # dd if=/dev/zero of=/mnt/windows/portage-loop bs=1M count=1  seek=1000


This will tell dd to write a zero at the 1000th 1 Megabyte block, making a 1000MB file filled with zeros, just as above. However, this method takes advantage of most filesystem's (including NTFS) support for what are known as sparse files. The FS allocates the files as being of a a certain size, but the empty allocated space is not written to the disk itself; rather the FS keeps track of what regions are empty and actually fills them on the disk as appropriate.


PLEASE NOTE! FAT32/vfat does NOT support sparse files!

Credits

Original Forum Post by gava77

Feedback

Concerns or Compliments? Please use the Discussion section.

Retrieved from "http://www.gentoo-wiki.info/TIP_Running_out_of_space_use_a_loopback_device"

Last modified: Fri, 05 Sep 2008 09:22:00 +0000 Hits: 16,008