Score:-1

How to define the fstab entry for /dirname when /home is already defined

pe flag

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.

terdon avatar
cn flag
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?
pe flag
@terdon. Clarification added. Thanks
terdon avatar
cn flag
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](https://meta.stackexchange.com/q/66377/203101).
pe flag
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.
terdon avatar
cn flag
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`?
pe flag
I came tot he same conclusion. In fact I didn't create it.
Score:1
cn flag

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".

pe flag
Before following this read @terdon's comments under the question.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.