Sunday, June 15, 2014

Reducing Root LV EXT3 + Linux

Dear Friends,

Had worked on reducing the root file system some days back. So sharing the experience of the same.

A. Our Aim is to reduce the root file system, which is in EXT3. We also have other file systems, need to be reduced to free the space, but they are not allowing us to reduce the same online. All File systems are in EXT3.
B. Name of the file systems are /home, /var, /opt, and root i.e. / .
C. All of the above are not allowing us to unmount them.


 /dev/mapper/VolGroup-LogVol00
 /dev/mapper/VolGroup-LogVol02
 /dev/mapper/VolGroup-LogVol04
 /dev/mapper/VolGroup-LogVol06


Request you to please note down the name of the file system on paper as we may not be able to recall the complete path in RESCUE MODE.

E. Once checked, We can again check status using umount /opt, etc. It will say the message.

FILE SYSTEM/MOUNT POINTS are busy cannot umount.

or

umount: /: device is busy
umount: /var: device is busy
umount: /home: device is busy

F. Now to reduce them, take proper Downtime of the server, Take complete backup of the server. if in case things goes wrong. Then we will be having plan B.

G. Once all done,  We are given approvals Get Set go to reduce the mount points in RESCUE MODE.

H. TO go into RESCUE MODE, We should have a Boot Able DVD, or Boot Able USB.

I. Insert the DVD, Reboot the system, once installation screen appears, press F5.

J. Write LINUX RESCUE on the prompt.
the system will start booting to rescue mode, I have experienced some times the server/system doesn't go in rescue mode in one go. so friends don't panic. Boot up the system again using CTRL+ALT+DEL.
and follow step I and J again.

K. Once server start booting, it will show blue screen Asking for Language selection, {at the same time it will show the heading as LINUX RESCUE also, Friends as it is DVD part which is booting up, not the Hard disk}.
 It will show next screen for switching on NFS {skip this step/NO},
Now it will ask for whether File system to be mounted. Select NO.
 Server/System will bring to the prompt  #, at the same time.

L. Now we can run commands like, df -hT, e2fsck -y, lvm, etc. those we need.

M. Now run commands,

#LVM
#lvm vgchange -a y VolGroup00 ----  It will show VG is active state now.

Now run

#e2fsck -y /dev/mapper/VolGrooupLogVol00

It will do five checks. Once all done successfully.

#resize2fs "name of the file system" "Size need to be set"

Now run lvreduce

#lvm lvreduce -L "size need to be set" "name of the file system"

example :- #lvm lvreduce -L 10G /dev/mapper/VolGroupLvol00

Similar process to reduce other file systems. Do these steps carefully as extension of LV doesn't harm but reduction of the same can corrupt the file system and can also cause Data lose.

* I have tried to reduce the /opt and /home in single user mode or init 1. they were successfully reduced from there. You can also do the same from rescue mode.

once all done, reboot.

The system will be up and running with the desired reduced size.

Precaution :-

a. Take backup of the server/system. Complete backup/Snap shot will be best option in case of VM.
b. Note down the name of the File systems need to be reduced so that no confusion occurs at the time of activity.
c. Never run the command lvreduce without unmouting and running e2fsck, resize2fs before. If you have done this then we have to bring the same size back to earlier size, we can check the same from file ----------- /etc/lvm/backup/VolGroup00. extend the file system using "lvextend -L ....."  and then run resize2fs /dev/mapper/VolGroup-LogVol##. Then again reduce the same using proper steps.
d. Try to reduce to a specific figure till where you feel safe "For those who are starting working new on LVM.
e. Also request you to keep in mind the Logical extents of the logical Volume.
f. There is a way we can check using command "tune2fs -l "name of the filesystem" " whether the file system can be reduced online or in multiple user mode i.e. init 3.
else We can also check with un-mounting the File system after following proper way and process. 

tune2fs -l /dev/mapper/VolGroup-LogVol00

tune2fs -l  /dev/mapper/VolGroup-LogVol02

tune2fs -l /dev/mapper/VolGroup-LogVol04

tune2fs -l /dev/mapper/VolGroup-LogVol06



Please do correct me and if need to edit some steps.... All comments are welcome as learning is our goal. 




Thanks & Love Sharing
Amit Chopra






No comments: