1

Somewhat along the lines of this question, How to mount multiple directories on the same partition? but my situation is different.

I have a 2 small partitions that I'm using for two variants of linux and one large partition that I'm using as the home for both. I'd like to move the /usr folder from one of the variants to that same partition.

Any suggestions of how to accomplish this?

2

There is no generic way to directly mount a subtree of a filesystem. But you can mount the whole filesystem somewhere, and then “copy” a subtree of the mount with a bind mount.

mount /dev/foobar /media/foobar
mount --bind /media/foobar/usr /usr

In fstab syntax:

/dev/foobar /media/foobar auto defaults 0 2
/media/foobar/usr /usr bind bind
  • So if I wanted to use that partition for both variants /usr folders there is no way to do that? @Gilles – Jas Jul 21 '16 at 11:59
  • @Jas I don't understand your comment. What do you mean by “use that partition for both variants /usr folders”? – Gilles Jul 21 '16 at 17:53
  • I apologize for my lack of clarity, I'll try to do better. My thought went like this, if I have 4 partitions in my hard drive I can have one be /swap another be /home and two be /, the two / would be for two different linux variants. The two / or root partitions can be small, maybe 10GB each for system files only. The swap can be as large as my RAM, and the /home partition can be the rest of the drive. – Jas Aug 25 '16 at 6:33
  • However what happened was that the /usr folder in both of the variants became too large and I was trying to move them to the /home partition, but since they had the same name I was hoping to mount them as /usr from the /home partition, for each of the variants, while having the actual folder name be something like "usr16" and "usr14" to keep track of which usr folder went with which variant, say for example if the variants were Ubuntu 14.04 and Ubuntu 16.04. – Jas Aug 25 '16 at 6:38
  • @Jas Sure, you can do that. The best way to do it would be with a symbolic link: ln -s /home/usr14 /usr on the 14.04 system, ln -s /home/usr16 /usr on the 16.04 system. – Gilles Aug 25 '16 at 7:22

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.