[Linux]NFS 공유 디렉터리 자동 마운팅하기
automount는 사용자가 파일 시스템(로컬 디렉터리)에 접근할 때 필요한 원격 파일 시스템(예, NFS서버의 공유 디렉터리)을 자동으로 마운트하도록 도와주는 유틸리티입니다. “원격 파일시스템을 마운팅하기(NFS)” 글에서 설정한 환경을 사용하여 automount 서비스로 자동 마운팅하는 절차를 알아보겠습니다.
- NFS서버(192.168.56.101)의 export된 정보 확인(공유 디렉터리)
[root@rocky9u2 ~]# showmount -e 192.168.56.101Export list for 192.168.56.101: /shared 192.168.56.0/24
- automount 데몬 패키지 설치 및 설치 파일 확인
dnf -y install autofs dnf repoquery -l autofs
- 마운팅 포인트 생성
mkdir /sharednfs
- automount 마스터 파일에 NFS 자동 마운팅 파일 정보 등록
[root@rocky9u2 ~]# vi /etc/auto.master#add to the end /- /etc/auto.nfs
- NFS 자동 마운팅 파일 설정
[root@rocky9u2 ~]# vi /etc/auto.nfs#Mounting_point Options NFS_server:/shared_directory /sharednfs -fstype=nfs,rw,soft,intr 192.168.56.101:/shared
- automount 서비스 실행
systemctl enable --now autofs.service
- /sharednfs 디렉터리로 이동 후 자동 마운팅 결과 확인
[root@rocky9u2 ~]# cd /sharednfs [root@rocky9u2 sharednfs]# df -hTFilesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 4.0M 0 4.0M 0% /dev tmpfs tmpfs 889M 0 889M 0% /dev/shm tmpfs tmpfs 356M 5.6M 351M 2% /run /dev/mapper/rl-root xfs 27G 4.9G 23G 18% / /dev/sda1 xfs 1014M 292M 723M 29% /boot tmpfs tmpfs 178M 92K 178M 1% /run/user/0 192.168.56.101:/shared nfs4 22G 4.5G 18G 21% /sharednfs