The following instructions will show you how to create either a growable (consumes space as needed) or reserved (consumes all space in the beginning) drive image file, format it, and mount it as a directory. This usable on systems that are already partitioned and you need to work with a new "partition" (say one with/without quota support), or just want a portable filesystem that you can transfer between systems.
Create a "growable" 80GB disk image called virt.img.
dd if=/dev/zero of=virt.img bs=1M seek=81920 count=1
(note that 81920 = 80 * 1024)
or create a "reserved" 80GB disk image called virt.img
dd if=/dev/zero of=virt.img bs=1M count=81920 seek=1
(note that 81920 = 80 * 1024)
Format your virtual partition (choose yes to continue):
/sbin/mkfs.ext3 virt.img
Mount the virtual partition:
mkdir /mnt/image
mount -o loop virt.img /mnt/image
The /etc/fstab entry (assuming virt.img is stored in the root partition "/" ):
/virt.img /mnt/image ext3 rw,loop,auto 0 0

Leave a comment