Thursday, December 26, 2019

Add space to root partition (using /home space)

On /home partition of one server I've got more HDD than I need. Below are steps to shrink /home partition (I preferred to delete it and then recreate, preserving all content):

If you're not under the root, then first do the below:
  1. make (-m) dir and make it home for tmp_usr:
    1. useradd -m -d /tmp/temp_usr temp_usr
  2. usermod -aG wheel temp_usr
  3. id temp_usr
  4. passwd temp_usr # Z481632z.@
  5. ssh temp_usr@needed_server_ip 
  6. sudo su -
  1. df -h
  2. ll /home/
  3. mkdir /tmp/temp
  4. cp -a /home /tmp/temp/ # -a key makes archive
  5. ll /tmp/temp/home/
  6. umount -fl /home # lazy unmount and undetected NFS unmount
  7. lvs # find VolGroupName and /home VG name
  8. lvremove /dev/VolGroupName/lv_home
  9. pvs # how much free space we have
  10. lvextend -L+350G /dev/VolGroupName/lv_root
  11. resize2fs /dev/VolGroup/lv_root # or xfs_growfs /dev/VolGroupName/lv_root
  12. pvs # how much free space we have
  13. lvcreate -L 50G -n lv_home VolGroupName
  14. pvs
  15. lvs
  16. mkfs.ext4 /dev/mapper/VolGroupName-lv_home# or mkfs.xfs /dev/mapper/VolGroupName-lv_home
  17. df -h
  18. mount -a # mount all existent FS 
  19. df -h
  20. cp -a /tmp/temp/home/* /home
  21. ll /home
  22. rm -rf /tmp/temp

No comments:

Post a Comment