LVM, or logical volume management, this is the term LVM you probably have heard many times, but let's
look over how exactly this functions.
LVM allows disc to be combined together and it is a software based.
So again, pictures, 6000 words.
And that's why I have laid out in this picture and will go over it one by one.
If you see if you look at the first disk, this is one disk.
And out of this this let's say if it's 100 gig out of this 100 gig disk, we create a group and that
group is called Whatever.
The group that you wanted to be called it is that group, Aso's is associated with one disk.
Once that group is created, that group is created out of LVM software, then you could have as many
petition out of it as you want.
And if you look at it on the right side, you have petitioned for system swap home.
Or you could have more like water or temp as many parties as you want.
Just like in windows you will have C, you have D and you have E or F all the way to the Z.
So this is how you petition a disk, right?
You have one disk and you partition that disk.
But in this case you create one volume group.
Now in the next section you will see at the bottom exactly why we do need to create volume groups.
You have three disks now.
Each disc is 100 gig hundred hundreds and hundreds.
So that makes it three hundred gig.
And instead of you take one, get one disk and assign it to one partition or one point, you take all
three disk combined together and make it a volume Kupe and call it whatever that you wanted to call.
Let's say in this example is data VTG, which is volume.
You combine them together.
This group, the size of this group becomes 300 gig because all three disks that you have on the left
hand side, each has a size of hundreds.
So that becomes 300 gig.
Then you create.
So then you create on the right hand side, you create data one, two, three and four and different
partitions.
Now, the advantage of LVM, the main advantage of Elby LVM is what if you run our 300 gig that you
have created the blue?
And you could add a fourth disk and without breaking your partitions or your file system, you could
add that disk to your group, your volume group, which is at this point is data Viji.
You can add that extend that group and the group size becomes 400 gig and then you associate that size
to data one if data one disk space is run out of space.
So this is a logical volume is for it is very useful in a corporate environment because you have to
extend the disk space or partitions of your mom points all the time, because if you have given a server
to a developer and the size of your root is 100K and the and the developer runs application programs
and it fills up the root partition really fast and it becomes 99 gig.
So you're 99 percent full, right.
So what options do you have left?
Well, the only options you have left, if you have physical servers, pop to try out and take add another
disk.
But what if there is no capacity to add another disk out of luck?
Right.
So in virtual environment pacifically, you could add another disk or extend a disk and virtual machine.
Once it's extended, you could extend your group, which is right here, and then you could petition
that or extend your data one or route from 100 gig to 200.
Adding disk and creating a logical volume, your petition, you look at this picture now at the bottom
of the picture, you will see.
We have hard disk, hard disk one as the hardest to hardest three, so every hard disk, we create a
partition on top of it.
Now, if you are doing LVM on top of it, then you would have to create physical volume.
Physical volume has to be created for each partition.
Then we create a volume group.
This group will represent that entire physical volumes that will that will be coming out of those disks.
And then we will create logical volumes once we have the logical volume, which will be exactly the
same as a standard volume.
But of course, this will be under LVM and then we to mount those logical volumes to our file system.
So this is how it works.
Let's get into our next machine and we'll try how it works.
Now again, before we get into Linux machine, we have to go to Oracle Virtual Box and we will add a
new disk to our commercial box.
OK, so this is our go to box, it is powered off, so make sure it is powered off, OK, go to the
setting.
Click on storage icon controller Sayda.
And then come down here and click on Add new desk at your desk, the concrete in your desk, leave the
VDI default, dynamically allocated default, pick a name, any name that you like.
Let's say we're going to pick desk or Oracle.
So if you if you're database guy's coming to you and telling you, can I have an additional space and
you can label it according to the application.
But again, it doesn't really matter.
And the size of the disk I'm going to pick is one gig.
Then you click create.
So now it created and you simply click, OK, now once you're going to boot up the system, it will
have the new desk.
So let's start our system.
OK, so once you log in, you open up a terminal.
Now go ahead and become route.
OK, and Ron D.F., sorry about this mysel.
Do it with more.
The first disc you're going to see is the 10 gig is the one you created doing the installation.
The second issue you have is for two gig that you created previously, and it's partition information.
And now the third disc you have, if you notice it has the third letter, SDC, which is right here,
or one gig.
So the first gigs always starts with a second Stevie and the third one SDC.
So we already have the disk.
We confirm that.
So now let's start creating.
The petition, so now if you notice from the background, let's go back to our slide, the first one
is hardest.
We have confirmed we have the hard disk now let's create the petition.
So we are going to the petition.
If you see if you look at the picture, you will see on the green one right above the desk or the petition
will go ahead and create those petition.
So to create the petition is disk space, slash dev, slash SDC, because we are going to create desk
for the third petition for the third disk and you hit Enter Click on you and to create a new petition
P for primary petition.
One is the first set to partition, so first partition that you want to create.
So by default, it's one, so leave it as default and just hit enter prosectors sectors.
All of us started to 048 and it is giving us by default to 048 and leave a default hit enter.
Now the size of the partition you want to create, I wanted to give the entire side said automatically
giving me the last sector of the disk.
So I'll just hit enter and I'll pick the people's value.
So once that is done, go ahead and click.
So this will tell you that your partition has been created.
But again, this partition has not been written to the table yet until we do w, which is to write.
But at this time, since we are doing LVM, I want you to type T because we are going to change the
type of this partition.
Why?
What is T for.
If you type, just help.
You'll see right here.
T is change partition system ID.
So if you wanted to change to LVM, so I want you to type T and enter and here.
I want you to type L to see what are the tax code associated with LVM, so LVM is associated with eight
E that I know.
So eight E is somewhere here.
Right here.
So it says LVMH.
So just type eight.
So 80 and hit enter.
So now it's a changed type of petition next to LVM to hit again to confirm, right.
See it right here it is Linux, LVM now.
Now it is done.
Now go ahead and type W-2 right to it now.
And it is sinking the disk.
Good.
So now are a petition table is created.
Now the next step, the next step is to create a physical volumes right here where it says the blue
ones as D1.
So the third step is to create physical volume, to create a physical volume.
You have to run command p v.
Create physical volume, create and the name of the volume, which is Deve SDC and the name of the petition
number one, then you go ahead and enter and it says successfully created to verify it.
You always do Peevey display, which is to petition Walloon display.
And it will tell you that it created the volume, the information, the P size, the P for the new physical
volume, size 10 20 megabyte, which is one game.
Now we have created the the physical volume.
Now it's time to create the volume group.
So we are on the fourth step right here.
It says right here, if you notice volume growth.
So we going to create a volume called the call to create a volume called The Command is Viji Create.
And the name of the volume that you wanted to sign, so we're going to continue with our example, so
we're going to example of Oracle.
We're going to pick Oracle, underscore Elvie.
You could pick any name, but I'm just being consistent.
So LV stands for Wallack volume.
Sorry, I should pick Viji.
So volume growth.
So this word identify this is this group is for Oracle and now we are assigning this volume to Dev SDC
one.
Right.
So I want you to go ahead and create enter.
And it says Volume group Oracle Underscore Viji successfully created.
You could go ahead and verify it by running the command big
display and give the volume name, which is Oracle.
Underscore the cheap and it will give you the information about that group.
Now we are done with the volume group.
Now the fifth step is to create logical volumes right here, logical volume.
Which is also just like a partition, so now to create a logical volume, you have to run the command,
Elvie create.
Then, minus any new or cool, underscore the this is the name of the oracle, underscore Elwick the
size, the type size.
As one, because we have to size up 1G and where is it going to associate it to to Oracle Volume Group?
You go ahead and enter.
And it's his volume group or a colleague has insufficient free space to 55 cents to 56 required.
OK, I picked the exact same one.
So what I could do is instead of that, I could just pick one zero two three.
So if, you know, there is one zero two four megabyte makes one game.
So let's try that and hit em.
And it better still not enough, so I'll just pick down because it does need some of the space to hold
its LVM information.
OK, so it is the logical volume or Elvie is created.
We could verify it by running Elvie display.
And you will see right here it is created for that group.
OK, so now that is done.
Now we have to format the disk, assign the the file system to it to make a system that accepts.
To Dev.
Oracle, Liji and Oracle.
This is the group right here in the middle, and this is the logical volume that we just created.
So we are assigning Zephyrs filesystem to this partition.
So hit enter it had created.
Now, now it's time to mount this logical volume to our directory level that our director is.
So I'm going to go ahead and create a new directorate, MKR mkdir and call it Oracle to create it now.
But I didn't mount it.
So how are you going to mount it?
We have to mount it.
Slash Dev, slash Oracle VTG slash Oracle.
Elvie Mountain.
Where to Oracle.
It has mounted.
Go ahead and do D.F. my age and you will see the D.F. minus H.
Yes, right here, all the way to the bottom, it has a sign, this volume to this directory.
You could also unmounted the human comment.
Anyway, this is how you create LVM new disc Partition, some of the commands are there.
You just have to remember those commands, how to run them.
What is the order that you have to run them again?
The order always goes by the layout that we have.
So first we have hard disk, then partition, then physical volume and volume group, logical volume
and then mounted to the filesystem.
This lesson is about adding and extending disk using logical volume management.
Now why do we need to extend a disk?
So if we have a disk already in our system, in a Linux system, and let's say if that disk becomes
full, it's 100 percent.
So you have this disk that is mounted on Oracle and the disk space of that Oracle is one gigabyte.
And now after, let's say, six months or a year, the database administrator comes back to you and
says, hey, I need more disk space for Oracle because we've been doing a lot of work.
The productivity has been increasing every day.
The data is increasing every day.
So, of course, eventually the databases gets bigger and bigger.
So Oracle gets bigger.
So what options do you have?
Well, we could look at a few options.
Number one would be like delete some of the old files to free up displays.
Right.
That's the basic thing is so if you have your room that is fully cluttered and you don't have a room
to walk around, what do you do?
You take out all the stuff and throw it away, right?
I hope so.
Right.
OK, so the other options that we have is add a new physical disk and mounted to slash Oracle to meaning
that if you have a physical system, then you could add a new disk in this physical system if and only
if you have to slot an extra slot to add an extra disk to that physical system.
If you have it perfect, you could partition it, you could configure it at your grade level and then
you can mount it on Google, too.
Or if you have a virtual environment, which is the perfect scenario.
And that's why I love virtual environ, because you don't really have to actually pull your server out,
open the top and add a new disk.
So if you have a virtual disk, all you have to do is go to your VM and add a new disk and it takes
literally a few seconds to do that.
So and then once you add that, you do the same thing, slash Oracle to now.
I wanted to extend my slash oracle.
I don't want to create another petition or another Mount Point like Oracle to then what do I do?
Well, you will be out of luck if you had not used LVM initially.
If you have, then, my friend, you are in luck, then you would extend your oracle through logical
volume manager.
So no matter how many disk you attach, external disk or internal, this doesn't really matter.
All you have to do is create a partition of that disk and then attach that disk within the same group
that you created for Oracle on point.
Now, how does it work?
Let's get into a Linux machine to find out.
Now, before we get into a Linux machine, let's add let's assume that we don't have a disk space and
we wanted to add a new disk to our virtual machine.
So let's go to our machine powered off, of course, mature, powered off.
Every time you have to add a new disk or add resources, go to setting goals, storage, and then you
will see you have three disk.
The first one you have is about your own Linux operating system disks that you created initially.
I think it's like 10 gig.
The second one you have is about that data disk and the third one we added Oracle Data Oracle, which
is one gig.
So let's click here and you will notice right here the virtual disk size is one gig, but of course
it is running out of space.
We could extend it.
Now, remember one thing, other virtual environment like enterprise level VMware or even Oracle or
read about the environment.
You will be able to extend this this space right here by by clicking and clicking on extend disk.
But I believe since.
This is a PC version, personal version of virtual environments, you cannot extend that.
So what do you have to do?
You click on your controller, add a new disk, add hard disk, create new disk, VDI next, dynamically
allocated next.
And the name you could just name the same way as the other one data oracle and put one here, because
of course, you cannot name the exact same because it will be a conflict.
So now this is the second disk.
You know what it's better you put to sit this way.
It's easier to differentiate the first one and the second one.
So this is a two and I want to give it another extra one, get to get one gig and click create.
So it has created two disks.
So basically what we are doing here is we are combining Oracle data, so data oracle with our data,
Oracle two.
So that is done.
And now click OK, go ahead and hit power on or start.
OK, so we have logged into our Linux machine, go ahead and become root.
Now let's run the demised H Command and the disk or the petition that we are trying to extend.
Is this right here?
So if you look at it right now, this petition is mounted on Oracle and that this size is nine nine
seven, which is like a one gig, uses 33 meg and available it's nine 65.
Now, we are assuming that right now the usage is instead of four, it's 100 percent.
So once we are going to add additional disk space to it instead of nine, nine seven megabyte will become
too great.
So let's go to our command desk slash bill.
Let's pipe it to more and let's see what are the disk we have available then.
Steet, which is the root disk where we did installation.
Stoebe is where we did we created our data disk.
Then we have SDC, which is the Oracle disk that we used.
So now we should also have the new one, which we just created with the label SD D.
So let's see.
Hit Enter.
See, you're here, you just have to be very careful, because sometimes it throws so much information
on the screen, you can't really see where your desk is anyway.
So that's the desk s d d.
This is our new desk with one gig.
So now we going to do we're going to partition that desk the same way we partition any other desk whenever
we create a new one.
So to partition that desk, you run at desk slash dev just as D d and this is going to be your new desk
and end for new P for primary desk hit.
Enter for default or just hit one.
Would you like it.
Twenty 48 or just hit enter to default hit enter again for default value people protection.
You'll see right here it's as empty.
As soon as I assign eighty to it it will see Linux LVM so hit t again and again.
And you see this is a list of all the available file types that we assign to it.
So we just pick eight E again for links.
LVM hit Enter again and now you'll see Linux, LVM.
Now this is the system that's using its type of file.
It's going to be assigning it to now you hit W to create that partition so that partition is created.
The partition is SDD one.
You could do a disk again hit out and do pipefitter more and you will see as did one.
So right here, SDD one, it is created perfect.
All right.
So now you could just reboot the system real quick.
So it is updated to in the system again.
OK, once you have your system back online, you can log back in and become route
to a disk cell again and this time just typed SDD one.
Just make sure it's there if it's there.
Now it's time to extend the file system.
Slash slash mapper slash Oracle vtg dash oracle underscore Elwick.
We are extending this one so the file system gets bigger.
So first we do Peevey display this will show us which group is associated with which disk.
So our concern is right here.
This one is DC one and it is associated with group Oracle Slash Reiji.
You can also run PB's.
It will also give you the same pretty much the same information.
This disk is associated with this group.
So we want to add a new disk within this group.
And once we add that new disk that we created Dedi, then we will extend the group and we'll extend
the logical Wallingham as well.
So let's do the big display and let's do on our Oracle underscore Viji.
This is our group.
So you will see it also tells you the volume group size is 10 20 megabyte, which again of course is
one gig.
So now let's create physical volume.
So Peevey create slash dev slash D one because we always have to create physical volume so it is successfully
created.
Now we do v g extend.
We are extending the group, which is a group named Oracle
V G and we are associating that to s slash s so dev SDD one.
OK, so now it is extended with that disk partition because if you just say Viji extend Oracle underscore
vtg it will say hey I will extend it, that's fine.
But which disk I should leverage on our step on or include that disk within me to extend.
So you have to define that the disk is slash derivs that SDD one.
OK, so now that is done.
Now let's do a logical volume extend.
So a logical wiliam extend is right here.
So you have to specify the size which is the commander's mysel and plus the size.
So one zero two four which is one gigged.
So just put Megg here and then you specify Dev Mapper
which is right here.
What I would do is I I'll just move that, go up to RF Disk Command and I'll just copy this entire thing
so I won't make a mistake because this is the logical volume that eventually we want to extend and now
we come down and paste it right here.
OK, so now we have extended and it says Logical Wiliam Oracle underscore Viji Oracle underscore Elvie
successfully resized.
Awesome.
Let's extend the file system and the command to extend the file system as xpress underscore
grrl file system and then you hit Paiste hit enter and that should grow your file system.
Dearman's H.
And now you will see slash dev slash mapa underscore Viji to Gayathri.
Oracle is now to gig.
Remember we had at one gig, now it's two gig.
That's how you extend a file system.
Once you extend it, you go back to your Oracle guy, tell him you have added a new stories to your
existing mom point you did not have to create, slash or go to.