In this article, I will be going over the steps to create an LVM volume on Linux. Logical Volume Manager (LVM) was originally created by Heinz Mauelshagen, who wrote the original LVM code in 1998. The primary design guidelines were taken from HP-UX’s volume manager.
The procedure is fairly straight forward, we just need to create the physical volume, the volume group, and finally the logical volume. I added a 10 GB device to this Red Hat Linux 8 server.
Creating LVM volumes
The lsblk command shows us the available devices on the linux server. The one we need is
The first step in creating an LVM volume is to create the physical volume.
# pvcreate /dev/sdb
Second we create the volume group.
# vgcreate vg_iscsi_vol /dev/sdb
The vg_isci_vol is just the name of the volume
We can then view our volume groups to verify.
We see both the primary volume group,
The final layer in creating a LVM volume on Linux is creating the logical volume.
# lvcreate -L 5G -n lv_iSCSI_volume vg_iscsi_vol
The parameter -L 5G tell the logical volume we just wish to use 5 GB of the 10 GB.
We then verify our work once again.
We see that it is only using 5 GBs. You can easily expand the LVM later on by using the remaining portion of the 5 GBs or adding more devices to the server and adding a new physical volume and adding it to this logical volume group.
Using the lsblk command again, we see our volume group and the logical volume
Finally we need a file system on our volume.
# mkfs.xfs /dev/vg_iscsi_vol/lv_iSCSI_volume
You can also do:
# mkfs -t xfs /dev/vg_iscsi_vol/lv_iSCSI_volume
-t is for the file system type, such as xfs, ext4, gfs2, etc.
Mounting the LVM volume
Then we just need to mount the volume so we can start using it.
# mount /dev/vg_iscsi_vol/lv_iSCSI_volume /mnt
The /mnt is the location on the file system you wish to mount the