How to create and extend logical volumes by using LVM on Redhat 8.5
- 00:39 lsblk
- 00:54 fdisk /dev/nvme0n2
- 01:43 fdisk /dev/nvme0n3
- 02:18 pvcreate /dev/nvme0n2p1 /dev/nvme0n3p1
- 02:50 vgcreate vg0 /dev/nvme0n2p1 /dev/nvme0n3p1
- 03:35 lvcreate --name=lv1 --size=10G vg0
- 04:05 lvcreate --name=lv2 --size=9G vg0
- 04:30 mkfs.ext4 /dev/vg0/lv1
- 04:49 mkfs.ext4 /dev/vg0/lv2
- 05:32 vim /etc/fstab
- 06:52 lsblk
To create and extend logical volumes by using LVM on Redhat 8.5
Introduction
A logical volume manager (LVM) is a type of storage virtualization that combines multiple hard drives and/or partitions into a single volume group (VG), which then can be subdivided into logical volumes (LV), or can be used as a single large volume.
Installation Procedure:
STEP 1: List the disk by using the below command
[root@linuxhelp ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 10.2G 0 rom /run/media/root/RHEL-8-5-0-BaseOS-x86_64
nvme0n1 259:0 0 25G 0 disk
├─nvme0n1p1 259:1 0 1G 0 part /boot
└─nvme0n1p2 259:2 0 24G 0 part
├─rhel-root 253:0 0 21.5G 0 lvm /
└─rhel-swap 253:1 0 2.5G 0 lvm [SWAP]
nvme0n2 259:3 0 10G 0 disk
nvme0n3 259:4 0 10G 0 disk
STEP 2: Make Disk partition for nvme0n2 by using the below command
[root@linuxhelp ~]# fdisk /dev/nvme0n2
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x608951fd.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-20971519, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-20971519, default 20971519):
Created a new partition 1 of type 'Linux' and of size 10 GiB.
Command (m for help): wq
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
STEP 3: Make Disk partition for nvme0n3 by using the below command
[root@linuxhelp ~]# fdisk /dev/nvme0n3
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x72537795.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-20971519, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-20971519, default 20971519):
Created a new partition 1 of type 'Linux' and of size 10 GiB.
Command (m for help): wq
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
STEP 4: Create the physical Volume for nvme0n2p1 and nvme0n3p1 by using the below command
[root@linuxhelp ~]# pvcreate /dev/nvme0n2p1 /dev/nvme0n3p1
Physical volume "/dev/nvme0n2p1" successfully created.
Physical volume "/dev/nvme0n3p1" successfully created.
STEP 5: Create Volume group for nvme0n2p1 and nvme0n3p1 by using the below command
[root@linuxhelp ~]# vgcreate vg0 /dev/nvme0n2p1 /dev/nvme0n3p1
Volume group "vg0" successfully created
STEP 6: Create Logical Volume for vg0 by using the below command
Lv1
[root@linuxhelp ~]# lvcreate --name=lv1 --size=10G vg0
Logical volume "lv1" created.
Lv2
[root@linuxhelp ~]# lvcreate --name=lv2 --size=9G vg0
Logical volume "lv2" created.
STEP 7: Apply File Type lv1 and lv2 by using the below command
lv1
[root@linuxhelp ~]# mkfs.ext4 /dev/vg0/lv1
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 2621440 4k blocks and 655360 inodes
Filesystem UUID: 02b0ee18-32ef-407f-bcda-80ad19ff3ea6
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
lv2
[root@linuxhelp ~]# mkfs.ext4 /dev/vg0/lv2
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 2359296 4k blocks and 589824 inodes
Filesystem UUID: fc922047-50b6-4829-8536-0cce869fc725
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
STEP 8: Create Mounting Directory by using the below command
[root@linuxhelp ~]# mkdir /lv1
[root@linuxhelp ~]# mkdir /lv2
STEP 9: Mount the logical volume by using the below command
[root@linuxhelp ~]#vim /etc/fstab
/dev/vg0/lv1 /lv1 ext4 defaults 0 0
/dev/vg0/lv2 /lv2 ext4 defaults 0 0
STEP 10: After Restarting check the disk by using the below command
[root@linuxhelp ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 10.2G 0 rom /run/media/root/RHEL-8-5-0-BaseOS-x86_64
nvme0n1 259:0 0 25G 0 disk
├─nvme0n1p1 259:1 0 1G 0 part /boot
└─nvme0n1p2 259:2 0 24G 0 part
├─rhel-root 253:0 0 21.5G 0 lvm /
└─rhel-swap 253:1 0 2.5G 0 lvm [SWAP]
nvme0n2 259:3 0 10G 0 disk
└─nvme0n2p1 259:4 0 10G 0 part
└─vg0-lv1 253:2 0 10G 0 lvm /lv1
nvme0n3 259:5 0 10G 0 disk
└─nvme0n3p1 259:6 0 10G 0 part
├─vg0-lv1 253:2 0 10G 0 lvm /lv1
└─vg0-lv2 253:3 0 9G 0 lvm /lv2
Conclusion:
We have reached the end of this article. In this guide, we have walked you through the steps required to create and extend logical volumes by using LVM on Redhat 8.5. Your feedback is much welcome.
Comments ( 0 )
No comments available