Autofs 简介 autofs服务程序是一种Linux系统守护进程,当检测到用户试图访问一个尚未挂载的文件系统时,将自动挂载该文件系统。 (默认时间为5分钟) 1、安装autofs服务 [root@localhost ~]# yum -y install autofs 2、编辑/etc/auto.master # 如果把挂载信息都写入到 autofs服务的主配置文件中,会使主配置文件臃肿不堪,不利于管理和维护。 因此在autofs的主配置文件中按照"挂载目录的上层目录子配置文件"的格式填写,具体的挂载信息写入到子配置文件中,方便日后管理和维护。 4、启动Autofs服务 [root@localhost ~]# systemctl start autofs 验证自动挂载 # 先使用df -h查看是否已经挂载 [root@localhost
安装软件包 你只需要安装两个软件包:用于 NFS 客户端的 nfs-common 和提供自动挂载的 autofs。 alan@workstation1:~$ sudo apt-get install nfs-common autofs 你可以验证 autofs 相关的文件是否已放在 /etc 目录中: alan@workstation1 :~$ cd /etc; ll auto*-rw-r--r-- 1 root root 12596 Nov 19 2015 autofs.conf-rw-r--r-- 1 root root 857 最后,重启 autofs 守护进程,以便识别并加载这些配置的更改。 alan@workstation1:/etc$ sudo service autofs restart 测试 autofs 如果更改文件 auto.master 中的列出目录,并运行 ls 命令,那么不会立即看到任何内容
一 安装autofs 1 [root@imxhy data]# yum -y install autofs 二 编辑自动挂载相关配置 2.1 修改master 1 [root@imxhy ~]#
autofs自动挂载服务可以帮我们解决这一问题。与mount命令不同,autofs服务程序是一种Linux系统守护进程,当检测到用户试图访问一个尚未挂载的文件系统时,将自动挂载该文件系统。 : autofs.x86_64 1:5.0.7-40.el7 Dependency Installed: hesiod.x86_64 0:3.2.1-3.el7 Complete! 如果把这些设备挂载信息都写入到autofs服务的主配置文件中,无疑会让主配置文件臃肿不堪,不利于服务执行效率,也不利于日后修改里面的配置内容,因此在 autofs 服务程序的主配置文件中需要按照“挂载目录 ,nodev :/dev/cdrom [root@localhost ~]# systemctl start autofs [root@localhost ~]# systemctl enable autofs ln -s '/usr/lib/systemd/system/autofs.service' '/etc/systemd/system/multi-user.target.wants/autofs.service
包autofs提供了这个特性。在本文中,我将描述如何启动和运行基本的自动加载配置。 首先,假设NFS服务器linux.linuxidc.com已经启动并运行。 安装包 您只需要安装两个包:NFS客户端函数的常用NFS包,以及提供automount函数的autofs包。 alan@linuxidc:~$ sudo apt-get install nfs-common autofs 您可以验证autofs文件已被放置在etc目录: alan@linuxidc:~$ cd 最后,重新启动autofs守护进程,使其能够识别并加载这些配置文件更改。 alan@linuxidc:/etc$ sudo service autofs restart 测试autofs 如果您更改到文件中列出的目录之一,则自动。掌握并运行ls命令,您不会立即看到任何东西。
查看挂载情况: [root@client ~]# df -h 5、在/mnt里面创建文件验证 [root@client ~]# cd /mnt [root@client mnt]# touch abc 二、autofs 自动挂载配置步骤 (一)准备:要在NSF的基础上进行配置 如上操作 (二)配置autofs步骤 Server端: 检查nfs是否开启: [root@server ~]# systemctl status : [root@client ~]# yum -y install autofs 2、配置/share: [root@client ~]# vim /etc/auto.master.d/test.autofs vim /etc/auto.test 写入:pub 192.168.100.10:/opt/nfsshare 4、重启并开启自启: [root@client ~]# systemctl restart autofs [root@client ~]# systemctl enable autofs 5、访问目录: [root@client ~]# cd /share/pub
三:实施 首先进行 NFS NIS Autofs的配置安装 NIS服务需要以下软件包:ypserv、rpcbind、ypbind、yp-tools NFS服务需要以下软件包:rpcbind、nfs-utils Autofs服务需要以下软件包:autofs centos7(服务器)ip:192.168.83.134 centos6 (客户端)ip:192.18.83.140 服务器包的安装: [root@centos7 install nfs-utils 客户端包的安装: [root@centos6 ~]# yum install ypbind -y [root@centos6 ~]# yum -y install autofs NFS 共享家目录 [root@centos7 ~]# vim /etc/exports.d/mage.exports /app/homedir *(rw,sync) #注意*和()之间没有空格 autofs [root@centos6 ~]# service autofs restart 测试 [root@centos6 ~]# yptest ......... ......... .........
另一种方法是自动安装点播所需的文件系统(不使用mount命令)通过autofs的 ,它可以挂载文件系统时使用它们和闲置一段时间后卸载它们。 每个子目录由autofs动态创建。 现在,重新启动autofs服务: # service autofs restart [sysvinit / upstart based systems] # systemctl restart autofs [systemd based systems] 最后,使autofs,从而开始启动,运行以下命令: # chkconfig --level 345 autofs on # systemctl enable autofs [systemd based systems] 在启动autofs守护程序后检查装入的文件系统 当我们重新启动autofs的 ,mount命令向我们展示了地图文件(/etc/auto.nfs-share
配置完成之后,重启autofs服务:service autofs restart Step-2:访问网络共享目录,运行以下命令: cd /net/192.168.4.211/data/nfs_share 运行上述命令时,autofs会自动挂载NFS服务端中的网络共享目录。 /etc/auto.demo为单个配置文件,包含由autofs服务在此父目录下管理的子目录挂载点的列表。 Step-5:重新启动autofs服务,运行以下命令: service autofs restart Step-6:访问网络共享目录,运行以下命令: cd /root/demo/remote_dir 运行上述命令之后 ,autofs将自动创建挂载点目录,并且挂载共享目录。
[root@vms81.liruilongs.github.io]-[~/ansible] └─$ansible 192.168.26.100 -m shell -a "yum -y install autofs root@vms81.liruilongs.github.io]-[~/ansible] └─$ansible 192.168.26.100 -m shell -a "systemctl enable autofs to /usr/lib/systemd/system/autofs.service. /etc/autofs_ldap_auth.conf /etc/sysconfig/autofs /usr/lib/systemd/system/autofs.service ┌──[root@vms81 root@vms81.liruilongs.github.io]-[~/ansible] └─$ansible 192.168.26.100 -m shell -a "systemctl restart autofs
挂载(推荐) autofs是一个可以根据需要自动挂载目录的工具。 安装 // ubuntu/debian apt install autofs // centos yum install autofs 设置开机启动 systemctl enable autofs 安装完成后 完成上述配置后,重启autofs服务。 systemctl restart autofs 配置完成后,需要使用ls /mnt/local或cd /mnt/local才能激活autofs的自动挂载动作。 客户端安装后,还需要使用autofs来挂载,autofs需要设置开机启动。如果有可能,尽可能设置访问超时时间,这样可以增加磁盘使用寿命。
除此之外,还可以使用自动挂载器(autofs)实现按需自动挂载网络共享目录。当共享不再使用,并处于不活动状态一定时间之后,自动挂载器会对共享解除挂载。 5. 按需自动挂载samba共享目录 Step-1:修改不活动状态的超时时间,运行以下命令: vi /etc/sysconfig/autofs 将上述文件中的TIMEOUT=300替换为TIMEOUT=600 /etc/auto.samba为单个配置文件,包含由autofs服务在此父目录下管理的子目录挂载点的列表。 service autofs restart cd /samba/user1 运行上述命令之后,autofs将自动创建挂载点目录,并且挂载共享目录。 在/samba/user1之下的所有文件和目录停止使用且超时期满之后(10分钟),autofs将卸载共享目录。
要挂载的资源路径可以是文件系统的UUID,设备路径,文件系统的标签 ,光盘镜像文件(iso),亦或是来自网络的共享资源等 三、自动挂载 Automount: 特点:挂载是由访问产生;卸载是由超时产生;依赖于后台的autofs 服务 思路: 所有的监控都是由一个程序完成 autofs 服务启动后才会监控挂载的设备 修改配置文件来指定需要监控的设备 案例演示 需求:让系统自动挂载/dev/sdb2设备,如果2分钟没有被用自动卸载 步骤: 1)安装autofs软件 [root@zutuanxue ~]# rpm -q autofs package autofs is not installed [root@zutuanxue ~ ]# dnf install autofs [root@zutuanxue ~]# rpm -q autofs autofs-5.1.4-29.el8.x86_64 2)修改配置文件(指定需要监控的设备和挂载的目录 子配置文件自己创建,定义二级挂载点和需要挂载的设备 test -fstype=ext4,ro :/dev/sdb2 3)重启服务 [root@zutuanxue ~]# systemctl restart autofs
以我运营该系统超过一年的经验来看,当树莓派启动时(例如在断电后),USB 磁盘驱动器并不是总被挂载,因此我建议使用 autofs 在需要的时候进行挂载。 首先,安装 autofs 并创建挂载点: pi@raspberrypi:~ $ sudo apt install autofs pi@raspberrypi:~ $ sudomkdir/nas 然后添加下面这行来挂载设备 autofs 会跟踪文件系统的访问记录,并随时挂载所需要的设备。然后 mount 命令会显示这两个 USB 磁盘驱动器已经挂载到我们想要的位置了。 设置 autofs 的过程容易出错,如果第一次尝试失败,请不要沮丧。你可以上网搜索有关教程。 挂载网络存储 现在你已经设置了基本的网络存储,我们希望将它安装到远程 Linux 机器上。 如果需要其他帮助,请参看 如何使用 Autofs 来挂载 NFS 共享。 现在你可以在远程设备上通过 NFS 系统访问位于你树莓派 NAS 云盘上的数据了。
service nfs restart NFS客户端配置自动挂载NFS: 配置好了NFS服务端之后,我们就可以给我们需要的NFS挂载机器进行相关配置了,一般来讲,挂载有三种方法,较为推荐的是autofs autofs自动挂载方法在挂载时会咨询主映射配置文件/etc/auto.master来决定要定义哪些挂载点,然后使用适用于各个挂载点的参数来启动automount守护进程。 在开始autofs自动挂载之前,我们需要先进行一些配置,这个配置过程的步骤分为如下几步: 1.查询相关rpm包依赖 这一步类似NFS服务端的检查方法: rpm -q --qf '%{NAME}-% {VERSION}-%{RELEASE} (%{ARCH})\n' autofs nfs-utils nfs-utils-lib 如果没有的话,需要使用下面的命令进行安装: yum install autofs chkconfig --level 345 autofs on service autofs restart 3 常见错误处理 问题1: 如果mount时报错:mount.nfs: Input/output
2016-8-21 /data/bbs 192.168.1.3(rw,sync,all_squash,anonuid=3000,anongid=3000) 客户端的配置如下 首先需要开启autofs /dev/shm /dev/sda1 485M 35M 426M 8% /boot [root@localhost ~]# /etc/init.d/autofs [ OK ] autofs两个组件:/etc/auto.master /etc/auto.misc [root@localhost ~]# vi /etc/auto.master # following format # key [ -mount-options-separated-by-comma ] location # Details may be found in the autofs /bbs 在/mnt下新建一个nfsfile文件夹,-fstype=nfs 192.168.1.2:/data/bbs [root@localhost ~]# /etc/init.d/autofs
自动挂载与漫游用户 1、 autofs yum install autofs vim /etc/auto.master /mnt /etc/auto.aa vim /etc/auto.aa aa
来挂载NFS 挂载NFS共享的第三种方法是使用autofs,它使用automount守护进程来管理挂载点,只在文件系统被访问时才动态地挂载。 autofs访问主映射配置文件/etc/auto.master来决定要定义哪些挂载点,然后使用适用于各个挂载点的参数来启动automount守护进程。 autofs是一种服务,要启动这项服务,在shell提示下键入以下命令: sudo /sbin/service autofs restart 要查看活跃的挂载点,在shell提示下键入以下命令: sudo /sbin/service autofs status 如果在autofs运行时修改了/etc/auto.master配置文件,则必须在shell提示下键入以下命令来通知automount守护进程重新载入配置文件 : sudo /sbin/service autofs reload df命令查看是否挂载成功: sudo df 取消挂载的命令如下: sudo umount /mnt/root_nfs
/disk1s4 on /private/var/vm (apfs, local, noexec, journaled, noatime, nobrowse) map -hosts on /net (autofs , nosuid, automounted, nobrowse) map auto_home on /home (autofs, automounted, nobrowse) /dev/disk2s2
guest2001 guest2001的主目录自动挂载于本地目录/rhome 的/rhome/guest2001 目录下 每个用户必须对其主目录拥有读写权限,guest2001 密码为 tangkai 考试要求安装 autofs 软件包 yum –y install autofs 安装aufofs软件包 vim /etc/auto.master 编写要挂载的目录 mkdir /rhome 创建guset2001用户的家目录 systemctl restart autofs 重启autofs服务 systemctl enable autofs 下次开机启动autofs服务 linux7.0 NTP客户端连接 配置你的系统,