Resizing Xen guests using LVM

11,587

Solution 1

Your problem here is that you can't resize ext3 partition with parted. you have to remove the journal (turning ext3 into ext2) and then resize.

see this for more info

http://www.hermann-uwe.de/blog/resizing-ext3-partitions-with-parted

Solution 2

Why are you partitioning the LV, instead of just using it directly? Also, if you are going to be manipulating the partition table, it's best to do it in the guest. Worst, it looks like you might be trying to fiddle with the partition table in the dom0 while the domU is still running... dangerous.

My simple recipe for resizing a domU disk, which I've done probably in excess of a hundred times by now, is to have the domUs with the LV as the full root partition (xvda1) and then running:

lvextend -L+NG -n domu-root vg
xm shutdown -w domu
xm create domu
ssh domu resize2fs /dev/xvda1

And voila, all done. For non-root filesystems, you can just detach/reattach (useful for swap, in particular), but root needs the reboot.

Share:
11,587

Related videos on Youtube

John
Author by

John

Linux/BSD/Solaris SysAdmin/Geek/Dad

Updated on September 17, 2022

Comments

  • John
    John over 1 year

    I have a RHEL 5.4 server running as a Xen Dom0, and wish to install several RHEL 5.4 DomU guests using LVM as the guest disks. I have created the following two LVs:

    xen-test02-root  VM-VG -wi-a-   6.00G
    xen-test02-swap  VM-VG -wi-a- 512.00M
    

    I used the custom partitioning option when installing the guest so no LVM is used in the guest, only 2 disks. One for / (xvda) and one for swap (xvdb).

    This all works fine, but now I wish to test extending the root partition. So far, I have tried using lvextend from the Dom0. This works:

    # lvextend -L +4GB /dev/VM-VG/xen-test02-root
      Extending logical volume xen-test02-root to 10.00 GB
      Logical volume xen-test02-root successfully resized
    

    fdisk shows that the disk is now 10.7GB:

    # fdisk -l /dev/VM-VG/xen-test02-root
    
    Disk /dev/VM-VG/xen-test02-root: 10.7 GB, 10737418240 bytes
    255 heads, 63 sectors/track, 1305 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    
                         Device Boot      Start         End      Blocks   Id  System
    /dev/VM-VG/xen-test02-root1   *           1         783     6289416   83  Linux
    

    I now wish to extend the partition on that disk with parted:

    (parted) print
    
    Model: Linux device-mapper (dm)
    Disk /dev/mapper/VM--VG-xen--test02--root: 10.7GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    
    Number  Start   End     Size    Type     File system  Flags
     1      32.3kB  6440MB  6440MB  primary  ext3         boot
    
    (parted) resize 1 32.3kB 10.7GB
    Error: File system has an incompatible feature enabled.
    (parted)
    

    Any clues as to what I'm doing wrong? Is parted the best tool to resize partitons? Should I be using LVM differently for Xen guests?

    Many thanks, z0mbix

  • John
    John over 14 years
    Thanks, I would like to use the LV directly, but the RHEL installer requires that I partition /dev/xvda to create /dev/xvda1 for the / partition. Is there a way around this? I'm not editing the partition table when the domU is running.
  • womble
    womble over 14 years
    I avoid RHEL like the plague, so I'd just use xen-tools to create the domU and avoid the RHEL installer altogether.
  • Philip
    Philip almost 14 years
    Welcome to Server Fault. Please don't post "me too" or "thank you" type message on Server Fault. This site is for Questions and the associated Answers. If you have any new questions please use the Ask Question button in the upper right corner of every page.