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?

0

1 Answer 1

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
3
  • 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 May 22, 2014 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, 2014 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: askubuntu.com/questions/1167612/…
    – Nux
    Aug 22, 2019 at 11:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .