linux_wiki:create_and_remove_physical_volumes_assign_physical_volumes_to_volume_groups_and_create_and_delete_logical_volumes

Create And Remove Physical Volumes Assign Physical Volumes To Volume Groups And Create And Delete Logical Volumes

General Information

Working with logical volumes.


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


Summary of physical volumes

pvs


Full display of physical volumes

pvdisplay

Assign physical volume to new volume group

vgcreate vglocal /dev/sdb1


Assign physical volume to existing volume group

vgextend vglocal /dev/sdb1


Summary of volume groups

vgs


Full display of volume groups

vgdisplay

Create logical volume

lvcreate --name lvhome --size 30G vglocal


Summary of logical volumes

lvs


Full display of logical volumes

vgdisplay

Create filesystem and mount logical volume

mkfs -t xfs /dev/mapper/vglocal-lvhome
mount /dev/mapper/vglocal-lvhome /home

Delete logical volume

lvremove /dev/mapper/vglocal-lvhome


Remove a physical volume (/dev/sdb1) from a volume group (vglocal)

vgreduce vglocal /dev/sdb1


Delete volume group

vgremove vglocal


Remove physical volume

pvremove /dev/sdb1

  • linux_wiki/create_and_remove_physical_volumes_assign_physical_volumes_to_volume_groups_and_create_and_delete_logical_volumes.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)