-1

I refer to the post How do I mount a folder from another partition?. I have /home associated with a partition and this is working.

From the post it seems that my fstab should read:

/whatever    /home    none    bind

Can I have /whatever related to this partition without is being under /home? In scripts I would like to refer to this location as /whatever rather than as /home/whatever

I come from the Windows environment the my reasoning is that Drive D could have any number of folders under it.

Thanks


Clarification note

I have the following in my fstab

UUID=109bff64-xxxx /home ext4 defaults 0 2

I want to add a directory /whatever to resolve to the save device having UUID=109bff64-xxxx.

I do not want /whatever to be under /home.

chribonn
  • 291
  • 1
  • 3
  • 15
  • 3
    Please [edit] your question and describe what the end result you want looks like. I can't understand what you are trying to achieve. Bind mounts essentially give you two locations where the same data are located. Is that what you want? What is /whatever? What do you want it to be? Where do you want to have its data mounted? – terdon Jan 08 '23 at 14:46
  • @terdon. Clarification added. Thanks – chribonn Jan 09 '23 at 07:51
  • Thanks, that helps. So why do you need a bind mount for this? Wouldn't a simple symlink be enough? Something like sudo ln -s /home /whatever? And your comment about "drive D having multiple folders" is also confusing, /home can have as many folders under it as you like. I am having trouble understanding what advantage you see in having this /whatever. Why is it easier to use /whatever in a script than to use /home? I feel this may be an xy problem. – terdon Jan 09 '23 at 09:16
  • I don't have an opinion on symbolic links. I come from Windows and I find it challenging to wrap my mind around going from devices that have names (A:, B:, ...) to a devices that are essentially folders. With Windows, C: drive has folders underneath it; here I am saying that /whatever point to ANOTHER folder /home. I can't (my ignorance) appreciate why /dev/sdaX is not the reference point for all folders under it.

    Maybe it needs time to sink in.

    – chribonn Jan 09 '23 at 09:46
  • 1
    There isn't much difference, really. "C" is also a directory, and you can think of it as such. Presumably, Windows also does some sort of mapping between the directory \C: and the drive. So just like your system partition is accessible via \C: in Windows, so your home partition is accessible via /home in Linux. Sure, the mechanics might be different, but from the user perspective it is basically the same. But, again, what is the benefit for you in having /whatever point to /home? What can you do with /whatever that you cannot do with /home? – terdon Jan 09 '23 at 10:15
  • I came tot he same conclusion. In fact I didn't create it. – chribonn Jan 09 '23 at 10:20

1 Answers1

1

While you could do this with a bind mount, that seems like overkill. If all you want is to access the data in /home from the directory /whatever, a symlink is enough:

sudo ln -s /home /whatever

That will create the symlink /whatever and you can use it just as you would /home.

I don't see any advantage to using a bind mount instead if all you want is a different entry point to /home. But then I also don't really understand why you would prefer to use /whatever instead of /home. They are both top level directories under / so there seems to be no benefit in using one over the other.

In any case, if you insist on using a bind mount, then you would first need to create the directory:

sudo mkdir /whatever

And then add this line to the end of your /etc/fstab file:

/home    /whatever   bind  defaults

That means "bind mount /home to /whatever".

terdon
  • 100,812