Monday, October 24, 2011

Resizing with LVM

I am running a proxmox server with several virtual machines and noticed that I have more disk space configured on the virtual machines then I have on the partition they are running on. Here are the steps I took to increase the size of the ext3 partition hosting the vms.

  1. View the mount points to determine what logical volume the vms are on
  2. ~# mount
    /dev/pve/root on / type ext3 (rw,errors=remount-ro)
    tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
    proc on /proc type proc (rw,noexec,nosuid,nodev)
    sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
    procbususb on /proc/bus/usb type usbfs (rw)
    udev on /dev type tmpfs (rw,mode=0755)
    tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
    devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
    /dev/mapper/pve-data on /var/lib/vz type ext3 (rw)
    /dev/cciss/c0d0p1 on /boot type ext3 (rw)
  3. View the logical volume to determine what volume group it is on:
  4. ~# lvdisplay /dev/mapper/pve-data
      --- Logical volume ---
      LV Name                /dev/pve/data
      VG Name                pve
  5. View the volume group to be sure there is room for expansion:
  6. ~# vgdisplay pve
      --- Volume group ---
      VG Name               pve
      System ID
      Format                lvm2
      Metadata Areas        2
      Metadata Sequence No  2236
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                3
      Open LV               3
      Max PV                0
      Cur PV                2
      Act PV                2
      VG Size               477.93 GB
      PE Size               4.00 MB
      Total PE              122351
      Alloc PE / Size       44928 / 175.50 GB
      Free  PE / Size       77423 / 302.43 GB
      VG UUID               ThGaW0-KPoF-ZA3V-jgxE-zv6d-jaMY-Pc8Y1W
  7. Extend the logical volume (-L flag as used below allows you to specify the new size of the volume):
  8. ~# lvextend -L150G /dev/pve/data
      Extending logical volume root to 150.00 GB
      Logical volume root successfully resized
  9. Resize the ext3 partition
  10. ~# resize2fs /dev/pve/data
    resize2fs 1.41.3 (12-Oct-2008)
    Filesystem at /dev/pve/data is mounted on /var/lib/vz; on-line resizing required
    old desc_blocks = 4, new_desc_blocks = 10
    Performing an on-line resize of /dev/pve/data to 39321600 (4k) blocks.
    The filesystem on /dev/pve/data is now 39321600 blocks long.
Pretty easy.