Steps to reduce /home file system:
1. Take backup of Filesystem before going to start LV reduce activity
For example if you want to reduce /home file system
# mkdir /var/tmp-bkp-home <-- to make temporary folder for backup as per disk space availability
# cd /var/tmp-bkp-home
# tar -cf home-bkp-7th-July-2015.tar /home
# ls -lh home-bkp-7th-July-2015.tar
2. Take pre-check before starting the activity
# df -h /home
# vgdisplay VolGroup00
# lvdisplay /dev/VolGroup00/LogVol03 <-- is for /home file system
3. Unmount the /home file system
# umount /home
umount: /home: device is busy
umount: /home: device is busy
If get device busy error check user/process that is still using file system
# lsof /home
# fuser -cu /home
/home: 24551c(sharmaxx) 26948c(root)
# fuser -ck /home
/home: 24551c 26948c
Hangup
Kill process to release the /home file system
# kill -9 24551
# kill -9 26948
Check "open" option in lvdisplay command
# lvdisplay /dev/VolGroup00/LogVol03
# open 0 <-- it should be zero means this LV is free to unmount
if still facing issue REBOOT is one more option if file is locked by any process or try,
# umount -f /usr/local/nete
# umount -l /usr/local/nete
# umount -lf /usr/local/nete
Make confirmation by running
# df -h /home
4. Run e2fsck to check file system
# e2fsck -f /dev/mapper/VolGroup00-LogVol03
5. Suppose size of /home is 14 GB and you want to reduce it by 4GB, then the new size will be 10GB
for than run below command:
# resize2fs /dev/mapper/VolGroup00-LogVol03 10g
6. Run LV reduce command
lvreduce -L 10GB /dev/mapper/VolGroup00-LogVol03
7. Again Run e2fsck to check file system
e2fsck -f /dev/mapper/VolGroup00-LogVol03
8. Check size of lv and vg
# vgdisplay VolGroup00
# lvdisplay /dev/VolGroup00/LogVol03 <-- is for /home file system
9. Mount file system
# mount /home
10. Finaly check file system
# df -hT /home
Steps to extend /root File System
1. Take pre-check before scanning the disk:
# vgdisplay VolGroup00
# lvdisplay /dev/VolGroup00/LogVol00
# lsscsi
# lsblk
# blkid
2. Scan new disk:
# echo "- - -" > /sys/class/scsi_host/host0/scan
# echo "- - -" > /sys/class/scsi_host/host1/scan
Alternativily you can also scan / rescan by
# ls /sys/class/scsi_host/ | while read host ; do echo "- - -" > /sys/class/scsi_host/$host/scan ; done
2. Check newly added disk:
# lsscsi
# lsblk
# blkid
# ls -lhtr /dev/disk/by-path/
3. Suppose you got new disk like /dev/sdn then, create PV:
# pvcreate /dev/sdn
4. Extend VG:
# vgextend VolGroup00 /dev/sdn
5. Extend LV:
# lvextend -L +50G /dev/VolGroup00/LogVol00
6. Run resize2fs command to resize LV online:
# resize2fs /dev/VolGroup00/LogVol00
Note : resize2fs also work for ext4 file system
For older version of Linux OS you can resize file system by
# ext2online /dev/VolGroup00/LogVol00
7. Check VG, LV and file system size:
# vgdisplay VolGroup00
# lvdisplay /dev/VolGroup00/LogVol00
# df -hT /root
1. Take backup of Filesystem before going to start LV reduce activity
For example if you want to reduce /home file system
# mkdir /var/tmp-bkp-home <-- to make temporary folder for backup as per disk space availability
# cd /var/tmp-bkp-home
# tar -cf home-bkp-7th-July-2015.tar /home
# ls -lh home-bkp-7th-July-2015.tar
2. Take pre-check before starting the activity
# df -h /home
# vgdisplay VolGroup00
# lvdisplay /dev/VolGroup00/LogVol03 <-- is for /home file system
3. Unmount the /home file system
# umount /home
umount: /home: device is busy
umount: /home: device is busy
If get device busy error check user/process that is still using file system
# lsof /home
# fuser -cu /home
/home: 24551c(sharmaxx) 26948c(root)
# fuser -ck /home
/home: 24551c 26948c
Hangup
Kill process to release the /home file system
# kill -9 24551
# kill -9 26948
Check "open" option in lvdisplay command
# lvdisplay /dev/VolGroup00/LogVol03
# open 0 <-- it should be zero means this LV is free to unmount
if still facing issue REBOOT is one more option if file is locked by any process or try,
# umount -f /usr/local/nete
# umount -l /usr/local/nete
# umount -lf /usr/local/nete
Make confirmation by running
# df -h /home
4. Run e2fsck to check file system
# e2fsck -f /dev/mapper/VolGroup00-LogVol03
5. Suppose size of /home is 14 GB and you want to reduce it by 4GB, then the new size will be 10GB
for than run below command:
# resize2fs /dev/mapper/VolGroup00-LogVol03 10g
6. Run LV reduce command
lvreduce -L 10GB /dev/mapper/VolGroup00-LogVol03
7. Again Run e2fsck to check file system
e2fsck -f /dev/mapper/VolGroup00-LogVol03
8. Check size of lv and vg
# vgdisplay VolGroup00
# lvdisplay /dev/VolGroup00/LogVol03 <-- is for /home file system
9. Mount file system
# mount /home
10. Finaly check file system
# df -hT /home
Steps to extend /root File System
1. Take pre-check before scanning the disk:
# vgdisplay VolGroup00
# lvdisplay /dev/VolGroup00/LogVol00
# lsscsi
# lsblk
# blkid
2. Scan new disk:
# echo "- - -" > /sys/class/scsi_host/host0/scan
# echo "- - -" > /sys/class/scsi_host/host1/scan
Alternativily you can also scan / rescan by
# ls /sys/class/scsi_host/ | while read host ; do echo "- - -" > /sys/class/scsi_host/$host/scan ; done
2. Check newly added disk:
# lsscsi
# lsblk
# blkid
# ls -lhtr /dev/disk/by-path/
3. Suppose you got new disk like /dev/sdn then, create PV:
# pvcreate /dev/sdn
4. Extend VG:
# vgextend VolGroup00 /dev/sdn
5. Extend LV:
# lvextend -L +50G /dev/VolGroup00/LogVol00
6. Run resize2fs command to resize LV online:
# resize2fs /dev/VolGroup00/LogVol00
Note : resize2fs also work for ext4 file system
For older version of Linux OS you can resize file system by
# ext2online /dev/VolGroup00/LogVol00
7. Check VG, LV and file system size:
# vgdisplay VolGroup00
# lvdisplay /dev/VolGroup00/LogVol00
# df -hT /root
No comments:
Post a Comment