Resize Xen image files

If LVM is not used when creating domU operating system, you might need to resize you image file. It's not easier than LVM but hopefully there's a solution.

  • First create an extra image with the desired size (here 1GB) that will be added to the current image
$ dd if=/dev/zero of=extra.img bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 5.09034 seconds, 211 MB/s
  • Make sure domU is not running. Then just add extra.img to your domU image file (here domU.img). Yes just as simple :D
$ cat domU.img extra.img > domU.resize.img
  • You also need to enlarge your filesystem. I've test it with ext3 but not with ReiserFS - it seems ReiserFS needs resize_reiserfs instead of resize2fs -.
$ ef2fsck -f domU.resize.img

$ resize2fs domU.resize.img

  • Finally modify your domU config file or move domU.resize.img over domU.img.

Comments

Typo

Hello,
Great article! Just wanted to correct a typo:

ef2fsck -f domU.resize.img is wrong
Correct command is:
e2fsck -f domU.resize.img

Thibault

Thanks!

Thanks for this, works like a charm.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options