본문 바로가기
OS 운영체제/LINUX

exportfs (nfs을 export/unexport하는 명령어)

by yororing 2024. 5. 2.

01 exportfs란

1. 정의

  • NFS (Network File System) 파일 시스템을 내보내는(export) 테이블을 관리(maintain)하는 명령어
  • 로컬 디렉토리를 NFS 클라이언트가 마운트할 수 있게 함

2. 문법

/usr/sbin/exportfs [-avi] [-o options,..] [client:/path ..]
/usr/sbin/exportfs -r [-v]
/usr/sbin/exportfs [-av] -u [client:/path ..]
/usr/sbin/exportfs [-v]
/usr/sbin/exportfs -f

 

3. 설명

  • An NFS server maintains a table of local physical file systems that are accessible to NFS clients.
  • Each file system in this table is referred to as an exported file system (or 'export').
  • This table (called Master Export Table) is kept in a file name etab ( /var/lib/nfs/etab)
  • The exportfs command maintains the current table of exports for the NFS server.
  • Master export table (etab)
    • master export table is kept in a file named /var/lib/nfs/etab
    • This file is read by rpc.mountd when a client sends an NFS MOUNT request
    • Normally the master export table is initialized with the contents of /etc/exports by invoking exportfs -a (참조: 02 exportfs 사용)
    • However, a system administrator can choose to add or delete exports without modifying /etc/exports by using the exportfs command
  • exportfs and its partner program rpc.mountd work in one of two modes:
mode 설명
legacy mode
(in Linux kernel 2.4 and earlier versions)
- exports which identify a specific host, rather than a subnet or netgroup, are entered directly into the kernel's export table, as well as being written to /var/lib/nfs/etab
- Further, exports listed in /var/lib/nfs/rmtab which match a non host-specific export request will cause an appropriate export entry for the host given in rmtab to be added to the kernel's export table
new mode
(in Linux kernel 2.6 and later)
- provides nfsd virtual filesystem (which has been mounted at /proc/fs/nfsd 또는 /proc/fs/nsf)
- if virtual filesystem is not mounted on 2.6 kernels, the legacy mode is used
- does not give any information to the kernel, but provides it only to rpc.mountd through the /var/lib/nfs/etab file
- rpc.mountd then manages kernel requests for info about exports, as needed

4. 옵션

종류 설명
-a 모든 디렉토리를 export 또는 unexport
-o options, ... export 옵션 리스트를 지정 (exports와 같이)
-i /etc/exports 파일 무시. 옵션 기본값과 명령줄에서 사용된 옵션들만 실행
-r - /var/lib/nfs/etab/etc/exports 파일들을 동기화하며 모든 디렉토리를 다시 export (reexport)
- removes entries in /var/lib/nfs/etab which have been deleted from /etc/exports
- removes any entries from the kernel export table which are no longer valid
-u 하나 이상의 디렉토리를 unexport
-f - if /proc/fs/nfsd or /proc/fs/nfs is mounted, flush everything out of the kernel's export table
- fresh entries for active clients are added to the kernel's export table by rpc.mountd when they make their next NFS mount request
-v - verbose 모드
- exporting 또는 unexporting 시 무슨 일이 일어나는지 출력
- current export list 출력 시, list of export options 또한 출

02 exportfs 사용

1. 디렉토리 export

1) 모든 디렉토리 export

# exportfs -a
  • all exports listed in /etc/exports are added to /var/lib/nfs/etab
  • the kernel's export table is also updated as needed

2. 디렉토리 unexport

1) 모든 디렉토리 unexport

# exportfs -ua
  • all entries listed in /var/lib/nfs/etab are removed from the kernel export tables, and the file is cleared
  • effectively shuts down all NFS activity

참조

  1. https://linux.die.net/man/8/exportfs 
  2.  
  3.