1

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?

4

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
  • 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
  • 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: askubuntu.com/questions/1167612/… – Nux Aug 22 '19 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.