LVM (Logical Volume Management) is a flexible and advanced option available to manage hard disks in most of the major Linux distributions. It is easy to manage the disks with LVM than the tradition tools like fdisk, parted or gparted.
Some of the terms which you need to understand while using LVM:
- Physical Volume (PV): Consists of Raw disks or RAID arrays or other storage devices.
- Volume Group (VG): Combines the physical volumes into storage groups.
- Logical Volume (LV): VG’s are divided into LV’s and are mounted as partitions.
Steps:
Once the disks has been added, you can list them using the following command.
# fdisk -l
1. Now partitions both the disks /dev/xvdc and /dev/xvdd using fdisk command as shown.
# fdisk /dev/xvdc # fdisk /dev/xvdd
Use n to create the partition and save the changes with w command.
2. After partitioning, use the following command to verify the partitions.
# fdisk -l
3. Create Physical Volume (PV).
# pvcreate /dev/xvdc1 # pvcreate /dev/xvdd1
4. Create Volume Group (VG).
# vgcreate testvol /dev/xvdc1 /dev/xvdd1
Here, “testvol” is the VG name.
5. Now use “vgdisplay” to list all details about the VG’s in the system.
# vgdisplay OR # vgdisplay testvol
6. Create Logical Volumes (LV).
# lvcreate -n lv_data1 --size 12G testvol # lvcreate -n lv_data2 --size 14G testvol
Here, “lv_data1” and “lv_data2” are LV name.
7. Now use “lvdisplay” to list all details about the Logical volumes available in the system.
# lvdisplay OR # lvdisplay testvol
8. Format the Logical Volumes (LV’s) to ext4 format.
# mkfs.ext4 /dev/testvol/lv_data1 # mkfs.ext4/dev/testvol/lv_data2
9. Finally, mount the file system.
# mount /dev/testvol/lv_data1 /data1 # mount /dev/testvol/lv_data2 /data2
Make sure to create data1 and data2 directories before mounting the filesystem.