Extending LVM

Extending LVM

Check current virtual groups, physical and logical disks:

vgs
pvs
lvdisplay

Find disks and compare with output from pvs to find out which one was just added (which one is not used):

fdisk -l

Knowing that, create a partition:

fdisk /dev/sdf   # replace /dev/sdf with the new one
n                # new partition
p                # primary
### Then those are defaults to use the whole drive ###
t                # set partition type...
8e               # ...to Linux LVM
p                # show changes
w                # write changes

Create physical drive:

pvcreate /dev/sdf1

Add to the vg0 group:

vgextend vg0 /dev/sdf1

Extend the group:

lvm lvextend -l +100%FREE /dev/vg0/lv-0

Resize filesystem:

resize2fs -p /dev/mapper/vg0-lv--0

Confirm changes:

df -h
About the author
Peter M Pelica

Hi, I'm Peter.

I'm a software engineer who enjoys building things, writing about odd technical problems, and photographing wildlife.

Feel free to explore my tech ramblings and animal photos – or browse all stories.