Linux, can a home directory be symlinked?

8

1

I have a second large storage hdd mounted in Ubuntu in /media/storage. I would like my home directories for me and all future users of the system to be located on this storage drive as well.

I was thinking that the easiest way to accomplish this was to move /home to /media/storage/home and then create a symlink so that /home points to /media/storage/home. Would this work okay?

The only reason I ask, is because I know that a users home directory has a lot of special configuration information stored in it, so I didn't know if this would screw up anything on the system.

Are there any better alternative methods to relocating the home directory?

Jake Wilson

Posted 2010-02-10T18:40:10.997

Reputation: 3 044

Answers

7

What you describe is one strategy that will work.

Another would be mounting the drive at /home directly, instead of at /media/storage. If you did this you'd probably want to move any existing data into other folders so you don't end up with extra /home/foo subdirectories.

The main potential problem with both strategies is that no home directories will be available if mounting the storage drive fails for some reason. If that happens, the symlink strategy will probably fail harder; the direct-mount strategy will leave an actual directory, so programs that attempt to access /home/foo will fail, but simply accessing /home will still succeed.

quack quixote

Posted 2010-02-10T18:40:10.997

Reputation: 37 382

1And if you have the /home/foo directories hidden by the mount, if the disk ever fails, people will still be able to login. Especially for graphical logins, inability to write to a users home directory means that they can't login. – KeithB – 2010-02-10T19:23:04.580

1@KeithB: yes. you could leave skeletal home directories to be hidden by the mount, although that might not be the optimal choice. it becomes a question of whether you'd want the user to login with a restricted, basic configuration, or whether you'd want the logins to fail so you know to fix the problem. (i thought about making that point in the answer, but it opens up other cans of worms that are a little tangential to the issue at hand.) – quack quixote – 2010-02-10T19:29:21.693

Okay so I guess my biggest concern is that if my storage drive fails, that /home will not be accessible. The main reason that I want my /home directories on a different drive that the primary OS drive/partition is that my primary drive that the OS is installed on is only like 100 gigs and between multiple users filling up their home directories, that will fill up fast. So having /home on the much larger storage drive would be much better. Is there anyway to have some sort of cascading setup where if /home is on a separate drive that fails to mount, it looks for it elsewhere? – Jake Wilson – 2010-02-10T19:36:44.417

@Jakobud: it sounds possible but i don't know of an existing solution for that; might need custom scripting to implement. i wouldn't worry about it; you've got good reasons to make this change, and in the event of a mount failure, i'd probably want the system to idle (with logins disallowed or basically useless) until i could handle it manually. – quack quixote – 2010-02-10T19:58:26.860

you could also look into a solution like LVM that would allow you to have the /home directories to take up space on both drives, but applying LVM to a non-LVM system basically means reinstalling, so it would be some work. if this is for home use, don't worry about it; if for a commercial server, an LVM strategy might be worth considering. – quack quixote – 2010-02-10T20:01:14.173

@~quack True. I was thinking about the case of a home system with few users. If this a a more widely used machine, login failure may indeed be a better option. – KeithB – 2010-02-10T21:05:55.520

I have done this before and suggest you do /media/storage/osver. when you upgrade to a new ver of os add a new folder after it is up and running normally as well as you have your users setup you can migrate their data. If I had more then just me on this pc when I installed ubuntu 11.4 i would have had to revert after a week or 3. the bad side to that is version specific configs in your users dir.... 11.4 doesnt work for hw accelleration in my config where 10 worked like a champ so reverting would have been ugly. – Kendrick – 2012-08-31T00:34:45.897

3

Instead of symlinking the whole /home dir to someplace else (say /media/storage/home), create symlinks for every user separately and leave your admin account unlinked so admin can always login

/home/admin is /home/admin

/home/billy is linked to /media/storage/home/billy

cypour

Posted 2010-02-10T18:40:10.997

Reputation: 31

admin is likely an account with admin priviliges and the ability to login remotely (while direct root login is likely blocked and thus insufficient for recovery purposes). – HonoredMule – 2016-12-15T19:50:49.210

1are there actually any distributions using /home/admin istead of /root as the homefolder for root? either way i think it would still be easier to simply move the admins ~/ somewhere else than creating a symlink for each user. – Baarn – 2012-01-31T00:51:19.223