How can I move /usr directory to another disk (partition)?

Viewed 23

I am trying to move/remap the [/usr] directory to another disk as the following:

From: [/dev/sda1/root [/]] to: [dev/sdb1/usr [/dev/mapper/redhat-usr]

So, I have tried the following steps:

  1. Calculated the current [/usr] directory disk space usage:

    du -sh /usr

  2. Checked for available space:

    vgdisplay

    fdisk -l

  3. Added a new disk or partition to the system, then initialise for use by LVM:

    pvcreate /dev/sdb1

  4. Created a volume group "redhat":

    vgcreate redhat /dev/sdb1

  5. Created a logical volume in vg "redhat":

    lvcreate -L 8G --name usr redhat

  6. Created a new filesystem for LV usr:

    mkfs.xfs /dev/mapper/redhat-usr

  7. Mounted new LV [usr] to a temporary directory and copy contents of [/usr] into it:

    mkdir /tmp/usr

    mount /dev/mapper/redhat-usr /tmp/usr

    rsync -avz /usr/ /tmp/usr/

  8. Verified the contents of LV [usr] matches that of the [/usr] directory:

    diff /usr/ /tmp/usr/

  9. Configuried the system to permanently mount LV [usr]:

    blkid

    vi /etc/fstab

    UUID=[uuid of [usr]] /usr xfs defaults 0 0

  10. Restored SELinux Context:

    restorecon -vvFR /usr

  11. Added the new VG/LV names to /etc/default/grub:

    vi /etc/default/grub

    GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rd.lvm.lv=redhat/usr rhgb quiet"

  12. Regenerated the GRUB2 configuration (Legacy based machine):

grub2-mkconfig -o /boot/grub2/grub.cfg

  1. Rebuilt the initial RAM disk image file:

    cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.$(date +%m-%d-%H%M%S).bak

    dracut -v -f /boot/initramfs-$(uname -r).img $(uname -r)

Finally, after rebooting the node. It came up but, when I try to login via Xterm the following message appears:

/bin/bash: Permission denied

Thanks in advance

0 Answers
Related