Logical Volume Manager
Common
Check if LVM can access and manage system disks
sudo lvmdiskscan
List physical volume(s)
sudo pvs
List volume groups
sudo vgs
Verify physical volume(s) was created successfully
sudo pvdisplay /dev/<disk>
Verify the logical volume was created successfully
sudo lvdisplay
## Physical
Create physical volumes in LVM
```shell showLineNumbers=false# example: sudo pv create /dev/sdbsudo pvcreate /dev/<disk>
Volume
Create volume group based on physical volumes
# One physical disk in volume groupsudo vgcreate VolumeGroup01 /dev/sdb
# Multiple physical disks in same volume groupsudo vgcreate VolumeGroup01 /dev/sdc /dev/sdd /dev/sde
Logical
Create logical volumes based on volume group
# Allocate disk space for multiple volumes from same volume groupsudo lvcreate -n repos -L 30G VolumeGroup01sudo lvcreate -n backup -L 50G VolumeGroup01sudo lvcreate -n dev -L 100G VolumeGroup01
# Allocate rest of disk spacesudo lvcreate -n disk01 -l 100%FREE VolumeGroup01
Mount logical volumes
-
Format logical volumes and do it for all volumes
Terminal window # example: sudo mkfs.ext4 /dev/VolumeGroup01/backupsudo mkfs.ext4 /dev/<volume group>/<name of volume> -
Create folders (optional)
Terminal window # example: sudo mkdir -p /mnt/backup# example: sudo mkdir -p /opt/{repos,backup,dev}sudo mkdir -p /<path>/<name of volume> -
Mount the disks
Terminal window # example: sudo mount /dev/VolumeGroup01/backup /mnt/backup# example: sudo mount /dev/VolumeGroup01/dev /opt/devsudo mount /dev/<volume group>/<name of volume> /<path>/<name of volume># Verify the mount was successfuldf -h# ormount | grep <volume group> -
Add to fstab to permanently add the disks
Terminal window # use your editor of choice (nano, vi, vim, etc.)sudo vim /etc/fstab# Add the following# example: /dev/VolumeGroup01/backup /mnt/backup ext4 defaults,nofail 0 0/dev/<volume group>/<name of volume> /<path>/<name of volume> ext4 defaults,nofail 0 0