Repository navigation
Linux: Logical Volume Manager (LVM)
Paiet edited this page Jun 6, 2021
·
1 revision
- Drive naming convention
/dev/sda/dev/sda1/dev/sdb/dev/sdb3
- List available physical drives:
fdisk -l
- Create a partition
fdisk /dev/sdb-
n- Create new partition -
p- primary partition- When done press "p" for a list
-
w- write the changes
- Reboot or execute "partprobe"
- If install was a minimal install
yum install lvm2
- Create physical volumes
pvcreate /dev/sdb1 /dev/sdc1
- Verify creation
-
pvdisplayorpvs
-
- Create a volume group
vgcreate vg1 /dev/sdb1 /dev/sdc1-
vgdisplayorvgs
- Create logical volumes
lvcreate -L <size> vg1 -n <name>lvcreate -L 250G vg1 -n website
- Format and mount the logical volume
mkfs.ext4 /dev/vg1/websitemkdir /websitemount /dev/vg1/website /websitesemanage fcontext -a -t httpd_sys_content_t /websiterestorecon /website
- Add more storage to the volume group / logical volume
-
fdisk /dev/sdd-
n- create new partition -
w- write changes
-
partprobepvcreate /dev/sdd1vgextend vg1 /dev/sdd1lvresize -L +1G /dev/vg1/websitedf -hresize2fs /dev/vg1/websitedf -h-
lvsorlvdisplay
-
- Verify volume added to /etc/fstab if needed at boot
more /etc/fstab/dev/mapper/vg1-lv1-
/website ext4 defaults 1 1- 1 - Do backup
- 1 - Do check for errors
- 1 - Do backup
- Tear it all down
umount /websitelvremove /dev/vg1/websitevgremove /dev/vg1pvremove /dev/sdb1 /dev/sdc1 /dev/sdd1