Thumbnail for Logical Volume Management (LVM) in Linux | Create LVs Step-by-Step || RHCSA Complete Course by DexTutor

Logical Volume Management (LVM) in Linux | Create LVs Step-by-Step || RHCSA Complete Course

DexTutor

9m 54s1,187 words~6 min read
YouTube auto captions
Transcript source

YouTube auto captions

This transcript was extracted from YouTube's auto-generated caption track. The transcript below is server-rendered so it can be read, searched, cited, and shared without opening the original YouTube player.

Pull quotes
[0:09]Hi, in this video we are going to learn a very important topic, which is logical volume management.
[0:09]So we will understand what is the need of logical volume management and then we will learn how to create a logical volume.
[0:09]Now, what is logical volume management or what is the need of logical volume management?
[0:09]So, logical volume management in Linux is a flexible way to manage disk space effectively.
Use this transcript
Related transcript hubs

[0:09]Hi, in this video we are going to learn a very important topic, which is logical volume management. So we will understand what is the need of logical volume management and then we will learn how to create a logical volume. So this is a very important topic from the exam point of view. You can expect at least two questions related to this. Now, what is logical volume management or what is the need of logical volume management? So, logical volume management in Linux is a flexible way to manage disk space effectively. Suppose now that you have three separate disks of size 6 GB, 5 GB, and 4 GB. And you need to allocate 8 GB to user U1 and 7 GB to user U2. However, none of your disk alone have that much of free space, so this is where LVM becomes essential. Now, instead of being limited by the size of individual disk, LBM allows you to combine the multiple physical disks into one single storage pool. So how this will work? We will first convert the disk into physical volumes. So each of the three disks is initialized as a physical volume first and the size will be same. Next, we will create a volume group. So these physical volumes are combined to form a single volume group. So in this case, all three disks together create a 15 GB storage pool. Finally, we will create logical volumes from this combined storage and we will allocate 8 GB to user one and 7 GB to user two. Even though no single disk had that much of space initially. So what are the key benefits of using LVM? First, flexible storage management. So you need not to worry about individual disk sizes. Next is easier expansion. In case you need more space, you can simply add another disk to the volume group. Third, resizing on demand. The logical volumes can be resized dynamically without affecting the data. Last is effective use of storage, so no wasted space due to disk size limitations. So, from the user's perspective, they will see a single allocated volume of 8 GB or 7 GB, but in reality, the data might be spread across multiple disks. LVM makes the storage management much more effective, scalable, and user-friendly compared to traditional partitioning. Now, what are the key elements? So to summarize from our discussion so far, we will have the physical devices. We will convert them first into physical volume. We'll combine the physical volumes to form the volume group and finally, from this volume group, we will create multiple logical volumes. So what are the steps for creating a logical volume? First, we will prepare the physical device, which can be your partitions or disk altogether. Next, we'll create a physical volume using the command pvcreate. From the physical volume, we will create a volume group using vgcreate. Then, we'll create logical volumes from the volume group by using the command lvcreate. So, once the logical volume is created, then we can add the file system using mkfs. And finally, we can have it mounted persistently by editing the /etc/fstab file. So let us first list the available disk. So now I will be using these three disks, SDD, SDE, and SDF of size 6, 5 and 4GB respectively. So remember, the first step was to convert the disk into physical volume. The command is pvcreate, and then you will write the path of the disk, which is /dev/sdd. You can see, physical volume /dev/sdd successfully created. Similarly, we will do for SDE and SDF.

[4:58]So this is the first step. How to check that these volumes, physical volumes are created or what all physical volumes have been created so far? So we can use PVS. So this will show all the physical volumes. You can see here, SDA2 is the already existing one and these three we have just created. If you want to check the detail of an individual physical volume, you can use PV display and the address /dev/sdd. So it will give you a little more detail about an individual physical volume. Next step is to combine multiple physical volumes to create a volume group. So now you can combine two, three, four, or even one physical volume also you can use to create a volume group. So the command is vgcreate. Then we will give the name, let's suppose newVG, and then you will give the path of all the physical volumes which you want to club to create a volume group. So, in this case, I want to club SDD, /dev/sde, and /dev/sdf. You can see, the new volume group is created. Since the size were 6, 5 and 4GB, so this means the size of the volume group newVG should be 15. So to check that, we'll use VGS. And you can see here, the size is 14.99. So the size will be slightly less because some of the space is used for creating the or maintaining the metadata, okay? In case you want to see the detail about this volume group, so you can use VG display /dev/newVG. So this will give you more detail about the volume group. Now, the volume group is ready. From this volume group, you can create n number of logical volumes whose combined size can be 15 GB, okay? So, we will create now a logical volume of 8 GB. So the command is lvcreate -n, which means the name. Let's suppose LV1 -L, capital L, which is to specify the size, so 8G from the volume group newVG. So logical volume is created. Again, LVS. So you can see the new logical volume LV1 of size 8 GB. Again, if you want more details, so LV display /dev/newVG/LV1. So this will give the detail about the logical volume. So once we have the logical volume created, we can install the file system by using the mkfs command. So mkfs.xfs is the file system. /dev/newVG/LV1. So the file system is installed. Finally, to make it persistent, we need to edit the /etc/fstab file. And here we will make similar kind of entries. First is the path, /dev/newVG/LV1. Next is you need to give the mount point, which we have learned earlier also when we created a new partition. So here, although I have not created a mount point as of now, but let us suppose that the mount point is newmount. Tab, you will give the file system, which was XFS, then defaults, 0, and 0. So we'll save this and the logical volume is mounted persistently. Just ensure that you create the new mount point, okay? Also remember, if you make any changes, let's suppose in the next video you learn how to delete the logical volume and you delete those logical volumes or the volume groups, also edit this fstab file and delete this entry, okay? So this was one of the ways of creating logical volume. In the next video, we will learn how to create logical volume using physical extent.

Need another transcript?

Paste any YouTube URL to get a clean transcript in seconds.

Get a Transcript