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 our Linux system, and let's say if
that disk becomes full, it's 100%, 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
can look at a few options. Number one
would be like delete some of the older
files to free up disk space, right?
That's what 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 the oldest stuff and throw it away,
right? I hope so alright. Okay, so the other
options that we have is, add a new
physical disk and mount it to slash
oracle2, 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 the 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 RAID level. And then you can
mount it on slash or /oracle2, or
if you have a virtual environment, which
is the perfect scenario. And that's why
I love virtual environment, 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 /oracle2.
Now I want to extend my /oracle,
I don't want to create another
partition or other another mount point
like oracle2, 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 the disk, and then attach that disk
within the same group that you created
for /oracle mount point. Now how
does it work? Let's get into our Linux
machine and we'll 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 want to add a new disk to
our virtual machine. So let's go to our
[No audio]
our machine powered off, of course, make
sure it's powered off every time you
have to add a new disk or add resources.
Go to Setting, go to Storage, and then
you will see you have three disks. 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
the data disk, and the third one we added
oracle, dataoracle 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 Redhat virtual environment, you will
be able to extend this disk space right
here by right 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, dataoracle, and
put one here because of course sorry,
you cannot name the exact same because
it will conflict. So now this is the
second disk. You know what, it's better
you put 2, so 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 gig. Select
one gig, and click Create. So it has
created two disks. So basically what we
are doing here is, we are combining
Oracle data, sorry dataoracle with our
dataoracle2. So that is done, now click
OK, go ahead and hit power on or Start.
[No audio]
Okay, so we have logged into our Linux machine. Go
ahead and become root. Now, let's run
the df -h command, and the disk
space or the partition that we are
trying to extend is this right here. So
if you look at it right now, this
partition is mounted on /oracle.
And the disk size is 997, which is like a
1 gig, used is 33 meg, and available is
965. Now, we are assuming, that right now
the usage is instead of 4, it's 100%.
So once we are going to add additional
disk space to it, instead of 997
megabyte it would become two gig. So let's go
to our command fdisk -l, let's
pipe it to more, and let's see what are
the disk we have available, /dev/sda,
which is the root disk, where we did
installation, sdb 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 sdd.
So let's see, hit Enter.
[No audio]
See, you're here,
you're just have to be very careful,
because sometimes it throws so much
information on the screen, you can't
really see where your disk is, anyway, so
that's the disk, sdd, this is our new
disk with one gigs. And now we're going
to do, we're going to partition that
disk, the same way we partition any other
disk whenever we create a new one. So to
partition the disk, you run fdisk /dev/sdd.
And this is going to
be your new disk, hit n for new, p for
primary disk, hit Enter for default, or
just hit one, whatever you like, hit 2048,
or just hit enter to default. Hit enter
again for default value, p for permission,
you will see right here it says Empty.
As soon as I assign 8e to it, it will
see Linux LVM so hit t again, and l again,
and you'll see this is a list of all the
available file types that are assigned
to it. So we just pick 8e again
for Linux 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 sdd1,
you could do fdisk again, hit l
and do pipe it to more, and you will see
sdd1. So right here sdd1 it is
created, perfect. Alright so now you
could just reboot the system real quick.
So it is updated to in the system again.
[No audio]
Okay, once you have your system back
online, you will log back in and become root.
[No audio]
Do fdisk -l again, and this
time just type /dev/sdd1, just to make
sure it's there. It's there. Now it's
time to extend the file system slash dev
/dev/mapper/oracle_vg-oracle_lv.
We are extending this one.
So the file system gets bigger. So first
we do pvdisplay, this will show us
which group is associated with
which disk. So our concern is right here,
this one sdc1, and it is associated
with group oracle_vg. You could
also run pvs, 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, sdd, then we will
extend the group and we will extend the
logical volume as well. So, let's do vgdisplay,
and let's do on our oracle_vg,
this is our group. So you
will see it also tells you the volume
group size is worth 1020 megabytes,
which again, of course is one gig. So
now let's create physical volume. So
pvcreate /dev/sdd1 because
we always have to create physical
volume. So, it is successfully created.
Now we do in vgextend, we are extending
the group with, what is a group name,
oracle
[Author typing]
_vg, and we are associating that
to /dev/sdd1.
[No audio]
Okay, so now it is extended with that
disk partition because if you just say
vgextend oracle_vg, it
will say hey, I will extend it, that's
fine. But which disk I should leverage
on or step on or include that disk
within me to extend, so you have to
define that the disk is /dev/sdd1.
Okay, so now that is done.
Now let's do logical volume extended. So
logical volume extent is right here. So
you have to specify the size, which is,
the command is -l, and plus the
size so 1024, which is one gig, so just
put meg here, and then you specify /dev/mapper,
[Author typing]
which is right here.
[No audio]
What I would do is, I will just move that,
go up to our fdisk command, and I will
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. Okay, so now we
have extended and it says logical volume
oracle_vg/oracle_lv
successfully resized, awesome. Let's
extend the file system and the command
to extend the file system is xfs_growfs.
And then you hit Paste, hit enter, and that should
grow your filesystem. df -h, and now
you will say /dev/mapper/
oracle_vg, 2 gig, 33. oracle is now
two gig. Remember we had it one gig, now
is 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 storage to your existing
mount point, you did not have to create /oracle2.
[No audio]