Friday, August 29, 2008

Resizing your xen DomU using LVM

To resize the disk space of a xen DomU that is using Logical Volume Manager(LVM) is very easy. Below is step by step on how to do the resizing process.

  1. Create a new image with the size that you require. Just give any meaningful name to the image. In this case I will use the name extended.img
    • # dd if=/dev/zero of=extended.img bs=1 count=1 seek=20G conv=notrunc
  2. Add the new image to the configuration file of your DomU. In this example, the name of the domU is xen0
    • # vi /etc/xen/xen0
    • Add these line to it
      • disk = [ 'tap:aio:/path/to/xen/xen0.img,xvda,w','file:/path/to/xen/extended.img,xvdb,w' ]
    • Save
  3. Start your domU
    • # xm create xen0
  4. Access your domU
    • # xm console xen0
  5. Once inside, check whether the new image is detected
    • # fdisk -lu
  6. After confirm that your new hard disk image is detected, it is time we have to work on the lvm
    • Create new physical volume (PV) using the new hard disk image
      • # pvcreate -v /dev/xvdb
    • Check that you have successfully added the PV
      • # pvdisplay
    • Extend your existing volume group (VG) to include the new PV
      • # vgextend -v VolGroup00 /dev/xvdb
    • Check that you have successfully add the PV into the VG
      • # vgdisplay
    • Extend your logical volume (LV)
      • # lvextend -L +20G -v /dev/VolGroup00/LogVol00
    • Check that the extension has been added
      • # lvdisplay
    • If all the steps are successfully done, you have to resize the / partition
      • # resize2fs /dev/mapper/VolGroup00-LogVol00
  7. You are done. Check your new hard disk space :)
    • # df -lh


Anonymous said...

Its kill your time to find how to change Duplicate VG name VolGroup00

I dont find how:((((

Anonymous said...

Worked great - Nice job, thanks for posting it it was really helpful.

cowmix said...

Why are you using the 'file' drive for the expanded image as opposed to the 'tap:aio' driver?

cowmix said...

This guide worked AWESOME! Every other doc on this subject was twice as long and sometimes didn't work.

The only thing you might want to add is that you can do all this on a 'live' domU by using 'xm block-attach' instead of editing the configuration file.

Danilo said...

Great! This is the only guide I've found so far explaining exactly how to expand my Logic Volume. You have all my appreciation now :) Very good job!

blackorga said...

Thanks Danilo

Anonymous said...

There so many articles, but only this works fine! You save my business! Thanks 1000000x