2

I want to mount /usr directory on different partition and keep the same owner on all files and subdirectories in /usr directory.

I want to mention that this issue is for linux ec2 machine where I can't enter to the single-user runlevel.

Is it possible?

ibedelovski
  • 503
  • 3
  • 9
  • 20

1 Answers1

6

Yes, this is almost certainly possible.


  • Mount the new partition somewhere in your filesystem.
    • mount /path/to/device /mnt
  • Copy the contents of your current /usr to the new partition.
    • rsync -a /usr /mnt
  • Unmount the new partition.
    • umount /mnt
  • Update your /etc/fstab to reflect the changes.
    • /path/to/device /usr defaults 0 0
  • Mount the new partition.
    • mount /usr
user9517
  • 114,104
  • 20
  • 206
  • 289
  • I've already done this but all the files and directories are owned by the root user and some services cannot access certain files in /usr – ibedelovski May 22 '14 at 12:50
  • On a CentOS system I have to hand there are only a handful of directories and files in /usr that aren't owned by uid/gid 0 and the rsync command copies the ownership/permissions on these correctly. – user9517 May 22 '14 at 12:59
  • 1
    Be careful with this because that don't seem to be working e.g on Ubuntu (see link). Also it's probably a good idea to use `-H` option to copy hard links as there are some in `/usr` directory and `rsync -a` doesn't include hard links. See problems on Ubuntu here: https://askubuntu.com/questions/1167612/ubuntu-doesnt-boot-after-moving-usr-from-hdd-to-ssd-nvme – Nux Aug 22 '19 at 11:03