Create LVM in Centos/Rocky Linux.

Create LVM in Centos/Rocky Linux.

What is LVM?

LVM is a tool for logical volume management which includes allocating disks, striping, mirroring and resizing logical volumes.
With LVM, a hard drive or set of hard drives is allocated to one or more physical volumes. LVM physical volumes can be placed on other block devices which might span two or more disks.
The physical volumes are combined into logical volumes, with the exception of the /boot partition. The /boot partition cannot be on a logical volume group because the boot loader cannot read it. If the root (/) partition is on a logical volume, create a separate /boot partition which is not a part of a volume group.


How to Create LVM in Centos and Rocky Linux.

Code to create LVM.

  1. yum install -y makecache lvm2
  2. lsblk
  3. pvcreate /dev/sdb /dev/sdc
  4. vgcreate demo_lvm_group /dev/sdb /dev/sdc
  5. lvcreate -L 5G -n demo_lvm_volume demo_lvm_group
  6. mkfs.ext4 /dev/demo_lvm_group/demo_lvm_volume
  7. mkdir /mnt/lvm
  8. mount /dev/demo_lvm_group/demo/lvm_volume /mnt/lvm/
  9. df -h

Code Definition

To install LVM
$yum install -y makecache lvm2

To check available partition
$lsblk

Command to create Physical Volume, here you can define one or more partition name. 
$pvcreate /dev/sdb /dev/sdc

Command to create Logical Volume Group, "demo_lvm_group" is a name, shoulb be change. 
$vgcreate [demo_lvm_group] /dev/sdb /dev/sdc

Command to create Logical Volume, -L is use for define size, -n is use for Logical Volume name "demo_lvm_volume" (Changable). 
$lvcreate -L 5G -n [demo_lvm_volume] [demo_lvm_group]

Command to create file system for newly created Logical Volume.
$mkfs.ext4 /dev/demo_lvm_group/demo_lvm_volume

Create directory and mount Logical Volume
$mkdir /mnt/lvm
$mount /dev/demo_lvm_group/demo/lvm_volume /mnt/lvm/
$df -h

Snapshots





    • Related Articles

    • Setup FTP access to rocky linux 9.5 server using vsftpd

      Install vsftpd sudo dnf install vsftpd -y Enable and Start the vsftpd Service sudo systemctl enable vsftpd --now Verify the status: sudo systemctl status vsftpd Adjust Firewall Rules By default, the Rocky Linux firewall blocks FTP traffic. Allow it: ...
    • Install Rocky Linux 9.2

      What is Rocky Linux? Rocky Linux is a Linux distribution developed by Rocky Enterprise Software Foundation, which is a privately owned benefit corporation that describes itself as a "self-imposed not-for-profit". It is intended to be a downstream, ...
    • How to Partition, Format, and Mount Secondary Drives in Linux - Manual Drive Configuration (MDC)

      Introduction This guide provides detailed instructions on how to manually configure secondary drives in a Linux system, including partitioning, formatting, and mounting the drives. Warning Performing these steps on an existing primary drive or a ...
    • What is Boot Process in Linux OS.

      Boot Process in Linux OS. Have you ever wondered what happens behind the scenes from the time you press the power button until the Linux login prompt appears? Press the power button on your system, and after few moments you see the Linux login ...
    • Backup, Snapshot, and Restore Linux installations using Timeshift

      If you mess up (or are going to mess up) some config files or drivers, it is always good to have a fallback point. The de-facto standard for doing this on Linux is Timeshift. Timeshift for Linux is an application that provides functionality similar ...