I am using Xen to create Virtual Machines, but how can I re-size the virtual disk image?
Add an extra empty space to your virtual disk size and re-size the filesystem in it:
or if reducing is needed, minimize the files system, add empty space to it as desired and re-size it.
Goal: Raising your virtual disk of VM of 2 GBytes bigger.
Use dd to create a 2 GB empty file
dd if=/dev/zero of=tempfile bs=1G count=2
Append this file to virtual image file (in this case it is disk.img)
cat tempfile >> disk.img
Resize the filesystem to its maximum size.
resize2fs -f disk.img
Goal: Reduce a 10GB Xen image file system ext3 to 3GB without data loss.
Reduce filesystem in image file to its minimum size(example: down to 1.4GB)
resize2fs -fM disk.img
Create an empty file the size(1.6GB) to add later to minimized filesystem
dd if=/dev/zero of=Empty_1.6GB.img bs=100M count=16
Adding the empty file to the minimized filesystem
cat Empty_1.6GB.img >> disk.img
Resizing the filesystem to its maximum size
resize2fs -f disk2.img
The image file is now 3GB.