Cymen's Blog

Xen, LVM and DomU ext3 resizing…

3 comments

I’m using a Debian 5 (Lenny) host with Xen 3.2 from packages with software RAID and LVM. At the moment, all of my guests (DomU) are also Debian 5. To resize a guest filesystem, in Dom0 resize the logical volume:

lvextend -L +100G /dev/$PV/$LV

In guest (DomU), resize the partition by deleting and creating again. The trick is to make sure the first block stays. With the default steps on the Debian netboot installer with the “all in one” option, it makes these partitions:

/dev/xvda1 as / (1st primary partition)
/dev/xdva2 as extended partition
/dev/xvda5 as swap

So I unmounted the swap (swapoff /dev/xvda5), deleted all of the partitions, recreated /dev/xvda1 as the new size marked bootable leaving just enough room for the swap partition, and added the small swap partition. Then edit /etc/fstab to point to the new device (I changed swap to be on /dev/xvda2), reboot and do “resize2fs /dev/xvda1″. I tried doing this without the reboot but resize2fs didn’t want to see the new partition sizes. I used cfdisk for the partitioning so maybe it would work with fdisk or parted.

I did forget one detail — I rebooted the DomU after resizing the LVM volume in Dom0. Mentioning just in case that is required. I’ll find out next time I need to add more space to a logical volume.

Written by Cymen

June 14th, 2009 at 4:24 pm

Posted in Xen

3 Responses to 'Xen, LVM and DomU ext3 resizing…'

Subscribe to comments with RSS or TrackBack to 'Xen, LVM and DomU ext3 resizing…'.

  1. Reminder: Do the lvextend in Dom0 with the DomU booted up. Don’t reboot after the extend but before the DomU partition editing/fixing otherwise lengthy bootup (at least with Debian 5.0) due to filesystem/partition change detected and mount as ro.

    On that note, to remount ext3 as rw, use “mount /dev/xvda1 / -o remount,rw” as just plain “mount -o remount,rw /” will make mount inspect /etc/fstab and insert the other mount options specified there which will cause the remount to fail.

    Cymen

    24 Jul 09 at 10:19 pm

  2. Idea: Next time, try shutting down the DomU and doing all the work in Dom0 mounting /dev/$PV/$LV to Dom0 as needed.

    Cymen

    24 Jul 09 at 10:33 pm

  3. Well, in the end, it appears data=writeback causes ext3 partitions (at least /) to mount rw with Debian 5.0 2.6.26-2-686-bigmem.

    Cymen

    24 Jul 09 at 11:19 pm

Leave a Reply