user234568
user234568

Reputation: 815

How do I extend the space of /dev/mapper/rhel-root?

DF -TH

enter image description here

[root@ap-dcr-ctc01 log]# sudo vgs
    VG   #PV #LV #SN Attr   VSize   VFree
    rhel   2   3   0 wz--n- 298.99g    0

As you can see the space directory of rhel-root is full so I would like to increase the space of its directory. How can I do it. By the way, this is rhel 7.3.This is the display for vgs and vgsdisplay. Also is it possible to transfer empty space in another directory to the root?(For home directory has 252G of available space so is it possible to transfer some to the root directory?)

Upvotes: 1

Views: 23759

Answers (1)

erTugRul
erTugRul

Reputation: 340

First of all note this, XFS filesystem cannot be shrunk. Now the way to do this is as following:

  1. Delete some unnecessary files from root so that you can store the backup of /home in this directory.

  2. Backup the contents of /home as:

    tar -czvf /root/home.tgz -C /home .
    
  3. Test the backup

    tar -tvf /root/home.tgz
    
  4. Need to unmount /home

    umount /dev/mapper/rhel-home
    
  5. Remove home logical volume

    lvremove /dev/mapper/rhel-home
    
  6. Now need to recreate new /home LV (lets say of 100GB), format and mount it

    lvcreate -L 100GB -n home rhel 
    mkfs.xfs /dev/rhel/home
    mount /dev/mapper/rhel-home
    
  7. Now extend your /root volume with all the remaining space

    lvextend -r -l +100%FREE /dev/mapper/home-root
    
  8. Restore your backup

    tar -xzvf /root/home.tgz -C /home
    
  9. Check /etc/fstab entry of /home. Update the UUID of /home directory

    blkid /dev/mapper/rhel-home
    vi /etc/fstab (and update UUID of /home)
    

Done !!! Hope it helps!!! :)

Upvotes: 2

Related Questions