Wednesday, 13 May 2015

How to reduce an LVM partition

LVM gives flexibility to systems administrators work when it comes to disk space management. A situation where we are running out of disk space in a linux box and if partition created is on LVM, then we can make some free space in the volume group by reducing the LVM using "lvreduce" utility.

------
Caution:  Backup all your critical data. 
------

PLAN OF ACTION:
-----------

Before, starting up with the process I will explain about our plan of action. In my server, the current partitions are as below:

The lvm partition "opt_oracle" is 10 GB, I want to reduce it to 8 GB.



PROCEDURE: 
------------

STEP 1: Umount /opt/oracle
--------
[root@MANINMANOJ]#umount /opt/oracle
---------

STEP 2: PERFORM AN FSCK ON THE LVM PARTITION.
---------
e2fsck -yf /dev/mapper/VG_DAS_1-opt_oracle
---------



STEP 3: Shrink the size of filesystem using resize2fs
--------
resize2fs /dev/mapper/VG_DAS_1-opt_oracle 8G
--------

Now, 8 GB is the desired size of  /opt/oracle.




STEP 4:  REDUCE THE LVM SIZE USING lvreduce 
--------
lvreduce -L 8G /dev/mapper/VG_DAS_1-opt_oracle
---------


STEP 5: PERFORM AN FSCK
-------
e2fsck -yf /dev/mapper/VG_DAS_1-opt_oracle
------

STEP 6: MOUNT THE FILE SYSTEM.
------
mount /opt/oracle
------

Now, you can see the size of "/opt/oracle" has been reduced to 8 GB as below:


Now, you can use vgreduce to get the free this free space to physical volume.

The command syntax is as below:
------
vgreduce <Volume group name>  <physical volume name>
------

With this done in this post, I will explain about the procedure to extend an LVM partition in my next post.









No comments:

Post a comment

Note: only a member of this blog may post a comment.