Create .img of a directory
Author Message
Posted : Tue, 15 April 2008 18:14:27
Subject : Create .img of a directory
I have a directory say for example /tmp/stuff, and I want to create an .img (stuff.img) file of this stuff directory. Can some one please help me to achieve this? Thanks
tophandcwby
Posted : Tue, 15 April 2008 18:31:45
Subject : Create .img of a directory
There are short cuts to this, but this is how I'd do it. #make sure the loop driver is installed modprobe loop #determine the amount of memory space I need cd dir_of_interest du cd dd if=/dev/zero of=new_img bs=1024 count=#kilobytes needed losetup /dev/loop0 new_img mkfs.ext3 /dev/loop0 mount /dev/loop0 /mnt cp -a dir_of_interest /mnt/ umount /mnt losetup -d /dev/loop0 Now you have the img of dir_of_interest.