One of the great things about UNIX and Linux is that they were built from the start to be multitasking and multiuser operating systems.
As networking became faster, new additions were done that was also multitasking and multiuser, such as the network file system, or NFS.
The automounter is an important part of managing a UNIX network with a few users and machines to several hundreds or thousands of them.
Linux implements the automounter as autofs. It is not limited to network file systems, and can do other local devices as well, such as CD-ROMs, floppies, USB devices, and much more.
When combined with KDE's session saving feature, this becomes a very convenient setup, where any user can login anywhere, and get the same session as he last left it, with the same applications opening up as they were.
This article focuses on how to use the automounter in Linux for remote file systems.
Introduction
If you have a home network of several machines used by several people, a few issues may crop up after some time using it. For example:
- Users will have data on their local machines. This complicates things such as backups, which are easier if they are centralized.
- Users may want to access their data from other machines, such as a test machine in the lab, or if their own machine is down.
The answer to the above is to use the automounter to make the users' home directories available on any machine they log in to.
Assumptions
The assumption here is that you have a server that has NFS running, and that the /etc/exports file has the home directories setup to be shared.
Then you have to setup every client machine per the following steps:
Installation
To acheive this, you need to install and configure the the autofs package. If you are using an RPM based distribution, then check RPMFind for your distribution and architecture.
On Mandrake, you can use the following command:
urpmi autofs
On Debian, you can use apt-get.
Configuration
After you finish the installation, you have to configure autofs.
First, as root, you have to edit the file: /etc/auto.master to include the following line:
/home /etc/auto.home --timeout=60
Then, create a new file called /etc/auto.home, and add the following line in it:
* -fstype=nfs,rw,nosuid,soft server:/home/&
You have replace server in the above file by the hostname of your NFS server.
The secret to this working as well as it does, is the * and /home/& parts. This tells the automounter to mount user directories on demand. This setup makes things simple, and eliminates the need to list every user's home directory in the configuration file.
Then, issue the following command as :
/etc/init.d/autofs start
Conclusion
Now, any access to home directories from any client machine will cause this directory to be mounted.
Combined with KDE's session saving, this becomes a very convenient feature, since users get their exact session on any machine they login to.
My daughters use this feature to login from another machine if their own one has a problem.
Neat, isn't it?
Comments
Anonymous (not verified)
Thank you!
Mon, 2008/03/03 - 18:25Thank you!
Bob (not verified)
It goes without saying...
Tue, 2008/03/11 - 08:59One should do this as root, not as a normal user working as root (via su, sudo, etc.) and especially not as a normal user logged in via graphical console (KDE, Gnome.) Expect the desktop to freeze as it gets confused as to where your home directory went when you fire up autofs.
I found it helpful to use rsync or 'cp -a' to copy home directories to their new autohome location, then move the old home directory to someplace memorable like /home.old. Make sure your users' uids and guids line up on all your systems and move non-user home directories elsewhere. The former problem is solved with LDAP, NIS, or tedious work with vi and chown (note: I would like to talk with someone who has set up LDAP at home, assuming anyone is crazy/bored enough to have done such a thing.)
In my case, I had a Subversion repository under /home/svn - I moved it to /srv/svn and changed the Apache config (remember to reload Apache) and it worked just fine. /home/ftp moved to /srv/ftp.home - I'm not sure that even needs to exist.
When the dust settles, the three-line config change above should make your life easier or at least more consistent and save you some disk space and backup headaches. As usual, you trade one form of headache for another, but it's really nice not wondering which machine holds the file you need right now.
So beware the pitfalls - they aren't insurmountable. I just wanted to keep someone else from working along, noticing strange behavior while setting this up and wondering "Have I just hosed myself...?" just as their desktop goes dark. :)
Thanks for the excellent simple tutorial!
Priya Chandran (not verified)
Thanks, incredibly helpful!
Mon, 2010/03/29 - 13:14Thanks, incredibly helpful!
Anonymous (not verified)
Soft mount?
Thu, 2010/08/26 - 18:25These are home directories users will be writing to. They should be hard mounts, not soft!
Joan (not verified)
users home directories in differetn places
Thu, 2010/09/09 - 10:35Hi,
i have two different groups of users.
One of them have their home directory under /home.
The second group have their home under /srv/exports/OtherUsers
* -fstype=nfs,rw,nosuid,soft server:/home/&
works for the first group
* -fstype=nfs,rw,nosuid,soft server:/svr/exports/OtherUsers
works for the second group.
What can i do if i want that works for the two groups together.
Thanks
kusi (not verified)
share home?
Thu, 2010/11/25 - 08:45Is it a good idea to share the home directory among several computers? Aren't there too many machine specific settings (font size, screen resolutions) in directories under $HOME, such as .kde, .config, etc...? What are your experiences?
I decided to just share a "Documents" folder among several computers