autofs is a program for automatically mounting directories on an as-needed basis. Auto-mounts are mounted only as they are accessed, and are unmounted after a period of inactivity. Because of this, automounting NFS/Samba shares conserves bandwidth and offers better overall performance compared to static mounts via fstab.
In this case, the first will be mounted as /net/remotenfs/ and the second as /net/remotesmb/. For the Samba share, credentials are required and are defined in /etc/smb.auth, which would look like. Mount an smb share with fstab vs sudo mount problems. AutoFS for mouting Samba share with Kerberos Ticket. Hot Network Questions How did Azerbaijan come to be allied with Turkey and Israel? Why is Microgravity called 'Microgravity' How do I ask Japanese restaurants in.
1.1. Quick note on terms
To avoid confusion, the following terminologies will be used:
- automount is the program used to configure a mount point for autofs. When autofs is started, an automount daemon is spawned for each map.
- Auto-mount or auto-mounting refers to the process of automatically mounting filesystems.
- autofs is the program that controls the operation of the automount daemons.
Install the autofs package either by clicking here or entering the following in a terminal window:
autofs can be configured by editing configuration files. There are other ways to configure autofs on a network (see AutofsLDAP), but config files provide the simplest setup.
- Autofs also referred as Automount is a nice feature in linux used to mount the filesystems automatically on user’s demand.
- 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. First, install the curlftpfs package. Load the fuse module: # modprobe fuse Create a /etc/modules-load.d/fuse.conf file containg fuse to load it on each system boot.
- Findsmb - list info about machines that respond to SMB name queries on a subnet SYNOPSIS findsmb subnet broadcast address DESCRIPTION This perl script is part of the samba(7) suite. Findsmb is a perl script that prints out several pieces of information about machines on a subnet that respond to SMB name query requests.
3.1. The Master Map File
The master configuration file for autofs is /etc/auto.master by default. Unless you have a good reason for changing this, leave it as the default.
Here is the sample file provided by Ubuntu:
- By default, all lines are commented out by using the # character.
Each of the lines in auto.master describes a mount and the location of its map. These lines have the following format:
3.1.1. Direct and Indirect Maps
automount maps can be direct or indirect. Indirect maps, such as those in the auto.master file shown above, create-mount points as subdirectories inside the main mount-point. For example, consider the following master map entry:
This entry in auto.master tells autofs to look in /etc/auto.smb and create mount-points in the /smb directory.
Direct maps create a mount-point at the path specified in the relevant map file. The mount-point entry in auto.master is always /-. For example, the following line instructs autofs to create a mount-point at the place specified in auto.data:
- If the map file is not specified using a full local or network path, the Name Service Switch configuration will be used to locate the map, e.g.:
3.2. Map Files
As indicated above, each autofs mount has its own map file. These files are usually named using the convention auto.<X>, where <X> can be anything as long as it matches an entry in auto.master and is valid for a file-name.
Map files take the following format:
In this howto, we will configure autofs to auto-mount an NFS share, using a set of configuration files. This howto assumes that you are already familiar with NFS exports, and that you already have a properly-functioning NFS share on your network. Go to the NFS Setup Page to learn how to set up such a server.
4.1. Edit /etc/auto.master
The following step creates a mount point at /nfs and configures it according to the settings specified in /etc/auto.nfs (which we will create in the next step).
- Type the following into a terminal:
- Add the following line at the end of /etc/auto.master:
4.2. Create /etc/auto.nfs
Now we will create the file which contains our automounter map:
This file should contain a separate line for each NFS share. The format for a line is {mount point} [{mount options}] {location}. If you have previously configured static mounts in /etc/fstab, it may be helpful to refer to those. Remember, the mount points specified here will be relative to the mount point given in /etc/auto.master.
The following line is for shares using older versions of NFS (prior to version 4):
This creates a new mount point at /nfs/server/ and mounts the NFS root directory exported by the machine whose host-name is server.
4.2.1. NFSv4
If your NFS shares use NFSv4, you need to tell autofs about that. In such a case, the above line would appear as follows:
The client needs the same changes to /etc/default/nfs-common to connect to an NFSv4 server.
- In /etc/default/nfs-common we set:
4.3. Unmount static mounts and edit /etc/fstab
If you have previously configured the NFS shares as static mounts, now is the time to unmount them.
Next, remove (or comment out) their respective entries in /etc/fstab.
4.4. Reload /etc/init.d/autofs
After entering your changes, run the following command to reload autofs:
If working on an older ubuntu version, and that does not work try:
If working in Natty, and that does not work try:
4.5. Make sure it works
In order to access the share and verify that it is working properly, enter the following into a shell:
If you see your NFS share listed, congratulations! You have a functioning NFS mount via autofs! If you want to learn some more advanced information, keep reading.
Following the example directory structure above, if you were to enter ls /nfs into a shell, you might be surprised to see nothing listed. But remember that you need to access a directory before it is auto-mounted. To access the share, enter ls /nfs/server. Once it has been accessed, your share will be listed only until it times out. This is good to keep in mind, as it could save you time diagnosing an autofs problem that isn't really there.
5.1. Note on /net and /smb
These two default configurations may be useful for your set-up. If you have a lot of NFS or Samba shares, you may want to uncomment these lines. /net enables auto-mounting of file systems elsewhere on the network which are exported by NFS. For example, if you have a server named fileserver with an NFS export directory called /export, you can mount it by typing in a shell command line cd /net/fileserver/export. In an environment with NFS file servers, such a configuration can be useful. /smb functions the same way but is for Samba file systems. However, if you need to authenticate before accessing the Samba share, automount will not function.
5.2. Wildcard characters
Let's say you have a directory with a number of subdirectories which you want to have auto-mounted individually. An example of this is the /home directory, in which case /etc/auto.master might contain the following line:
If user1 is logged in, you will want to auto-mount his home directory. However, if you create a mount point for the whole /home directory, you will also mount the home directories of every other user at the same time, thus wasting bandwidth. One solution to this would be to create separate entries for each directory, as follows:
This works, but is cumbersome. Instead, you can use wild-card characters, as follows:
The asterisk (*) is used in place of the mount point and the ampersand (&) in place of the directory to be mounted. For more detail on the use of wild-cards see Using Wild-card Characters as Short-cuts in AutoFS Maps.
You can also use variables (see autofs(5) man page) to substitute users and other parameters to be able to create generic file for multiple users. Example below is smb map that maps based on user which asks for the share using $USER variable.
6.1. CIFS
When specifying a CIFS share in a map file, specify -fstype=cifs and precede the share location with a colon (:).
Example:
Example: Mount read-write, specifying a user and group to own the files:
Autofs Smb Mac
Example: Mount read-write, specifying a username and password to use to connect to the share:
6.2. FUSE based file systems
FUSE based file systems are mounted by specifying -fstype=fuse. The file-system location specifies the user-space binary used to mount the file system, followed by a hash (#), followed by the location.
Autofs Smb Server
When specifying a FUSE file system location in map file, certain characters, notably the hash (#) and the colon (:), must be escaped by a backslash (). The entire location must be preceded by a colon (:).
Since automount performs the mount as root it is usually necessary to specify allow_other on the mount options to allow your non-root userid to access the share.
6.2.1. SSHFS file system
SSHFS is a FUSE based file-system. In an autofs mount, the colon (:) following the server name must be escaped by a backslash ().
You should have already set-up password-less authentication via public key encryption. Be sure that you understand the security implications of this before proceeding.
Remember, automount will mount your SSHFS file-system as root, so you need to:
- Copy your private key to the /root/.ssh directory. Be sure that you understand the security implications of this before proceeding.
- Add the necessary host keys to /root/.ssh/known_hosts.
- Specify the user-name used to connect
To test mounting your SSHFS file system as root issued the following:
If the mount succeeds without prompting you for a password, you are ready to mount the file-system via autofs
Example:
Example: Mount read-write, specifying a user and group to own the files: Vuescan 9 5 65 download free.
Note that for FUSE mounts, uid and gid must be numeric ids.
If you are having trouble automounting your file systems, it may be useful to run automount in the foreground.
- Stop the autofs daemon
- Run automount in the foreground with verbose information
- From another terminal, try to mount your file-systems by changing directories into the mountpoint.
- Check the output from the first terminal for clues as to why the mount failed or was not attempted.
- Mount - Information about the mounting process and its configuration in Ubuntu.
- The mount man page - hosted on the official Ubuntu website.
Autofs的更多相关文章
Autofs Smb Login
- autofs自动挂载autofs是根据需要自动挂载,默认5分钟不使用自动卸载挂载点!nfs,smb,iso,sd*的挂载 环境:RHEL6.5/Centos6.5 172.24.0.25 01.安装autofs y ..
- autofs实现nfs自动挂载apt-get install autofs 主配置文件/etc/auto.master 副配置文件可以在之配置文件中自定义 能生效的配置文件如下例: 将/usr/local/nginx/html挂载 ..
- Nis+Nfs+AutofsNis: NIS服务的应用结构中分为NIS服务器和NIS客户机两种角色 NIS服务器集中维护用户的帐号信息(数据库)供NIS客户机进行查询 用户登录任何一台NIS客户机都会从NIS服务器进行登录认证, ..
- Linux nfs+autofs 环境搭建两台服务器环境为centos 6.6 1.安装配置nfs 安装portmap 和 nfs [root@node0 ~]# yum install portmap [root@node0 ~]# yu ..
- RHCE之配置autofs远程挂载远程服务器的家目录[root@server0 ~]# yum -y install autofs 安装包 [root@server0 ~]# vim /etc/auto.master ..
- Autofs自动挂载探讨Autofs介绍: mount是用来挂载文件系统的,可以在系统启动的时候挂载也可以在系统启动后挂载.对于本地固定设 备,如硬盘可以使用mount挂载:而光盘.软盘.NFS.SMB等文件系统具有动态性, .. File cabinet pro 4 9 5.
- 绑定到外部验证服务LDAP、配置 autofs题1:您的系统需要按照以下要求绑定到这个服务上:验证服务器的基本 DN 是: dc=xxxx,dc=xxxx,dc=xxxx. 帐户信息和验证信息都是由 LDAP 提供的.连 接 需 要 使 用 证 ..
- NFS使用autofs自动挂载NFS自动挂载设置在/etc/fstab和/etc/rc.local可能挂载不成功,假如是服务端NFS宕机还可能导致客户端无法启动,可以使用autofs实现自动挂载 安装autofs yum -y i ..
- 004.Autofs自动挂载一 安装autofs [root@imxhy data]# yum -y install autofs 二 编辑自动挂载相关配置 2.1 修改master [root@imxhy ~]# vi /et ..
随机推荐
Autofs Smb File
- debian下使用Sphinx异常“Could not import extension sphinx.builders.linkcheck (exception: cannot import name SSLError)”的解决最近使用到Sphinx编译文档,出现如下异常: Extension error:Could not import extension sphinx.builders.linkcheck (except ..
- php 总结第一篇(望大家补充!谢谢)/* 数组的常用函数 * * 数组的排序函数 * sort() * rsort() * usort() * asort() * arsort() * uasort() * ..
- mvc、三次握手1.所谓MVC便是: ① View:(查看,观察)就只处理View的事情,其它神马都不要管 ② 数据由Model处理,并且为View提供渲染需要的数据 ③ 由于后端可能抽风可能将name变成Name坑 ..
- Google one联合联发科,国内低端智能机方案怎么办?欢迎转载opendevkit文章, 文章原始地址: http://www.opendevkit.com/?e=46 Google在Google I/O大会, 发布的Android One,由于看重的是 ..
- spring中controller提示:原网站已由百度转码,以便在移动设备上查看. 第七城市 (Portal 开发读书笔记)Spring Portlet MVC 测试Controller 2012-04-28 16:32:44 - - ..
- uva11584将课本上所述方法实现即可,代码如下: /* * Author: Bingo * Created Time: 2015/1/25 23:49:49 * File Name: uva11584.cpp * ..
- js对WebApi请求的基本操作在WebAPI对外提供的,大概有4种接口,get,post,delete,put,现在,我就简单的来说一下js请求webApi的方式和大概的作用: get:在webApi中,get方法通常是用来获取数 ..
- Oracle 正则表达式函数-REGEXP_REPLACE背景 当初写oracle的一个存储过程,以前不知道sql里也有正则表达式,关于正则表达式教程很多了,这里只是记录下Oracle也有这个功能,下次再有类似需求用这个处理的确方便很多. 想起存储过程,就想 ..
- Django项目之cookie+session原文:https://www.cnblogs.com/sss4/p/7071334.html HTTP协议 是短连接.且状态的,所以在客户端向服务端发起请求后,服务端在响应头 加入cokie响应给浏览 ..
- npm配置镜像、设置代理配置镜像 by config command npm config set registry http://registry.cnpmjs.orgnpm info underscore (如果上面配置 ..