How to Create LVM Partition on CentOS 7 Using Additional Hard Disk

Logical Volume Management (LVM) is an abstraction layer between operating system and physical hard drives and can be easily managed the disk space.

This article describes How to Create LVM Partition on CentOS7 Using Additional Hard Disk.
Step 1. Check Hard Disk Details: Run the following command to get the hard disk details:
[[email protected] ~]# fdisk -l
…………………….
Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
…………………….
Step 2. Create a Physical Volume: Run the following command to create a physical volume using the above hard disk:
[[email protected] ~]# pvcreate /dev/sdb
  Physical volume “/dev/sdb” successfully created.
Step 3. Create a Volume Group: Run the following command to create volume group using the above physical volumes:
[[email protected] ~]# vgcreate vg-data /dev/sdb
  Volume group “vg-data” successfully created
Step 4. Create a Logical Volume: Run the following commands to create logical volume from the above created volume group:
[[email protected] ~]# lvcreate -n nginx-data -l +100%FREE vg-data
  Logical volume “nginx-data” created.
Use -l +100%FREE option to use entire space of the volume group for a logical volume.
Step 5. Verify the Changes: Run the following command to verify the physical volume:
  PV         VG      Fmt  Attr PSize   PFree
…………………….
  /dev/sdb   vg-data lvm2 a–  < /span><10.00g    0
Run the following command to verify volume group:
  VG      #PV #LV #SN Attr   VSize   VFree
  ……………………
  vg-data   1   1   0 wz–n- <10.00g    0
Run the following command to verify the logical volume and it will show as below:
  LV         VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
…………………….
  nginx-data vg-data -wi-a—– <10.00g
Done!!! LVM and LVM partition is created successfully and ready to use. Follow the article Howto Create and Mount a LVM Partition/Volume on CentOS 7 to create and mount the LVM partition on CentOS 7.

Leave a Reply