This is an old revision of the document!
Create And Remove Physical Volumes Assign Physical Volumes To Volume Groups And Create And Delete Logical Volumes
General Information
About this page/how-to/script.
Parition that is prepared for type LVM (8e00)
gdisk /dev/sdb n Partition number: 1 First sector: default Last sector: +30G Hex code type: 8e00 w
Create physical volume
pvcreate /dev/sdb1
Assign physical volume to new volume group
vgcreate vglocal /dev/sdb1
Assign physical volume to existing volume group
vgextend vglocal /dev/sdb1
Create logical volume
lvcreate --name lvhome --size 30G vglocal
Create filesystem and mount logical volume
mkfs -t xfs /dev/mapper/vglocal-lvhome mount /dev/mapper/vglocal-lvhome /home
Display physical volumes, volume groups, or logical volumes
pvdisplay vgdisplay lvdisplay
Delete logical volume
lvremove /dev/mapper/vglocal-lvhome
Delete volume group
vgremove vglocal
Remove physical volume
pvremove /dev/sdb1