How to create LVM Partitions ?
LVM partition has three levels of structure as below
- Physical volume
- Volume Group
- Logical volume
Step: 1 – Physical volume creation
First, we have to create the physical volume before creating the volume group, Now I’m going to make physical volume partitioning /dev/ sdb from block storage(RAW HDD).
- Shell command: fdisk -l this command used for view the all mounted HDD’s
- Shell command: pvcreate /dev/sdb this command used to create the physical volume from raw disk and it can be any disk-like physical HDD, VMware VMDK, etc.
- Shell command: “pvs or pvdisplay ” to view the physical volumes
Step: 2 – Volume Group creation
- Shell command: “vgcreate vg_secureethics /dev/sdb ” to create the volume group
vg_secureethics –> this is volume group name and it can be any name
- Shell command: “vgs or vgdispaly ” to view the volume groups
Step: 3 – Logical Volume creation
- Shell command: “lvcretae -L 4G -n lv_secureethics vg_secureethics ” to create logical volume
- Shell command: “lvsor lvdisplay ” to view the logical volumes
Step: 4 – Make File systems
Shell command: “mkfs.ext4 /dev/mapper/vg_secureethics-lv_secureethics_data ” to make the filesystems for usable partition and You can use any format like ext2,ext4,xfs,ntfs,etc.
Step: 5 – Mount/Add the LVM partition to fstab
Here I’m going to mount the partition /dev/mapper/vg_secureethics-lv_secureethics_data to /data
- Shell command: “mount /dev/mapper/vg_secureethics-lv_secureethics_data /data ” to mount the lvm partition
- Edit the fstab file “vi /etc/fstab ” this is step mount the partition permanently on the server
“/dev/mapper/vg_secureethics-lv_secureethics_data /data ext4 defaults 0 0 “add this line end of the file into fstab