本篇介紹在centos7.9系統中安裝autofs自動掛載nfs
集羣已經部署完成了nfs服務,其導出的共享目錄地址爲:192.168.80.187:/home/export/base
,需求是在node17裏面當用戶登陸時,自動掛載/home/export/base
,用戶的home着陸地址爲/home/export/base/group/user
首先yum -y install autofs
編輯配置文件vim /etc/auto.master
,最後一行添加:/home/export /etc/auto.home
創建配置文件vim /etc/auto.home
,增加內容:base 192.168.80.187:/home/export/base
啓動autofs服務systemctl start autofs && systemctl enable autofs
通過登陸驗證,當切換到用戶時,自動掛載/home/export/base
[root@node18][~]
$ df -h
文件系統 容量 已用 可用 已用% 掛載點
devtmpfs 486M 0 486M 0% /dev
tmpfs 496M 0 496M 0% /dev/shm
tmpfs 496M 6.7M 489M 2% /run
tmpfs 496M 0 496M 0% /sys/fs/cgroup
/dev/sda2 30G 2.1G 28G 8% /
/dev/sda1 497M 124M 373M 25% /boot
192.168.80.186:/opt/hpc 100G 3.0G 97G 3% /opt/hpc
192.168.80.19@tcp:192.168.80.20@tcp:/mylustre 589G 8.3M 559G 1% /online1
tmpfs 100M 0 100M 0% /run/user/0
[root@node18][~]
$ su - liwl
上一次登錄:五 11月 25 08:37:31 CST 2022從 192.168.80.1pts/0 上
[liwl@node18][~/online1]
$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 486M 0 486M 0% /dev
tmpfs 496M 0 496M 0% /dev/shm
tmpfs 496M 6.7M 489M 2% /run
tmpfs 496M 0 496M 0% /sys/fs/cgroup
/dev/sda2 30G 2.1G 28G 8% /
/dev/sda1 497M 124M 373M 25% /boot
192.168.80.186:/opt/hpc 100G 3.0G 97G 3% /opt/hpc
192.168.80.19@tcp:192.168.80.20@tcp:/mylustre 589G 8.3M 559G 1% /online1
tmpfs 100M 0 100M 0% /run/user/0
192.168.80.187:/home/export/base 100G 33M 100G 1% /home/export/base
[liwl@node18][~]
$ pwd
/home/export/base/sysadm/liwl