EX200 Red Hat Certified System Administrator RHCSA – Managing LVM Logical Volumes

  • By
  • January 18, 2023
0 Comment

1. Linux Volume Management (LVM) part 1

Welcome all to this tutorial. Today I will open up a chapter on LVM or Linux Volume Management. Extremely useful. You will soon see what it is, how you can use it and what is it that it is good for in general. So the good news is that it is not that difficult to master and the commands are not that complex. Now, if we go ahead and introduce a new command DF or disk free and if we do Hyphen h or dash h, it will show us the available size on our disk partition. So you see that SDA one? This is a very nice tool as it tells you what percentage of the disk is occupied. So SDA One has 43% usage apparently SR zero has 100% usage but that’s just the ISO file.

So that’s correct. Don’t worry about that. SDB Two has 10GB of usage, which is pretty much 1% the partition that we have mounted I do believe in the previous tutorial. Now DF you can just use to have a list of these mounted partitions and how much space is actually used on them or what is the available space, so on. So you have the size here. So wait, let me just choose this one here, SDA One or let’s choose a normal actually, let’s take the example of the one that we have created. So this one says dev. SDB Two says size 10GB right next to it only 33 megabytes have been used and available.

It’s pretty much 10GB. Again, because it doesn’t actually show these small numbers because we practically haven’t occupied almost any space on it and I don’t think that this is 1%, it’s probably less so it doesn’t really matter. It says used. So the amount of space that is used that is occupied is 1% and then it says mounted on and it will show you the folder, it will show you the mount point here. So you see that the mount point is as we have specified it before. Again, another one of those useful tools that can provide you with all sorts of interesting information.

Anyway. Now, one of the first things that we need to do if we want to see how the Linux volume management actually works and functions, because this is an important part of Red Hat and of pretty much any other Linux distribution out there, we need to figure out. We first need to assign or change the IDs of our partitions so that they would be usable by LVM. In order for us to do this, we will need to jump into Fdisc devstb. We are going to mess around with STB and we will use the T option. It says partition number. Okay, let’s select the partition number. But wait, before I do this, let me just type in Fdiscl.

I just want to show you what do I intend to change so that you know it has been actually changed. So you see, dev SDB here. I will change the system IDs here. You should see an LVM here pretty soon. So type in f disk dev SDP enter I know the option that I want to use. I will use D and says partition number one, two. Well, I want to do it for both, but the second one is mounted. So let’s go ahead and change it for the first one and then we’ll unmount the second one hex code. What could that be? Well, if you want to see the hex codes for IDs, you can just go ahead and press L. And there you go. You have these hex codes for the IDs of the I’ve used actually this file to show you what sort of file systems can Linux read. And okay, that’s perhaps not the best of examples, but definitely you can see a lot of these things here. No big deal. Anyway, let’s go ahead and search for what we actually need. So let me just go ahead and scroll through this to see it.

So we have NTFS sex fat here. We don’t really want that. Fat, fat, fat. We don’t really need those either. It should be around here somewhere. I swear if somebody sees LVM, feel free to scream, but I’m not going to hear you. Somebody might. Okay, so we don’t need swap, we don’t need Linux. There we go. So Linux LVM, we have found it and the hex code for that is eight E. Okay, so let’s type in eight E, press Enter. Changed type of partition linux to Linux LVM let’s see what happens when we try. Let’s see if we can actually change the system ID for the partition SDP two. Let’s go ahead and do this and use two. And type in eight. E changed partition of Linux to Linux LVM So let’s see if this has taken place right, changes and it says okay, so I get a warning. The partition table has not been altered to reread the partition. Okay, I didn’t actually mess around with the partition table.

That’s fine. It says down here warning rereading the partition table failed with error 16 device or resource busy. The kernel is still using the old table. Type in F disk shell. What am I typing in real wrong? It has changed it, but you should definitely not do this. Unmount the system and then do it. Let me just go ahead and do it because we got a pretty serious warning there. Clear the screen. You mount mntemi, is it? Yes, it is. Fdisc dev STB. Yeah, my awesome. Typing f disk. Okay then.

So we need to change it for the second one, eight E. And we need to change it for the first one, eight E. And let’s go ahead and write these changes. Excellent. So it says the partition table has been altered. It’s all fine and dandy. We don’t get any warnings or errors or anything of a kind. Everything should be fine. If you get a serious warning like that one, if it says that it’s still using something old or something of a kind, yeah, you should definitely go ahead and have a look at that and see what the problem is. I mean, obviously change it because something is a mess.

We got the ID, so it says at and it says here Linux LVM. Okay? Now the LVM can actually use these partitions and that’s completely useless at this point of time because we really haven’t done anything to the LVM. If we really haven’t done anything with the LVM itself, we’ve just changed it for these partitions. Now LVM at later stages will allow us to dynamically resize space on the drive.

We don’t need to know in advance how much drive do we need for partitions because we are able to resize it at a later point of time and there is no need to reformat the partitions or anything of a kind, create new ones to resize something. You can just resize it without bigger problems using a simple command. So you can resize the allocated space, you can resize the space quite easy and you can do it all live. There is no need for downtime or anything of a kind.

This is especially important on the servers for you as a regular user, it’s probably completely relevant because you can restart the machine. But yeah, I don’t really like turning off my machine. I don’t really like resetting it or rebooting it. I think that the uptime on my machine and my laptop is 2030 days, something like that, and it’s functional. But as I said, it’s not a big deal for home machines, but it is a big deal for big data centers or something like that.

Imagine if Google had to restart their service. Everybody in the world who uses Google services would not be able to use those services for what, maybe 510, maybe even 20 minutes, depending on the system and depending on what they’re doing. Wouldn’t that be ridiculous? Wouldn’t that be stupid? Well, of course it would. That’s why we have LVM where you can resize things at any point of time that you feel like as long as you have the permissions and no need for downtime or anything like that. LVM is also used for hot plug options or hot swipe options, where you basically are able to just pull the defective drive out or pull a non defective drive out of the system and just put it and just plug a new one in. So hot plugs, no big deal.

LVM allows for all of that. Now in the follow up tutorials here, I just wanted to introduce you to talk a little bit about it and make some preparations that will come in handy in the follow up tutorial. But in the follow up tutorial, what we are going to talk about is the abstraction layers. So we will create the physical volume the physical volumes. We will bundle them up. We will have SDB One and SDB Two, which will be put into a physical volume.

And then we will create the volume groups. We’ll create one volume group because that’s all we need. But you can create as many as you want, as many as your system allows you and then as last, we will create a logical volume. I will also talk about what these things are, as well as they are just layers of abstraction, but the picture is not always quite clear. And afterwards you will be able to see how these things can be resized live on a system without any downtime or anything of whatsoever. It’s quite simple. As I said in the beginning, you won’t have to use any complex commands, long one liners or anything of a kind. They will be pretty short, so no worries there. Anyway, I did you all farewell and wish you a ton load of luck.

2. Linux Volume Management (LVM) part 2

Welcome all to this tutorial. Today I will continue my talk about LVMS. And here I have this rather interesting drawing for you. In the drawing there are three sections. So you have the uppermost section, which is the File system. So the File system, hopefully by this point of time you come to understand is what the File system is to a good extent. As I have talked about it extensively in the previous tutorials. We’ve talked about its structure, how it looks like on Linux, where is what, and so on and so forth. Down below we have our storage devices and hopefully by now you know what disks are.

So you have disk one, disk two and disk three. On this particular machine I have two disks. But yeah, for the sake of this example I have typed in one, two and apparently I have two tools, which is again interesting. Let me just go ahead and correct that quickly. Subconsciously I knew I had two, but anyway, I created three for aesthetic purposes, I guess. And up above you have this layer of abstraction. So this part is LVM. This is what stands between the disks down below and the File system up above. That the user accesses. So first of all, you have physical volumes.

We need to make SDB One and SDB Two available for the creation of physical volumes. We need to aggregate them, so to say, in order to do that we will use PV Create. But we won’t do that much by just typing in PV Create. You see, these bars are like the physical volumes that I’ve placed here. So there are three of them, even though in reality I only have two. Well, I have two partitions here. SDB One and SDB Two. Anyway, next up we have the Volume Group.

So we can go ahead and create a Volume Group. You see these three down below, two in our case, but doesn’t really matter. We’ll go into this group, they will all join there, they will become one with the system. They will be treated as a single drive. That is what I’m trying to say. And here, at the end of the LVM layer, you will have to create a logical Volume which is basically breaking this group to an extent or taking a portion of it. That would probably be a better term, much better term.

So we are going to take a portion of this group and then we are going to convert it into logical volumes. Or we can take several portions of this group and then convert it into logical volumes and then we can do whatever we want with these logical volumes. That is the whole point, that they are dynamic, that you can manipulate them and Volume Group is as well. So you basically just go ahead and create a Volume Group. You type in the name of the group, choose any name that you like. I would suggest you choose something meaningful. Don’t follow my example in terms of naming. Seriously, I mean you’ve all seen how I name things, so not the best of ideas, trust me. Especially when you have 100 groups, you don’t want to be naming them coffee, spoon, table, chair, door, et cetera. Rather instead you want to name them by something that relates to the information that is stored there.

And then you provide a list of volumes. Basically you just type in Dev, SDB One and SDB Two and here they will actually be aggregated. Here they’re just made available as physical volumes. And then you will, as I said, create a logical volume which will take a section because this becomes one here. And then you say basically, okay, now that’s fine and dandy but now I would like to actually create something. So I take a portion of it I need, I don’t know, 10GB. I just specify the size 10GB and it will take the combined size of these two and it will say, okay, I would like to take 10GB from you because let’s say that this is let’s say that this is ten GB and Cubbytes and that this is maybe 2020 GB.

What is the comb? Well, you could have two separate partitions. One would be ten and the other one would be 20 here in the group they would be it would be 30. So the size of the group should be 30 if I’m not mistaken. And then from that 30 of the size of the group you’re going to say oh, okay, I would like to create a logical volume of 5GB. I don’t know, I want it to be a home directory for Mary who works on the second floor. So I would like that to be her home directory. And I can name it Red because she has red hair or something of a kind. Doesn’t really matter.

You get what I’m hoping that you are understanding what I’m telling you. Now just explain the logical concept of this. Basically we’re just going to merge this here and then from here we will go ahead and take a chunk of space and create a logical volume which we will be able to use later on for whatever reasons we need. Anyway, I am going to go ahead and open up another terminal. Should probably zoom it in. Well, easy there, don’t want it to be too big. Let’s go ahead and do this because we don’t want to see the background anymore. Become root clear. Excellent. Oh wait, now it’s excellent. Things that we need to do.

Well, as we saw from the example, the first thing that we should do is actually do PV create. But hey, wait, before you do PV create, you had to conduct the changes from the previous tutorial. And furthermore, I don’t need to do it here because I already know what I am going to assign and what partitions am I going to use. But you should definitely take into consideration like, okay, I have these partitions, I have these discs. From here I will take that, from there I will take that. I would advise you to take a pencil and a paper and just assign things on paper just so you have some sort of schematics for yourself which you will use at a later point of time.

Now let’s go ahead and start creating things. Go ahead and type in PV create dev SDB now here’s a neat trick. So I could type in dev SDB One, dev SDB Two or I could write SDB One, coma Two and if I had more, I could type in three, four, or I could write in something else. I don’t know, whatever is needed. But if I typed it in like this, it would save me an entire line of code.

Basically, instead of typing in again dev SDB Two I could just type in the two here and that would be fine. And there you go. It says Physical volume dev SDB successfully Created physical volume dev SDB Two successfully created. So this is one of those shortcuts that you can use with pretty much anything.

By the way, not just with PV Create, but any other command. This is a standard notation that Linux will recognize. So next up, we have to create a group, as you can see here. So we first done Picrate and now we need to do a Volume group. So just type in as the as I have written it out there. So VG Create and we shall name the group. How shall we name the group? I want to name it my wardrobe. No, let’s call it lyra. Let’s call it lyra. That’s not going to be a good name for a Linux volume group. But hey, what can you do about it? Then I need to go ahead and list the volume. So SDB One dev SDB one. Come on. Dev SDB two. And I do believe that that is it. I don’t have any others.

Volume Almira successfully created. Excellent. So let’s go ahead and clear the screen. And before we do LV Create, let’s go ahead and have a look at this group. Type in VG display. Before we type in VG Display, just press tab twice and take a look at all the available options that you have with VG. So, I don’t know, you can rename a group, you can remove a group. You can reduce I’m sure there’s a reduced here somewhere. There we go. So you can reduce a group by reducing a group.

You can, for example, remove SDB Two and leave only SDB One. You can there is a possibility to extend it here somewhere as well. There we go. So VG extend by extend, I would mean if we had SDB Three, we could make it we could make SDB 1234-5678, 910, 10 billion. If I had enough space, I most likely will create another one but with VG Extend, I would be able to add a few more to the group. Anyway, let’s go ahead and use VG Display. Press Enter. And let me just go ahead and move this terminal upwards a little bit. So I’m giving you a bit of nausea here. I know. My sincere apologies for that. So, we are interested in this. It says Volume Group. Wait, this is the one that I’m looking for.

Yes, it is. Sorry, I was thinking that showed me this one. This is not important. This is what we’ve created during the installation procedure. Because we’ve selected the encrypted volumes. That should just be the habit of everybody to as soon as you create, as soon as you are installing the system, just go ahead and encrypt it for your home computers and for service and for whatever you need for service. You probably won’t need to do it straight away.

You’ll be able to do it like this. But anyway, we will deal with looks and encryption soon enough. I will talk far more about it there. For the time being, we have Volume Group name. That would be lyra format. LVM two access. Read. Write. It is resizable VG status. And if we go down below, it says VG Size. Now, I am fairly certain that when I was creating SDB One and SDB Two that they were ten and five. If I am mistaken, if I’ve typed in something else, please correct me in the discussion section. But it doesn’t really matter. We’ve just combined the two into this group and that is what I really wanted to show you here.

If we go down below, that would be it. You have the UUID of the group as well, so that’s not a bad idea to keep it in mind that it is here. Okay, so you have you have 14. 99gb, and this is basically what is free. I think I have only 38 megabytes that are taken. On the whole on SDB Two, I think I’ve created a file Hay, and that was 38 megabytes directory, I think, or something of a kind. I’m not sure.

It doesn’t really matter. That’s what’s taken completely relevant, by the way. Let’s go ahead and clear the screen. Now, next up that we have to do is, as I have shown it here, we have to take a chunk of a Volume Group and actually create something meaningful out of it that the file system will be able to use and utilize, basically to be able to give a sense of dynamics to it. Anyway, let’s go ahead and type in LV Create. And then we’re going to go ahead and name it. This Volume Group will be named so Lyra and what else goes with it? Well, lyra jr. So that’s going to be the name.

And then for L, we need to define the size. How big do we want this logical volume to be? Well, I’m going to go ahead and say, I don’t want to select five. Let’s go ahead and select eleven. So 11gb, because that’s going to have one partition is ten and the other one is five. And if we take eleven, that’s going to take a significant chunk of it. And then we need to say a group from which we want to take this chunk from the group is Alyra Press Center. Logical volume.

Alira Jr. Created LV Display let’s go ahead and move this upwards a little bit. So up and up we go further up we go. And there we go. So logical Volume lyra Jr Logical Volume path. So you first have to go into Dev and then into the group Logical Volume Group Lyra. And then you have to go to the Logical Volume that is actually within that group. So volume group Name logical Volume. You have pretty much the same information there.

And here you have the size that is displayed. Now let’s go ahead and take a look at another interesting thing. Group Display. Let’s see if it’s going to show anything here. And this is not the one that we’re looking for. This is the one that we are looking for. And you can see that it’s allocated 11gb has free 3. 99gb, which is basically four. It adds up to five. Anyway, I bid you all farewell here because I am running short on time and I sincerely hope to see you in default tutorial where we will continue to work with this.

3. Linux Volume Management (LVM) part 3

Welcome all. Welcome back. Actually to this tutorial. Today, we are going to go ahead and do a few more things with Linux Volume. In regard to Linux Volume Management, one of those things will be that well, you know those logical volumes that we’ve made? So the ones we made with with this command? Well, we kind of need to format them. I mean, if we want to use them. And then we need to create their mount points and then we need to mount them. And if we want, we can put them in F tab as well. So let’s go ahead and do those things. The first thing that we need to do is of course, format them. So we need to type in then we need to go ahead and have a look where our group is. So it’s not lyra. I’m looking for Lyra. The Free total Allocated.

Where is it? Latah. So it’s volume. Group name lyra System Form. Oh, right, of course. My bad, my bad. We need to type in Logical Volume Display. And further up we go even more up. Okay, there we go. So it’s Dev Lyra and Liar miffs space dev lyra Jr. Because Lyra is our logical Volume group and Lyra Gr is our logical Volume and we want it to be XFS enter. And there we go. It is XFS. Indeed. Now, we now need to go ahead and create a mount point for it. Now we can create it, I suppose. Well, actually we can create it in the should we create in the root folder? Well, not the best of ideas, but I guess we could. However, I won’t do it for this tutorial, I’m going to go ahead and create it in let’s go back into the our Safe Place MNT and created here. So udemy one. Udemy Two. I think I’m going to go ahead and create a new one.

MK Deer. And the new one shall be what should the new one be? Sister. Yes, it will be lyra’s Sister. No, that doesn’t look good. We need to sibling know how, shall we? David? Well, this will be a Logical Volume One. Okay, let’s give it a strictly technical name. .

No sisters, no siblings, no fathers, no family in general. Just logical Volume One. Like Machine. And now lyra will be well, lyra Gr will be logical Volume. Lyragr will be mounted here. This will be its mount point. So mkdir logical volume zero one. Let’s go ahead and press Enter. Do ll. It does exist. It is here. It has been created. So let’s go ahead and type in mount. You don’t need to do anything special when mounting logical Volumes pretty much the same way. You just need to make them in the first place. And then it’s pretty easy to mount them. So dev Lyra Jr MNT logical volume one. Hey, guess what? It has been mounted. Nothing in there. I don’t think I created anything. I might have. Let’s go ahead and check it out. No, there is nothing in there. Well, of course not. I’ve just formatted the drive. I thought I might have created something before this, but it just hit me that I’ve just formatted the drive. So it wouldn’t really matter. Everything would get deleted anyway. Let’s go ahead and type in Mount Grep.

And what shall we? Grep? We will grep dev lyra Strangely, I haven’t really mounted that. Or I haven’t really typed it. Well, let’s just see if it is here under the mount. There are a lot of things well, another easier way that I’ve showed you before, it’s DFN, H. And there we go. So it is the last one. It is indeed mounted. It’s Dev Mapper lyra and then you have this Hyphen here. And then it’s Lara Jr. So it is Lyra Group and Lyra Jr. Only 1% of the disk is used for, I think, system info, something like that. Not sure. The system usually reserves a portion of the disk. It doesn’t matter how much space you assign. And then we have its mount point here, just to show you. We can go ahead and unmount this just as easily. I can literally just put a U here and delete one of these two.

I’ll delete the later, press Enter and there you go. I have oh, target busy. No. How about now? There we go. I have indeed unmounted it. If I press DFH again, you can see that it is indeed not mounted here at all. It is gone anyway. That’s how you would create and mount a logical volume. Now, how about resizing a logical volume? How about doing that? Well, let’s go ahead and come on, please. There we go. It is there anyway. Let’s go about resizing it. I’m not really sure as far as the size of it is concerned. Let’s just go ahead and check that because I don’t really remember. Okay, so Dev Mapper Lyra was eleven G, so 11gb. Very well. I don’t know. Let’s resize it to 14, let’s say. So all we need to do is type in LV resize. Is it there? Yes, there it is. So we wanted to resize it to 14. Let’s go ahead and do that. So, 14 GS. And now we need to specify which logical volume would be like to resize. That shall be dev. Lyra jr. There we go. Press enter and we’re done.

Not really. Take a look at this. If you type in Dfspace again, you’ll see that it still says that it’s 11gb. But why? It says here that the logical volume has successfully been resized. Well, it has indeed. But you need to resize the file system as well. So for XTA four or something like that, I think you can use resize to do FS and use pretty much the same or similar syntax. But for XFS file systems, we will need to type in XFS, which is the one that you will use in Red Hat anyway XFS and then just press Tab twice. Down below you will get a list of possibilities. Same thing you will get if you type in Resize. If you type in Tab twice you can see that it says that you have things for Resize. Not sure about no, didn’t install anything here but doesn’t really matter. What I want to focus at the moment is on XFS. So let’s go ahead and type in XFS. Once again, press tab twice. And here you can see that as before, you have a lot of tools. The one that we are going to use now is Grow. I’m just looking for it.

Well, I don’t really need to find it. I know how it is called. There you go. Grow FS. And there it is. Just as I type everything that I find, it doesn’t really matter now we need to go ahead and specify the logical volume which is Dev and Lyra Jr. Changed from this to this. I am not reading these big numbers. These are blocks. We’re not really that interested in them. It’s not something that’s easily read by humans. You prefer things like see okay from that many gibbytes to that many gigabytes. And if you type in DF space H you can see that the volume has indeed been resized. Please keep in mind that we have done all these things live. The disk did not go down. It was usable. In fact, it was mounted the whole time as you could have seen. And we have resized it from 11gb to 14gb. Very simple. No big deal there. If you would like to extend a group or something like that, you have VG. Press tab twice. You see you have here somewhere it says Extend and there you go, it says Extend.

You can use the Extend in order to actually put more volumes into the group, put more devices into the group. Or you could well, where is it? There we go. This is for group remove. All you have to do is just type in VG remove group name and that’s it. VG rename is fairly similar as well. Let me just show you quickly. So rename I would like to rename lyra into what? Lyra One volume group lyra successfully renamed to Lyra One. You see, the commands are fairly simple. There isn’t that much science to it really. You just type in the command and it’s pretty much self explanatory. If you want to rename the group, type in BG. Rename old group name, new group name that’s all that there is to it. That would be it for this tutorial. Until next one. I bid you farewell.

Comments
* The most recent comment are at the top

Interesting posts

The Growing Demand for IT Certifications in the Fintech Industry

The fintech industry is experiencing an unprecedented boom, driven by the relentless pace of technological innovation and the increasing integration of financial services with digital platforms. As the lines between finance and technology blur, the need for highly skilled professionals who can navigate both worlds is greater than ever. One of the most effective ways… Read More »

CompTIA Security+ vs. CEH: Entry-Level Cybersecurity Certifications Compared

In today’s digital world, cybersecurity is no longer just a technical concern; it’s a critical business priority. With cyber threats evolving rapidly, organizations of all sizes are seeking skilled professionals to protect their digital assets. For those looking to break into the cybersecurity field, earning a certification is a great way to validate your skills… Read More »

The Evolving Role of ITIL: What’s New in ITIL 4 Managing Professional Transition Exam?

If you’ve been in the IT service management (ITSM) world for a while, you’ve probably heard of ITIL – the framework that’s been guiding IT professionals in delivering high-quality services for decades. The Information Technology Infrastructure Library (ITIL) has evolved significantly over the years, and its latest iteration, ITIL 4, marks a substantial shift in… Read More »

SASE and Zero Trust: How New Security Architectures are Shaping Cisco’s CyberOps Certification

As cybersecurity threats become increasingly sophisticated and pervasive, traditional security models are proving inadequate for today’s complex digital environments. To address these challenges, modern security frameworks such as SASE (Secure Access Service Edge) and Zero Trust are revolutionizing how organizations protect their networks and data. Recognizing the shift towards these advanced security architectures, Cisco has… Read More »

CompTIA’s CASP+ (CAS-004) Gets Tougher: What’s New in Advanced Security Practitioner Certification?

The cybersecurity landscape is constantly evolving, and with it, the certifications that validate the expertise of security professionals must adapt to address new challenges and technologies. CompTIA’s CASP+ (CompTIA Advanced Security Practitioner) certification has long been a hallmark of advanced knowledge in cybersecurity, distinguishing those who are capable of designing, implementing, and managing enterprise-level security… Read More »

Azure DevOps Engineer Expert Certification: What’s Changed in the New AZ-400 Exam Blueprint?

The cloud landscape is evolving at a breakneck pace, and with it, the certifications that validate an IT professional’s skills. One such certification is the Microsoft Certified: DevOps Engineer Expert, which is validated through the AZ-400 exam. This exam has undergone significant changes to reflect the latest trends, tools, and methodologies in the DevOps world.… Read More »

img