Search code examples
centosvirtual-machinexenext4lvm

resize2fs LVM root on CentOS 6.6 64-bit guest on XenServer 6.2


All the preparations to grow the ext4 root LVM partition on CentOS 6.6 64-bit running on XenServer 6.2 have been completed.

  • Grow the xvda virtual disk on XenServer - check.
  • Create xvdaN as LVM on CentOS guest using fdisk - check.
  • pvcreate /dev/xvdaN on CentOS guest - check.
  • vgextend VolGroup /dev/xvdaN on CentOS guest - check.
  • lvresize --extents /dev/mapper/VolGroup-lv_root on CentOS guest - check.

Now I need to resize2fs /dev/mapper/VolGroup-lv_root. Here's the problem.

It's the root volume. My understanding is that it cannot be resized while the VM is running - lest we corrupt the volume. However, the volume is not recognized when I boot from the CentOS 6.5 LiveCD iso (there is no 6.6 LiveCD.)

So, how do I resize2fs a logical volume that cannot be touched with the VM running, and isn't recognized when the VM is not running?


Solution

  • Eventually found the answer online...

    1. Boot from LiveCD
    2. Open a terminal
    3. sudo su -l Switch user to root
    4. vgchange -aay This is the magic. It will automatically find and activate existing volume groups.
    5. e2fsck -f /dev/mapper/VolGroup-lv_root Force check the volume for errors
    6. resize2fs /dev/mapper/VolGroup-lv_root Add available space to volume
    7. e2fsck -f /dev/mapper/VolGroup-lv_root Force check the volume for errors
    8. reboot

    ...and viola, the root volume is now using the additional available space.