[Linux]NFS 공유 디렉터리 자동 마운팅하기

automount는 사용자가 파일 시스템(로컬 디렉터리)에 접근할 때 필요한 원격 파일 시스템(예, NFS서버의 공유 디렉터리)을 자동으로 마운트하도록 도와주는 유틸리티입니다. “원격 파일시스템을 마운팅하기(NFS)” 글에서 설정한 환경을 사용하여 automount 서비스로 자동 마운팅하는 절차를 알아보겠습니다.

  1. NFS서버(192.168.56.101)의 export된 정보 확인(공유 디렉터리)
    [root@rocky9u2 ~]# showmount -e 192.168.56.101
    Export list for 192.168.56.101: /shared 192.168.56.0/24
  2. automount 데몬 패키지 설치 및 설치 파일 확인
    dnf -y install autofs
    dnf repoquery -l autofs
    
  3. 마운팅 포인트 생성
    mkdir /sharednfs
    
  4. automount 마스터 파일에 NFS 자동 마운팅 파일 정보 등록
    [root@rocky9u2 ~]# vi /etc/auto.master
    #add to the end /- /etc/auto.nfs
  5. 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
  6. automount 서비스 실행
    systemctl enable --now autofs.service
    
  7. /sharednfs 디렉터리로 이동 후 자동 마운팅 결과 확인
    [root@rocky9u2 ~]# cd /sharednfs [root@rocky9u2 sharednfs]# df -hT
    Filesystem 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

You may also like...

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다