This HOWTO will allow you to increase the size of .img files created with dd. Note that this process changes the on-disk image in place and hence it is highly recommended that you back up the image first. Also, make sure the image is not already mounted or backing a live domain or virtual machine! This process is *not* recommended for decreasing the overall size of an image and would likely cause the image itself to be corrupted if attempted.
Replace image_file and size_in_MB appropriately
# dd if=/dev/zero of=image_file bs=1M conv=notrunc count=1 seek=size_in_MB
# losetup /dev/loop0 image_file
# e2fsck -f /dev/loop0
# resize2fs /dev/loop0
# e2fsck -f /dev/loop0
# losetup -d /dev/loop0
June 20, 2011
Enlarge a xen Image (.img) File
1 Comment »
RSS feed for comments on this post.
There is no need to setup a loopback device to do this, e2fsck and resie2fs will work on the file directly.
Comment by Geoffrey McRae — March 30, 2012 @ 12:33 pm