LVM

 

Logical Volume Manager

List available disk:
# fdisk -l

Run fdisk or gdisk to create LVM partition to all disks.
Select a disk
# fdisk /dev/sdb

Note: For disk larger than 2 TB, use gdisk
In fdisk or gdisk menu, select n for new a partition, then p for primary, select the default size. Select t to change the partition’s id. Use the hex code 8e (fdisk) or 8e00 (gdisk) for Linux LVM. Type w to Write and Exit.

Prepare the new partitions for LVM:
# pvcreate /dev/sdb1 /dev/sdc1

Verify the physical volume:
# pvdisplay

Create a LVM Volume Group:
# vgcreate VolumeGroupName /dev/sdb1 /dev/sdc1

Verify the Volume Group:
# vgdisplay

Create the logical volumes:
# lvcreate –name LogicalVolumeName –size 40G VolumeName

Verify the logical volumes
# lvdisplay

Create the file system:
# mkfs.xfs /dev/LogicalVolumeName/DirectoryName

Mount the file system and include it in fstab.

Commands:

LVM Partition:
# pvcreate – Create a LVM from Partitions
# pvremove – Remove a LVM Partitions
# pvdisplay – Display the LVM Physical Partition

LVM Volume Group:
# vgcreate – Create a LVM Volume Group
# vgremove – Remove a LVM Volume Group
# vgdisplay – Display the LVM Volume Groups
# vgscan – Scan the LVM Volume Groups
# vgrename – Rename the LVM Volume Group

LVM Logical Volume:
# lvscan
# lvrename
# lvdisplay
# lvcreate
# lvremove
# lvextend
# lvreduce