(keyboard clicks)
Instructor: Adding disk
and creating a Logical Volume Manager partition.
You look at this picture now,
at the bottom of the picture you will see
we have hard disk,
hard disk one. sda, hard disk two, hard disk 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 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 for under LVM.
And then we are gonna mount those logical volumes
to our file system.
So this is how it works.
Let's get into our Linux machine and we'll try how it works.
Now again, before we get into Linux machine
we have to go to Oracle VirtualBox
and we will add a new disk to our Oracle VirtualBox.
Okay, so this is our Oracle VirtualBox.
It is powered off, so make sure it is powered off.
Okay, go to the Setting, click on Storage,
click on Controller: SATA,
and then come down here and click on add new disk,
Add Hard Disk, click on Create new disk,
leave the VDI default, dynamically allocated default.
Pick a name, any name that you like.
Let's say we're gonna pick diskoracle.
So if your database guy is coming to you
and telling you cannot 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 gonna pick is one gig.
Then you click Create.
So now it is created and you simply click, OK.
Now once you're gonna boot up the system
it will have the new disk.
So let's start our system.
Okay, so once you log in, you open up a terminal.
Now go ahead and become root.
(keyboard clicks)
Okay, and run df, sorry, fdisk -l.
Do it with more.
(keyboard clicks)
All right, the first disk you're gonna see is the 10 gig,
is the one you created during the installation.
The second disk you have is for two gig
that you created previously
and it's partition information.
And now the third disk you have, if you notice,
it has the third letter, sdc,
which is right here for one gig.
So the first disk always starts with sda,
a second, sdb, and the third one, sdc.
So we already have the disk, we confirmed that.
So now let's start creating the partition.
So now if you notice from the background,
let's go back to our slide.
The first one is hard disk,
we have confirmed we have the hard disk.
Now let's create the partition.
So we are going to the partition.
If you see, if you look at the picture,
you'll see on the green ones, right above the disk
are the partition.
We'll go ahead and create those partition.
So to create the partition is fdisk, space, /dev/sdc
because we are going to create disk for the third,
partition for the third disk.
Then you hit Enter,
click on new, n, to create a new partition.
p for primary partition.
One is the first sector partition, sorry,
first partition that you want to create.
So by default it's one,
so leave it as default and just hit Enter.
First sectors always starts with 2048
and it is giving us by default, 2048.
And leave it default. Hit Enter.
Now the size of the partition you want to create,
I want to give the entire size,
so it automatically giving me the last sector of the disk.
So I'll just hit Enter and I'll pick the default value.
So once that is done, go ahead and click p.
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.
What is t for?
So if you type just help you'll see right here,
t is change partition system id.
So we wanted to change it to LVM.
So I want you to type t and hit Enter.
And here I want you to type L to see what are
the hex code associated with LVM.
So LVM is associated with 8e, that I know.
So 8e is somewhere here, right here.
See, it says LVM, 8e.
So just type 8, sorry, 8e and hit Enter.
So now it says changed type of partition Linux to LVM.
So hit p again to confirm, right, see right here,
it says Linux LVM now.
Now it is done.
Now go ahead and type w to write to it.
Now it is syncing the disk. Good.
So now our partition table is created.
Now the next step.
The next step is to create a physical volume.
So right here where it says, the blue ones, /dev/sda1.
So the third step is to create physical volume.
To create a physical volume,
you have to run command pvcreate, physical volume create,
and the name of the volume which is /dev/sdc
and the partition number, 1.
Then you go ahead and Enter
and it says, "successfully created."
To verify it, you could always do pvdisplay
which is to partition volume display.
And it will tell you
that it created the volume with information,
the PE size, the new physical volume size, 1023 megabyte,
which is one gig.
Now we have created 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 Group.
So we are gonna create a volume group.
To create a volume group, the command is vgcreate
and the name of the volume group that you wanted to assign.
So we are gonna continue with our example,
example of Oracle.
So we're gonna pick oracle_lv,
you could pick any name, but I'm just being consistent.
So lv stands for volume, sorry, I should pick vg,
so volume group.
So this will identify this group is for Oracle.
And now we are assigning this volume to /dev/sdc1, right?
So I want you to go ahead and create a hit Enter.
And it says, "Volume group 'oracle_vg'
successfully created."
You could go ahead and verify it
by running the command vgdisplay
and give the volume name, which is oracle_vg.
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,
so right here, Logical Volume,
which is also just like a partition.
So now to create a logical volume
you have to run the command lvcreate
then -n, new, oracle_lv.
This is the name of the oracle_lv,
the size, then you type size as 1G,
because we have the size 1G
and where is it gonna associate it to?
To oracle volume group.
You go ahead and Enter and it says,
"Volume group 'oracle_vg' has insufficient free space,
255 extents: 256 required."
Okay, I picked exact same one.
So what I could do is instead of that
I could just pick 1023.
So if you know there's 1024 megabyte makes one gig.
So let's try that and hit M, and hit Enter.
Still not enough, so I'll just pick 1000
because it does need some of the space to hold
its LVM information.
Okay, so it is a logical volume, "'oracle_lv' is created."
We could verify it by running lvdisplay.
And you will see right here it is created for that group.
Okay, so now that is done,
now we have to format the disk,
assign the file system to it.
So make file system .xfs
to /dev/oracle, vg underscore, oracle, lv.
This is the group right here in the middle
and this is the logical volume that we just created.
So we are assigning XFS file system to this partition.
So hit Enter.
So it had created now.
Now it's time to mount this logical volume to our directory
wherever that our directory is.
So I'm gonna go ahead and create a new directory,
mkdir, and call it oracle.
(keyboard clicks)
Directory created. Now go ahead and mount it.
So how you gonna mount it?
We have to mount it /dev/oracle_vg/oracle_lv,
mounted where?
To /oracle.
(keyboard clicks)
It has mounted.
Go ahead and do df -h, and you'll see with df -h,
yes, right here, all the way to the bottom,
it has assigned this volume to this directory.
You could also unmount it with umount command.
Anyway, this is how you create LVM new disk 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, then volume group, logical volume,
and then mounted to the file system.