Hey guys and welcome back.
So in the previous nugget we saw some basic LVM configuration and we could see some of
the tools that we could use or the commands should I say that we could use to set up this
technology.
Now there are some additional commands that we do want to be aware of for the purposes
of the examination.
Let me just tell you what some of those are and what they can actually do for us.
Now the first one I want to talk to you about is one called PVChange and again I would encourage
you to read the man pages on these particular commands and explore everything that they
are capable of.
But as a high level overview to understand what these commands do for the examination,
what this one does, it allows us to change attributes of a physical volume.
The next command is one called PVMove.
What this command is going to allow us to do, it's going to allow us to move, hence
the name, data from one physical volume to another physical volume.
So realistically when you want to happen to downsize a volume group, i.e. remove a physical
volume, you may want to move that data first, in which case the PVMove command is going
to allow you to do such a thing.
Now following on in that vein, if we have our volume group, remember that big logical
chunk, if we want to remove one of the physical volumes from that volume group, the command
we would use is PVRemove.
Similarly if we want to make changes to particular attributes of a logical volume, the command
we could use would be LVChange.
As we can see here we're following a similar format, PVChange changes attributes of a physical
volume, LVChange changes attributes of a logical volume.
Now if we want to actually extend a logical volume, we could use the command LVExtend.
Similarly if we wanted to reduce the size of a logical volume, we could use the command
LVReduce.
And again if we want to make changes to a volume group, the command would be VGChange.
And if we wanted to extend the size of a volume group, make our big logical chunk even bigger,
we would use the command VGExtend.
Now there is not enough time, definitely not, to display all of these commands and show
you how to work with them.
That would mean this scale would run on for way too long.
So as always as homework I would suggest that you use the man page on these commands, check
them out.
But if you want to have a full listing of the available commands that we can use, if
I just happen to say LVM and I press help and hit enter, we can actually see all of
the different options right here.
So if I scroll on up, we can see here LVCreate creates a logical volume.
LVExtends ultimately extends and adds space to your logical volume.
We can see LVRemove, LVRename, same with PVCreate, PVMove, VGCreate, VGReduce, so on and so forth.
So what I will do is I will give you an example of one of these commands and what we will
do is we will extend one of our logical volumes.
So if I hit exit and I clear the screen.
Okay, so if I do LVDisplay to see my logical volume and of course I'm always forgetting
and my sudo command, so LVDisplay with sudo, hit enter.
So how about we extend medium chunk and we will give it an additional let's say 100meg.
Now we can see here the actual path here which we saw before but I do actually feel like I
should make a note here just for clarity.
See this path format of dev followed by the volume group followed by the logical volume.
This is actually the naming convention with respect to LVM1 and you actually still see
this even when using LVM2 which we have installed.
I believe this is for backwards compatibility reasons.
However you will have noticed in the previous nuggets we also saw the format of dev forward slash
mapper forward slash and then the last part was the volume group with a hyphen and then
the logical volume.
This naming convention is actually the newer naming convention for LVM2.
So both of these are kind of accepted albeit this one is the more modern and up to date
one.
So the command I will do is I will say sudo LV extend and I'll do dash L and now what
I want to do is to specify the new size I want this to be.
So I want to increase it by 100 to 600.
I'm not going to say add 100.
I'm actually going to give the new fixed size of 600.
And I'll now say dev my storage chunk and then the name medium chunk.
If I hit enter we can see here we have now successfully resized the medium chunk logical
volume to be 600 megs.
If I do my sudo LV display we can now see this has actually been resized.
Now one thing I want to note is that if we want to do this again let me extend it maybe
to 700.
I will actually use the newer naming convention.
So what I will do here is I will say sudo LV extend and I'll say dash L and I'll now
make this 700 meg.
This time I'll use a convention of dev forward slash mapper and now I'm going to say the
volume group hyphen the logical volume.
So if I hit enter now notice this also works and again if we display our outputs we can
see here this has now been displayed to 700 meg.
Now the last thing I just want to briefly cover is remember we talked about the ability
of LVM to be able to create snapshots so that we have a perfect frozen image from a
particular time that we can then use to revert back to.
Let me show you how we can actually do this.
If I say sudo LV display and I scroll on up we can see we have this LV right here.
What if I want to be able to create a snapshot of this logical volume in its current state
so that I could reverse back and go to this save state.
In the event of maybe a disaster say for example so what we're going to do is we're going to
take a note of the path here or alternatively we could use the dev mapper myStoriesChunk
hyphen littleChunk naming convention if we so choose but for now I'll just keep it simple
and copy this path and I'll show you the syntax we need to use.
The way we can do this is again by using the LV create command I will say dash L the size
is going to be 52 meg and to create this snapshot we're going to have to use the dash s flag
this ultimately will generate the snapshot and now I'm going to say dash n to give this
snapshot a name so I'll just call this something identifiable so I'll say littleChunk snap1
which is the very first snapshot that I'm going to take of this logical volume and now I'm
going to specify the path so I'll say dev myStorageChunk and then littleChunk so if I hit enter now
we can see here that this logical volume has actually been generated so as we can see here
with LVM we do have many commands to perform many different tasks LVM is very very comprehensive
you can do so much with it that is why I would always encourage you to take this further explore
those commands we talked about read demand pages and do a little labbing until you feel
confident and familiar with the technology but ultimately those are the core concepts you
want to understand for the purposes of the Lpik2 examination with respect to LVM so I hope this
has been informative for you and I'd like to thank you for viewing.