linux - Resizing Xen guests using LVM

22
2014-07
  • z0mbix

    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

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    How can I resize a regular (non-LVM) partition?
  • Questioner

    Sorry for my poor English, I hope you will understand me.

    A month ago I set up a Ubuntu server with a 500GB HDD, while installing the system I created regular, non-LVM, partitions - here's their layout.

    root@skysquad:~# fdisk -l
    
    Disk /dev/sda: 500.1 GB, 500107862016 bytes
    255 heads, 63 sectors/track, 60801 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x000c9f61
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1       10942    87891583+  83  Linux
    /dev/sda2           10943       60801   400492417+   5  Extended
    /dev/sda5           12159       60801   390724866   83  Linux
    /dev/sda6           10943       12158     9767457   82  Linux swap / Solaris
    
    Partition table entries are not in disk order
    

    Basically it's;

    sda1 (90GB) for OS (ext4)
    sda5 (~370GB) for /home (I will explain later) (ext4)
    sda6 (10GB) for SWAP

    Later I realised that when sda5 (385GB for /home) will be full I would like to increase its size by adding a new HDD, so I made sda5 an LVM partition like so;

    root@skysquad:~# pvdisplay
      --- Physical volume ---
      PV Name               /dev/sda5
      VG Name               vg1
      PV Size               372.62 GB / not usable 3.25 MB
      Allocatable           yes (but full)
      PE Size (KByte)       4096
      Total PE              95391
      Free PE               0
      Allocated PE          95391
      PV UUID               lewQnp-NdvK-Ac0N-sCgE-NGOH-K2cX-WxJ2tL
    
    root@skysquad:~# vgdisplay
      --- Volume group ---
      VG Name               vg1
      System ID
      Format                lvm2
      Metadata Areas        1
      Metadata Sequence No  3
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                1
      Open LV               1
      Max PV                0
      Cur PV                1
      Act PV                1
      VG Size               372.62 GB
      PE Size               4.00 MB
      Total PE              95391
      Alloc PE / Size       95391 / 372.62 GB
      Free  PE / Size       0 / 0
      VG UUID               yRkcP7-zvZ0-DjIR-xDWS-Ia6V-InSu-6Hwvpe
    
    root@skysquad:~# lvdisplay
      --- Logical volume ---
      LV Name                /dev/vg1/home
      VG Name                vg1
      LV UUID                jXCi37-iWmp-xVd7-9TsL-56pg-6x9m-73flLT
      LV Write Access        read/write
      LV Status              available
      # open                 1
      LV Size                372.62 GB
      Current LE             95391
      Segments               1
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           252:0
    

    Now my sda5 (LVM) is full (see below), but my wallet is not, and I can't just buy another HDD.

    root@skysquad:~# df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/sda1             86511612   3829536  78287500   5% /
    tmpfs                  1677788         0   1677788   0% /lib/init/rw
    varrun                 1677788       520   1677268   1% /var/run
    varlock                1677788         0   1677788   0% /var/lock
    udev                   1677788       144   1677644   1% /dev
    tmpfs                  1677788        84   1677704   1% /dev/shm
    lrm                    1677788      2192   1675596   1% /lib/modules/2.6.28-15-generic/volatile
    /dev/mapper/vg1-home 384590900 332537772  32517052  92% /home
    

    As you can see I'm only using 5% of / (sda1) (I don't know what I had in mind when I was setting 90GB for /).

    So finally my question - is there any SAFE way to resize non-LVM partitions (i.e. decrease sda1 size by 60GB, from 90GB to 30GB, and increase sda5 with this 60GB from ~370GB to ~430GB) and then increase LVM at sda5 with those 60GB?

    Thank you,
    Lulaz


  • Related Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.