Support for $HOME not in /home

Asked by Paul Perkins on 2018-03-07

I know the usual configuration is that $HOME for $USER is /home/$USER, but sometimes there are reasons to put home directories on a filesystem that is neither root nor dedicated exclusively to home directories. This gives rise to home directories with names like /m/home/fred instead of /home/fred, for example. Is it better to define the user so that $HOME points to this path (with adduser or moduser or ?), or to make a symbolic link from /home/fred to /m/home/fred and make $HOME=/home/fred, or to use bind mount to bind /m/home/fred to /home/fred? Are any of these supported in the sense that testing makes some attempt to check that minor updates do not break things like, for example, AppArmor profiles for LibreOffice suddenly making LibreOffice totally nonfunctional if $HOME is not in /home?

I think I am mainly looking for guidance as to which is the way to have the least problems if I have to have some home directories whose real name is not of the form /home/name: bind mounts, symbolic links, or something else.

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Last query:
2018-03-11
Last reply:
2018-03-11

Use a symlink. If you move the data for the folder you can then symbolic link it and make it look like it's in place.

Be sure to run a full backup in case of issues.

Paul Perkins (catmatist) said : #2

I know that using a symlink as in "sudo ln -s /m/home/fred /home/fred" is an option. But backup and copying programs often treat symbolic links differently, and I worry about tripping over this somehow. I'm looking for pointers to statements from the Ubuntu organization, or from other documents on Linux system administration, or even "war stories". I've seen a few statements here and there on the WWW that suggest that some Ubuntu maintainers have an attitude that if your home directory is not a subdirectory of /home, you are asking for trouble. But nothing, so far, that says that is actually official.

Bind mounts are something I never messed with before, but were suggested in the answer to a problem similar to the one I had recently (another broken AppArmor profile). As far as I know, backup and copy programs all treat bind mounts as just like ordinary mounts, so as long as you don't try to copy one to the other, all should be well (?). But I don't have a good reference as to the intended use cases for bind mounts either.

Manfred Hampl (m-hampl) said : #3

If everything is programmed correctly, then there should not be a problem with having the home directory somewhere else, and there should not be any need for a symlink or other additional tricks.

Quote from https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s08.html
"chapter 3.8, "/home (optional)"
"no program should assume any specific location for a home directory"

The POSIX specification requires the OS to set a value for $HOME:
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html
"HOME
 The system shall initialize this variable at the time of login to be a pathname of the user's home directory. See pwd.h."

In my opinion the better way is to have the home directory correctly defined when the user logs in (i.e. the system finds the related information in the passwd file, or from the NIS server or whatever technique is used) and not faking a /home/username entry that is just a link elsewhere.

Can you help with this problem?

Provide an answer of your own, or ask Paul Perkins for more information if necessary.

To post a message you must log in.