Linux:配置客户端默认autofs服务

Linux:配置客户端默认autofs服务

安装autofs软件

[root@server200 ~]# dnf install autofs -y

开启并设置开机自启autofs服务

[root@server200 ~]# systemctl enable --now autofs

访问默认autofs挂载机制

当autofs启动后系统默认会在/net目录中访问nfs服务器

[root@server200 ~]# cd /net/172.25.254.100
[root@server200 ~]# ls
data1	data2	data3

设定动态卸载时间

默认autofs在发现限制资源闲置后会在300秒自动卸载,此设定可以自行设定

[root@server200 ~]# vim /etc/autofs.conf

*** ***
timeout = 5
*** ***

[root@server200 ~]# systemctl restart autofs

总体实现

[root@server200 ~]# dnf install autofs
[root@server200 ~]# systemctl enable --now autofs.service
Created symlink /etc/systemd/system/multi-user.target.wants/autofs.servic                                             e → /usr/lib/systemd/system/autofs.service.

[root@server200 ~]# df
Filesystem            1K-blocks    Used Available Use% Mounted on
devtmpfs                   4096       0      4096   0% /dev
tmpfs                    991084       0    991084   0% /dev/shm
tmpfs                    396436    6184    390252   2% /run
/dev/mapper/rhel-root  16353280 4218532  12134748  26% /
/dev/nvme0n1p1           404128  240060    164068  60% /boot
/dev/sr0                8847936 8847936         0 100% /rhel9
tmpfs                    198216      52    198164   1% /run/user/42
 

[root@server200 ~]# ls /net/172.25.254.100
data  timinglee
[root@server200 ~]# cd /net/172.25.254.100
[root@server200 172.25.254.100]# ls
data  timinglee
[root@server200 172.25.254.100]# cd data/
[root@server200 data]# ls
dir1
[root@server200 data]# cd dir1/
[root@server200 dir1]# ls
file1  file10  file2  file3  file4  file5

[root@server200 dir1]# df
Filesystem                1K-blocks    Used Available Use% Mounted on
devtmpfs                       4096       0      4096   0% /dev
tmpfs                        991084       0    991084   0% /dev/shm
tmpfs                        396436    6188    390248   2% /run
/dev/mapper/rhel-root      16353280 4218532  12134748  26% /
/dev/nvme0n1p1               404128  240060    164068  60% /boot
/dev/sr0                    8847936 8847936         0 100% /rhel9
tmpfs                        198216      52    198164   1% /run/user/42
tmpfs                        198216      36    198180   1% /run/user/0
172.25.254.100:/data/dir1  16353280 4216576  12136704  26% /net/172.25.254.100/data/dir1
[root@server200 dir1]# cd ~
[root@server200 ~]# df
Filesystem            1K-blocks    Used Available Use% Mounted on
devtmpfs                   4096       0      4096   0% /dev
tmpfs                    991084       0    991084   0% /dev/shm
tmpfs                    396436    6184    390252   2% /run
/dev/mapper/rhel-root  16353280 4218552  12134728  26% /
/dev/nvme0n1p1           404128  240060    164068  60% /boot
/dev/sr0                8847936 8847936         0 100% /rhel9
tmpfs                    198216      52    198164   1% /run/user/42
tmpfs                    198216      36    198180   1% /run/user/0


# 修改自动挂载卸载的时间
[root@server200 ~]# vim /etc/autofs.conf

[ autofs ]
#
# master_map_name - default map name for the master map.
#
#master_map_name = auto.master
#
# timeout - set the default mount timeout in seconds. The internal
#           program default is 10 minutes, but the default installed
#           configuration overrides this and sets the timeout to 5
#           minutes to be consistent with earlier autofs releases.
#
timeout = 5
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值