AutoFS provides automounting of removable media or network shares when they are inserted or accessed.
- 2Configuration
- 2.2NFS network mounts
- 2.3Samba
- 2.4FTP and SSH (with FUSE)
- 4Troubleshooting and tweaks
- You have searched for packages that names contain autofs in all suites, all sections, and all architectures. Found 8 matching packages. Exact hits Package autofs. Xenial (16.04LTS) (utils): kernel-based automounter for Linux 5.1.1-1ubuntu3: amd64 arm64 armhf i386 powerpc ppc64el s390x.
- Autofs consults the master map configuration file /etc/auto.master to determine which mount points are defined. It then starts an automount process with the appropriate parameters for each mount point. Each line in the master map defines a mount point and a separate map file that defines the file systems to be mounted under this mount point.
This should cover both Centos and Debian/Ubuntu/Mint Linux based installations. The below guide covers how I setup a few mount points over sshfs via autofs. Install autofs first via sudo or root. Debian/Ubuntu/Mint Linux. Sudo apt-get install autofs. Centos/RHEL/ rpm based. Sudo yum install autofs.
Installation
Install the autofs package.
Note: You no longer need to load
autofs4
module.Configuration
AutoFS uses template files for configuration which are located in
/etc/autofs
The main template is called auto.master
, which can point to one or more other templates for specific media types.- Open the file
/etc/autofs/auto.master
with your favorite editor, you will see something similar to this:
The first value on each line determines the base directory under which all the media in a template are mounted, the second value is which template to use. The default base path is
/media
, but you can change this to any other location you prefer. For instance:Note: Make sure there is an empty line on the end of template files (press
ENTER
after last word). If there is no correct EOF (end of file) line, the AutoFS daemon will not properly load.The optional parameter
timeout
sets the amount of seconds after which to unmount directories.The base directory will be created if it does not exist on your system. The base directory will be mounted on to load the dynamically loaded media, which means any content in the base directory will not be accessible while autofs is on. This procedure is however non-destructive, so if you accidentally automount into a live directory you can just change the location in
auto.master
and restart AutoFS to regain the original contents.If you still want to automount to a target non-empty directory and want to have the original files available even after the dynamically loaded directories are mounted, you can use autofs to mount them to another directory (e.g. /var/autofs/net) and create soft links.
Alternatively, you can have autofs mount your media to a specific folder, rather than inside a common folder.
Note: This can cause problems with resources getting locked if the connection to the share is lost. When trying to access the folder, programs will get locked into waiting for a response, and either the connection has to be restored or the process has to be forcibly killed before unmounting is possible. To mitigate this, only use if you will always be connected to the share, and do not use your home folder or other commonly used folders lest your file browser reads ahead into the disconnected folder
- Open the file
/etc/nsswitch.conf
and add an entry for automount:
- When you are done configuring your templates (see below), launch the AutoFS daemon as root by enabling and starting the
autofs.service
.
Devices are now automatically mounted when they are accessed, they will remain mounted as long as you access them.
Removable media
Removable devices are assigned block device locations according to the next available spot, e.g. if
/dev/sd{a,b,c}
are already occupied, the next removable media will be given block /dev/sdd
. Instead of assigning a mount point based on an unreliable block device path, a more robust approach is to use the UUID or PARTUUID of the removable media as the location in the map file.For example, to mount a specific USB drive to the path
/mnt/black
, configure the template file and map file:Use
blkid
to find the UUID of the partition to mount, then generate the map file:NFS network mounts
This article or section needs language, wiki syntax or style improvements. See Help:Style for reference.
Reason: 'New' compared to what? In what way?; don't show systemctl start; formatting cleanup (Discuss in Talk:Autofs#)
AutoFS provides a new way of automatically discovering and mounting NFS-shares on remote servers (the AutoFS network template in
/etc/autofs/auto.net
has been removed in autofs5). To enable automatic discovery and mounting of network shares from all accessible servers without any further configuration, you will need to add the following to the /etc/autofs/auto.master
file:Note: Each host name needs to be resolveable, e.g. the name an IP address in
/etc/hosts
or via DNS and make sure you have nfs-utils installed and configured. You also have to enablerpcbind
to browse shared Folders.For instance, if you have a remote server fileserver (the name of the directory is the hostname of the server) with an NFS share named /home/share, you can just access the share by typing:
Note: Please note that ghosting, i.e. automatically creating directory placeholders before mounting shares is enabled by default, although AutoFS installation notes claim to remove that option from
/etc/conf.d/autofs
in order to start the AutoFS daemon.The
-hosts
option uses a similar mechanism as the showmount
command to detect remote shares. You can see the exported shares by typing:Replacing <servername> with the name of your own server.
Manual NFS configuration
Linux Automount Nfs
To mount a NFS share on server_name called /srv/shared_dir to another computer named client_pc at location /mnt/foo, edit auto.master and create a configuration file for the share (auto.server_name):
Samba
Single shares
Add the following to
/etc/autofs/auto.master
:where
--timeout
defines how many seconds to wait before the file system is unmounted. The --browse
option creates empty folders for each mount-point in the file in order to prevent timeouts, if a network share cannot be contacted. Next create a file
/etc/autofs/auto.[my_server]
You can specify a user name and password to use with the share in the
other_options
section:Note: Escape $, and other characters, with a backslash when neccessary.
Multiple shares
You may be specify multiple shares in the
/etc/autofs/auto.[my_server]
, for instance:Auto discovery
See the comments in
/etc/autofs/auto.smb
.FTP and SSH (with FUSE)
Remote FTP and SSH servers can be accessed seamlessly with AutoFS using FUSE, a virtual file system layer.
Remote FTP
First, install the curlftpfs package.Load the fuse module:
Create a
/etc/modules-load.d/fuse.conf
file containg fuse
to load it on each system boot.Next, add a new entry for FTP servers in
/etc/autofs/auto.master
:Create the file
/etc/autofs/auto.ftp
and add a server using the ftp://myuser:mypassword@host:port/path
format:Note: Your passwords are plainly visible for anyone that can run
df
(only for mounted servers) or view the file /etc/autofs/auto.ftp
.If you want slightly more security you can create the file
~root/.netrc
and add the passwords there. Passwords are still plain text, but you can have mode 600, and df
command will not show them (mounted or not).This method is also less sensitive to special characters (that else must be escaped) in the passwords. The format is:The line in
/etc/autofs/auto.ftp
looks like this without user and password:Create the file
/sbin/mount.curl
with this code:Create the file
/sbin/umount.curl
with this code:Set the permissions for both files:
After a restart your new FTP server should be accessible through
/media/ftp/servername
.Remote SSH
The factual accuracy of this article or section is disputed.
Reason: All the ssh* commands should be executed as the same user, as before this edit. It should not matter if it is root or unprivileged. (Discuss in Talk:Autofs#)
These are basic instructions to access a remote filesystem over SSH with AutoFS.
Note: Password-less authentication may be convenient but also has security implications. See SSH keypair for more details
Install the sshfs Folx go 5 4 – manage and organize downloads pdf. package.
Load the
fuse
module:Create a
/etc/modules-load.d/fuse.conf
file containg fuse
to load it on each system boot if you have not one yet.Install openssh.
Generate an SSH keypair:
When the generator ask for a passphrase, just press
ENTER
. Using SSH keys without a passphrase is less secure, yet running AutoFS together with passphrases poses some additional difficulties which are not (yet) covered in this article. Next, copy the public key to the remote SSH server:
As root, see that you can login to the remote server:
Note: This will add the remote server to root's list of
known_hosts
. Hosts can be also be manually added to /etc/ssh/ssh_known_hosts
.Create a new entry for SSH servers in
/etc/autofs/auto.master
:Create the file
/etc/autofs/auto.ssh
and add an SSH server:After a restart your SSH server should be accessible through
/media/ssh/servername
.MTP
Media Transfer Protocol (MTP) is used in some Android devices.
Install the mtpfs package.
Create a new entry for MTP Device in
/etc/autofs/auto.misc
:Troubleshooting and tweaks
This section contains a few solutions for common issues with AutoFS.
Using NIS
Version 5.0.5 of AutoFS has more advanced support for NIS. To use AutoFS together with NIS, add
yp:
in front of the template names in /etc/autofs/auto.master
:On earlier versions of NIS (before 5.0.4), you should add
nis
to /etc/nsswitch.conf
:Optional parameters
You can set parameters like
timeout
systemwide for all AutoFS media in /etc/default/autofs
:- Open the
/etc/default/autofs
file and edit theOPTIONS
line:
- To enable logging (default is no logging at all), uncomment and add
--verbose
to theOPTIONS
line in/etc/default/autofs
e.g.:
After restarting the
autofs
daemon, verbose output is visible in systemctl status
or in journalctl
.Identify multiple devices
If you use multiple USB drives/sticks and want to easily tell them apart, you can use AutoFS to set up the mount points and Udev to create distinct names for your USB drives. See udev#Setting static device names for instructions on setting up Udev rules.
AutoFS permissions
If AutoFS is not working for you, make sure that the permissions of the templates files are correct, otherwise AutoFS will not start. This may happen if you backed up your configuration files in a manner which did not preserve file modes. Here are what the modes should be on the configuration files:
- 0644 - /etc/autofs/auto.master
- 0644 - /etc/autofs/auto.media
- 0644 - /etc/autofs/auto.misc
- 0644 - /etc/conf.d/autofs
In general, scripts (like previous
auto.net
) should have executable (chmod a+x filename
) bits set and lists of mounts should not.If you are getting errors in
/var/log/daemon.log
similar to this, you have a permissions problem:fusermount problems
With certain versions of util-linux, you may not be able to unmount a fuse file system drive mounted by autofs, even if you use the 'user=' option. See the discussion here:http://fuse.996288.n3.nabble.com/Cannot-umount-as-non-root-user-anymore-tp689p697.html
Debugging auto mount issues
For better debugging you might try running automount in foreground.
Of if you want more debug info than try:
Alternatives to AutoFS
- Systemd can automount filesystems upon demand; see here for the description and the article on sshfs for an example.
- Thunar Volume Manager is an automount system for users of the Thunar file manager.
- PCManFM is a lightweight file manager with built-in support for accessing remote shares
- Udisks is a minimalistic automatic disk mounting service
See also
- FTP and SFTP usage with AutoFS is based on this Gentoo Wiki article: https://web.archive.org/web/20130414074212/http://en.gentoo-wiki.com/wiki/Mounting_SFTP_and_FTP_shares
- More information on SSH can be found on the SSH and Using SSH Keys pages of this wiki.
- Ubuntu's Autofs help wiki is at https://help.ubuntu.com/community/Autofs
- For filesystem specific mount options check http://manpages.ubuntu.com/manpages/focal/man8/mount.8.html#filesystem-specific%20mount%20options
- For fuse specific mount options check http://manpages.ubuntu.com/manpages/precise/man8/mount.fuse.8.html
Retrieved from 'https://wiki.archlinux.org/index.php?title=Autofs&oldid=637736'
Contents[Hide]- automount configuration
It is more & more common to have a NAS or server at home, where you keep all the files that you need to share between your home computers or appliances. For example, if you want to share your music or video library across different computers, you will mostly need to share them thru a cifs (samba) share.
This article will explain how to setup a Ubuntu workstation to automount a list of network shares. These network shares won't be mounted all the time, they will be mounted 'on demand', when you need them. They will be available thru a desktop icon.
The main advantage of automount approach is to have these network shares accessible thru the normal filesystem. This way, even applications which are not able to use gnomefs will be able to access files on the network shares.
This setup has been done on a Ubuntu Jaunty 9.04 workstation, but it should work on any later version.
1. packages Installation
First thing to do is to install smbfs & automount packages :
# sudo apt-get install cifs-utils autofs
2. automount configuration
You then need to create the server automount root /mnt/server where all the network shares will be mounted. This root needs to have the proper access rights.
# sudo mkdir /mnt/server
# sudo chmod 0666 /mnt/server
# sudo chmod 0666 /mnt/server
Edit /etc/auto.master to add the following line at the end of the file :
/etc/auto.master
..
/mnt/server /etc/auto.server --timeout=6000 --ghost
#+auto.master
..
/mnt/server /etc/auto.server --timeout=6000 --ghost
#+auto.master
Autofs Ubuntu Linux
Under some Ubuntu versions, the default auto.master file is having a last line +auto.master which means that the file includes itself !
You must comment or remove that last line or you will get some wierd errors while trying to browe your automount directories.
Make sure you've done it before going further (thanks to François for pointing this out :-)
You must comment or remove that last line or you will get some wierd errors while trying to browe your automount directories.
Make sure you've done it before going further (thanks to François for pointing this out :-)
Then, create /etc/auto.server to list all the shares that should be automatically mounted under the /mnt/server root :
/etc/auto.server
# /etc/auto.server
# list all the shares to automount, here are some examples
# you need one credential file per different username/password combination
photo -fstype=cifs,credentials=/etc/auto.auth ://AddressOfServer/photo
video -fstype=cifs,credentials=/etc/auto.auth ://AddressOfServer/video
music -fstype=cifs,credentials=/etc/auto.auth ://AddressOfServer/music
# /etc/auto.server
# list all the shares to automount, here are some examples
# you need one credential file per different username/password combination
photo -fstype=cifs,credentials=/etc/auto.auth ://AddressOfServer/photo
video -fstype=cifs,credentials=/etc/auto.auth ://AddressOfServer/video
music -fstype=cifs,credentials=/etc/auto.auth ://AddressOfServer/music
You have to create as many number of credential files as needed. In this example, all the ressources are accessed with the same username/password, so only one file is needed.
/etc/auto.auth
username=nobody
password=xxxxx (can be empty if no password)
username=nobody
password=xxxxx (can be empty if no password)
Please note that you should not have any space before or after the '=' sign. Otherwise, your credentials won't be taken into account and you will get an access credentials error. Dreamweaver cc 2014 – build world class websites and applications.
Once configuration is over, you need to restart autofs daemon for the changes to take effect.
# sudo /etc/init.d/autofs restart
You should now be able to automatically mount and browse /mnt/server/photo, mnt/server/video & /mnt/server/music. Ressource will be unmounted by the system after the timeout.
2.1. Desktop shortcut
If you want to have a direct access to these network shares from your desktop, you just need to create a symbolic link on your desktop. Here the desktop icon will be called Server :
# ln -s /mnt/server /home/youraccount/Desktop/Server
From now on, you can browse your server shares thru the Server icon on your desktop.
Any application can access the server files thru :
Any application can access the server files thru :
- /mnt/server
- /home/youraccount/Desktop/Server
Resample 1 1 0 – an intuitive audio editor. Isn't it simple :-)