pmeerw's blog

Thu, 24 May 2018

Adding space to a Linux LVM volume

The steps can be done when the disk is online; only creating the partition required a reboot for me.

Growing the filesystem
  1. Create a physical LVM volume: pvcreate /dev/sdaN; check using pvdisplay
    $ pvcreate /dev/sdaN
      Physical volume "/dev/sdaN" successfully created
    
    $ pvdisplay
       --- Physical volume ---
      PV Name               /dev/sda1
      VG Name               vg-name
      ...
     
      --- Physical volume ---
      PV Name               /dev/sda2
      VG Name               vg-name
      ...
     
      "/dev/sdaN" is a new physical volume of "100.00 GiB"
      --- NEW Physical volume ---
      PV Name               /dev/sdaN
      VG Name
      PV Size               100.00 GiB
      Allocatable           NO
      PE Size               0
      Total PE              0
      Free PE               0
      Allocated PE          0
      ...
    
  2. Extend the volume group: vgextend vg-name /dev/sdaN; check using lvdisplay
    $ vgextend vg-name /dev/sdaN
      Volume group "vg-name" successfully extended
    
    $ lvdisplay
     
      --- Logical volume ---
      LV Name                /dev/vg-name/root
      VG Name                vg-name
      ...
    
  3. Extend the logical volume to all free space available: lvextend -l+100%FREE /dev/vg-name/root
    $ lvextend -l+100%FREE /dev/vg-name/root
    
  4. Resize the file system: resize2fs /dev/mapper/vg--name-root
    $ resize2fs /dev/mapper/vg--name-root
    
Partition type code for LVM is 8e.

Some more useful commands
lvmdiskscan -l to scan for LVM physical volumes
vgdisplay -v to summarize lot of information about a volume group
lvs to find the logical volumes and there size; also try the --segments argument

posted at: 11:16 | path: /configuration | permanent link

Made with PyBlosxom