lvm
Improves the availability, disk I/O, performance and capabilities of disk management
Adds an extra layer between the physical disks and the file system, allowing you to create a logical volume instead of a physical disk
Allows you to easily resize, extend and decrease the LV when need it
How to Create LVM Physical Volumes:
# ls /sys/class/scsi_host
host0# echo "- - -" > /sys/class/scsi_host/host0/scanCheck disk:
fdisk -lGeneral syntax for the creation of Phisical Volume (pvcreate)
pvcreate <Physical Volume name># pvcreate /dev/sdb /dev/sdc /dev/sdd
Physical volume "/dev/sdb" successfully created
Physical volume "/dev/sdc" successfully created
Physical volume "/dev/sdd" successfully createdUse the pvdisplay and pvs commands to display the PVs you have created. The pvs command shows summarize output and the pvdisplay shows the detailed output of the PVs.
# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb lvm2 a-- 15.00g 15.00g
/dev/sdc lvm2 a-- 15.00g 15.00g
/dev/sdd lvm2 a-- 15.00g 15.00gDisplay:
How to Create a Volume Group:
General syntax for Volume Group Creating (vgcreate)
Use the following command to add a new physical volume to the new volume group.
*Note:* By default, it uses 4MB for physical extent, but you can change it based on your need.
Use the vgs and vgdisplay commands to display information about the VG you created.
How to Extend Volume Group:
If you do not have space in the VG, Use the following command to add a new physical volume to the existing volume group.
Common syntax for Volume Group extension (vgextend).
How to Create Logical Volume Using GB Size's:
General syntax:
Run the below command to create a logical volume lv001 of size 10 GB.
Use the lvs and lvdisplay commands to display information about the LVs you have created.
How to Create Logical Volume Using PE Size’s
Alternatively, you can create Logical Volumes Using Physical Extends (PE) size.
How to Calculate PE Value? It’s very simple, for example, if you have a volume group of 10 GB, then what is the PE size?
By default, it uses 4MB for the physical extent, but check the correct PE size by running the vgdisplay command, as this can be changed based on requirements.
Common syntax for Logical Volume Creation with PE Size’s (lvcreate).
To create 10GB of logical volume using the PE size the command would be:
General syntax to create a file system.
For xfs file system.
Mounting Logical Volume Finally, you need to mount the logical volume to use it. Make sure to add an entry to /etc/fstab so that it loads automatically when the system boots.
Create a directory to mount the logical volume.
Use the mount command to mount the logical volume.
Add new logical volume details to the /etc/fstab file to mount automatically when the system starts.
Check the newly mounted volume using the df command.
Filesystem Size Used Avail Use% Mounted on
Last updated