autofs 自动挂载

将 172.16.30.254://mnt/public 挂载到 /aaa/auto, 一开始不用创建/aaa/auto, 等访问时自动创建

[root@station ~]# yum install -y autofs.x86_64 

[root@station ~]# vim /etc/auto.master
添加     /aaa    /etc/auto.misc          ------ 访问/aaa时自动读取配置文件

[root@station ~]# vim /etc/auto.misc 

添加 auto            -fstype=nfs             172.16.30.254://mnt/public         ------ 将文件夹挂载到auto

[root@station ~]# systemctl enable autofs.service          ------ 启动autofs 服务
ln -s '/usr/lib/systemd/system/autofs.service' '/etc/systemd/system/multi-user.target.wants/autofs.service'
[root@station ~]# systemctl start autofs.service 
[root@station ~]# ls  ----- 一开始没有aaa目录
anaconda-ks.cfg  Desktop  Documents  Downloads  initial-setup-ks.cfg  Music  passwd  Pictures  Public  Templates  Videos
[root@station ~]# cd /aaa      ----- 访问时自动创建
[root@station aaa]# ls           ------- 还没有auto
[root@station aaa]# cd auto    ----- 访问时自动创建并挂载
[root@station auto]# ls           ------- 挂载的文件
ddd  mmm  test_public_file
 


 

你可能感兴趣的:(linux)