support@yourtech.us | Webmail |  DNS Login | *Billing* | cPanel | (814) 652-5358

Welcome to YourTech, LLC. If you are unfamiliar with this site, you may want to find out about my services, read my story, or you could simply be looking for a way to contact me. On this site, you will find a collection of technical musings, howto guides, and technical reference information.

Make a drive image in Linux

| No Comments | No TrackBacks


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

No TrackBacks

TrackBack URL: http://www.yourtech.us/cgi-bin/mt/mt-tb.cgi/5

Leave a comment