Lesson 5.3: Configure autofs


Autofs

Although network devices can be mounted at boot using /etc/fstab, mounts configured this way consume additional resources because they are always mounted and therefore don't scale well. autofs works with the kernel to mount drives only when they are accessed, improving performance.

# Installing required package
[root@client ~]# yum -y install autofs 
 
# Configure autofs configuration file 
[root@client ~]# vim /etc/auto.master
[root@client ~]# tail -1 /etc/auto.master
/remote/data		/etc/auto.nfs		--timeout=300
 
# Create another file with filename (auto.<something>) and write the folder and mount 
[root@client ~]# vim /etc/auto.nfs 
[root@client ~]# cat /etc/auto.nfs 
support		-rw,sync	192.168.205.100:/pis/support
 
# Restart autofs service
[root@client ~]# systemctl restart autofs 
# Support Mount has not been shown, as it is not used currently
[root@client ~]# df -h 
Filesystem                        Size  Used Avail Use% Mounted on
devtmpfs                          4.0M     0  4.0M   0% /dev
tmpfs                             1.8G     0  1.8G   0% /dev/shm
tmpfs                             717M  9.5M  708M   2% /run
efivarfs                          256K   33K  224K  13% /sys/firmware/efi/efivars
/dev/mapper/cs-root                17G  5.1G   12G  31% /
/dev/nvme0n2p1                    960M   39M  922M   5% /ribik
/dev/nvme0n1p2                    960M  483M  478M  51% /boot
/dev/nvme0n1p1                    599M  7.0M  592M   2% /boot/efi
tmpfs                             1.0M     0  1.0M   0% /run/stratisd/ns_mounts
tmpfs                             359M   92K  359M   1% /run/user/0
192.168.205.100:/pis/training      17G   14G  3.4G  80% /mnt/nfsdata/nfstraining
192.168.205.100:/pis/development   17G   14G  3.4G  80% /mnt/nfsdata/nfsdevelopment
 
[root@client ~]# cd /remote/data/
[root@client data]# ls
[root@client data]# # Does not show folder when ls , but can do cd 
[root@client data]# cd support 
 
# Now as support folder is used , it shows mounted on df -h
[root@client support]# df -h 
Filesystem                        Size  Used Avail Use% Mounted on
devtmpfs                          4.0M     0  4.0M   0% /dev
tmpfs                             1.8G     0  1.8G   0% /dev/shm
tmpfs                             717M  9.5M  708M   2% /run
efivarfs                          256K   33K  224K  13% /sys/firmware/efi/efivars
/dev/mapper/cs-root                17G  5.1G   12G  31% /
/dev/nvme0n2p1                    960M   39M  922M   5% /ribik
/dev/nvme0n1p2                    960M  483M  478M  51% /boot
/dev/nvme0n1p1                    599M  7.0M  592M   2% /boot/efi
tmpfs                             1.0M     0  1.0M   0% /run/stratisd/ns_mounts
tmpfs                             359M   92K  359M   1% /run/user/0
192.168.205.100:/pis/training      17G   14G  3.4G  80% /mnt/nfsdata/nfstraining
192.168.205.100:/pis/development   17G   14G  3.4G  80% /mnt/nfsdata/nfsdevelopment
192.168.205.100:/pis/support       17G   14G  3.4G  80% /remote/data/support
 
All systems normal

© 2025 2023 Sanjeeb KC. All rights reserved.