Pawan Sharma | May 15, 2012 | Be the first to comment!

Extending Logical Volume

In this post we will see how to how to increase or decrease size of a Logical Volume online. Online means that you can change (extend or reduce) the size of a mount point while it is mounted and is used by any program without any data loss. Yes RHEL have this facility to extend or reduce a mount point online. This is very useful when you can’t unmount the mount point and have to increase the size of it.

It is one of the RHCSA objective which is also used very frequently in production environment. This objective is mostly used where there are database on the server. As data increase in mount point it is required to extend the mount point. In this post we will see how to increase a size of a mount point and in next post we will see how to reduce size of a mount point.

1. To extend a Logical Volume we need free space in its respective VG. In the below image we can see that Volume Group DATAVG have 1.88 GB free space. Use command vgdisplay to show free space in Volume Group.
Extending Logical Volume in RHEL
In the above image we can see that is something like 510/1.99 GB. Here 510 is Physical Extents(PE), above image shows that each PE size is 4 Mb.
To extend a Logical Volume it is not needed to unmount it, also it can be used at the time of extending.
2. In this example we will extend Logical Volume lvindx by 500Mb, which is mounted on /indx.  To extend lvindx by 500Mb use below command:
lvextend –L +500M /dev/DATAVG/lvindx
Note: if you don's add "+" sign in front of size the Logical Volume would be re-sized to 500M.
Extending Mount Point in RHEL.
In the above image output of lvscan command shows the increased size but df –Ph does not shows the extended size, /indx is still 1008M as before. This is because the LV has been extended but to take effect we have to run a command to add the extended spate to a mounted Logical Volume.
3.Now to extend the mount point online user resize2fs command:
resize2fs /dev/DATAVG/lvindx
Extending mount point with LV in RHEL
Above command will reflect changes and make the mount point extended online without affecting the existing data on the mount point.
That’s how you can increase size of a mount point. In the next post we will see how to reduce a Logical Volume.


No comments:

Post a Comment