Logical Volume Manager
LVM (aka Logical Volume Manager) is a tool for logical volume management which includes allocating disks, striping, mirroring and resizing logical volumes.
Overview⚓︎
500GB
1TB
500GB
1TB
1.5TB
ext4
xfs
LVM consists of three main components:
- Physical Volume (PV)
- Volume Group (VG)
- Logical Volume (LV)
Physical Volume⚓︎
A physical volume is a collection of disk partitions used to store all server data. These are the physical hard drives that are mounted to the CPU.
Physical volumes are usually mounted on /dev/sda,/dev/sdb, and so on.
Creating a Physical Volume⚓︎
To create a physical volume use pvcreate command
The above command initializes/creates a physical volume.
Note
Change `/dev/sda` according to your physical device name.
To list all the volumes available use `lsblk` or `fdisk -l`.
Display Physical Volumes⚓︎
To display a physical volume use pvdisplay or pvs or pvscan commands.
Volume Groups⚓︎
A volume group (VG) is what we create when we combine multiple physical volumes to create a single storage structure, equal to the storage capacity of the combined physical devices.
Creating a Volume Group⚓︎
To create a volume group use vgcreate command
Display Volume Groups⚓︎
To display a volume groups use vgdisplay or vgs or vgscan commands.
Extending Volume Group⚓︎
To extend a volume group use vgextend command
Logical Volume⚓︎
After you create a volume group, you can create logical volumes within that volume group. A logical volume, although it may reside on noncontiguous physical partitions or even on more than one physical volume, appears to users and applications as a single, contiguous, extensible disk volume
Creating a Logical Volume⚓︎
To create a logical volume use lvcreate command
Display Logical Volume⚓︎
To display a logical volume use lvdisplay or lvs or lvscan commands.
Extending Logical Volume⚓︎
To extend a volume group use lvextend command
-r is used to automatically format the allocated storage to required type like ext4,xfs, etc.