Howto: Resize Xen Loop Disk Image
Win4lin, KVM, QEMU, Virtualbox and Xen are all widely used technologies, used in virtual servers. Fairly often a virtual server run from within a loop filesystem and generally start with a fairly small file (1GB is big for a normal file, but not when it is pretending to be an entire filesystem!)
However things often grow over time.
Here is a nice simple procedure for increasing the size of a loop filesystem, if the filesystem is ext2 or ext3 (the procedure should work for ext4 too, but I havn’t tested it yet)
1. Stop the virtual server that is using the loop filesystem
2. Add some extra space to your loop filesystem file
# dd if=/dev/zero bs=1024k count=1024 >> loop_image_file
This adds 1GB to the end of a file called loop_image_file (make sure to use the append output redirector >> not a single >, otherwise you’ll have an empty 1GB file!)
3. Force a check on the resized/increased filesystem
# e2fsck -f loop_image_file
4. Resize the filesystem within the loop filesystem file
# resize2fs loop_image_file
5. Start the virtual server again
Related posts:
- Migrate existing Ext3 filesystems to Ext4
- Xen Howto: Install Windows
- How to mount bin / cue image files in Linux
- Howto: How to Reset the MySQL Root Password
- Ubuntu Server Edition JeOS
- Howto Install Windows XP / Vista on Xen
- How to Mount a Remote Filesystem Using SSH and sshfs
- Importing / Exporting Virtual Disk Images with Virtual Box
- Ubuntu Howto: Install Xen
- Virtualization Visualization with Visio
Popular Related Items »
Incoming search terms
- xen extend disk image
- Resize xen image
- xen resize disk image
- xen expand disk image
- dd expand image
- grow xen image
- xen grow disk image
- xen resize
- xen loop
- xen disk image
- resize xen disk image
- xen resize image
- extend xen disk
- extend xen image
- xen grow image
- xen resize disk
- xenserver resize disk
- shrink xen disk image
- xen expand disk
- xen extend disk
- shrink dd image
- xenserver resize virtual disk
- expand xen disk image
- resize dd image
- Xen disk size
- xen image resize
- expand xen image
- extending disk in xen
- xen disk resize
- xen grow disk
- xen shrink virtual disk
- xen virtual disk resize
- xenserver shrink virtual disk
- resize xen disk
- shrink xen image
- xen shrink
- dd loop xen
- expand disk image
- resize disk image
- resize xen
- resize xen virtual disk
- resize xen windows image
- xen extend image size
- xen extending disk
- xen image shrink

Expanding xen disk file image « Thomas Mathiesen’s Blog said,
May 10, 2009 @ 14:12
[...] virtual machine (guest), it’s quite easy to expand the image file. I stole this receipt from here, just to make sure that I have a copy in case his/her website goes [...]
Ciprian Pantea said,
June 7, 2009 @ 10:10
(lol at the spam protection system
)))))
thanks for the tip, is there a way to shrink the partitions? also what partition type is the best used when using xen? reiser, xfs, ext2, ext3?
Ryan Bushby said,
August 12, 2009 @ 19:47
Ciprian Pantea, to shrink a partition you need to first run resize2fs to set the filesystem to a smaller size, then afterwards you need to truncate the loop file to that size.
I am not sure on the correct way to truncate the file, however I would suggest leaving a bit of room at the end unless you are certain about your math.
Imran Chaudhry said,
August 18, 2009 @ 15:41
To resize a Xen guest filesystem that exists as a loopback file:
1. ensure the guest is not running
2. make a copy of the file to resize, just in case (ensure you have sufficient free space first). Lets say the file is disk.img, backup is disk.img-backup
3. as root, run resize2fs – it may prompt you to run “e2fsck -f disk.img” – if it does then do so.
4. do the resize resize2fs disk.img 3G
5. confirm the size with du -h disk.img
6. now start up the xen guest and confirm the size is ok from within the guest: df -h
Imran Chaudhry said,
August 18, 2009 @ 15:50
Forgot to mention, the above was done with a Debian Lenny Xen host and Etch guest. It was a shrink action as I wanted to reclaim space on the Xen host.
I expected to have to use dd to physically resize the file from 4 to something just over 3.1 but resize2fs appears to have catered for this. This seems to be at variance with the man page.
Paul ward said,
June 2, 2010 @ 1:57
Great advice it worked perfectly on my virtual file system using encfs too.
I can now move files to my encfs folder and grow the virtual file system as I free up space!
Howto: Xen Loop Disk Image vergrössern | Stetix said,
July 6, 2010 @ 11:59
[...] ist eine Übersetzung des Original-Posts "Howto: Resize Xen Loop Disk Image". Ähnliche Artikel:Cronjob Linux Tutorial und Crontab [...]