Skip to content

LVM

LVM

Usage

Display the physical volumes and the logical volumes they conatain

pvdisplay -m

(https://serverfault.com/questions/461385/how-to-find-the-physical-volumes-that-hold-a-logical-volume-in-lvm#answer-461390)

Create new physical volume

The device must have an empty partition table or if it's a partition, it should have the 0x8e identifier (for LVM). You can achieve this things with fdisk. Once ready:

pvcreate 

(https://www.centos.org/docs/5/html/Cluster_Logical_Volume_Manager/physvol_create.html)

Move physical extents between physical volumes

This is useful if you want an already existing LV to be on a specific PV.

pvmove /dev/sda1:1000-1999 /dev/sdb1:0-999

(https://superuser.com/questions/435075/how-to-align-logical-volumes-on-contiguous-physical-extents#answer-700018)

Create a logical volume

lvcreate -n  -L g 

Then format it and mount it if requiered.

(https://wiki.debian.org/LVM#Create_an_LV)

Extend LV and filesystem

To extend the logical volume and the filesystem in it use:

lvresize --resizefs --size +931GB /dev/vg/lv_home

When extending, the filesystem can be mounted, but not when shrinking.

Reference