한국어
Linux Programming
 

NFS를 통해 파일시스템 공유

makersweb 2018.03.05 22:40 조회 수 : 1128

네트워크상에서 host작업 디렉터리를 client쪽에서 mount하여 마치 로컬 디렉터리, 파일처럼 사용할 수 있는 시스템으로 임베디드 개발환경에서 많이 사용된다.

 

NFS구축의 순서는 다음과 같다.

 

Host 설정

 

네트워크 환경설정 파일을 열어 다음과 같이 host IP를 설정한다.

@ubuntu:/$ sudo vim /etc/network/interfaces

# interfaces(5) file used by ifup(8) and ifdown(8)

auto lo

iface lo inet loopback

 

auto eth0

iface eth0 inet static

address 192.168.0.106

 

apt-get패키지를 업데이트하고 필요한 패키지들을 설치한다.

@ubuntu:/$ sudo apt-get update

@ubuntu:/$ sudo apt-get install nfs-kernel-server tftpd tftp dhcp3-server

 

host에서 작업디렉터리를 생성한다

@ubuntu:/$ sudo mkdir /opt/nfs

 

nfs환경설정파일을 열어 설정 내용을 추가한다.

@ubuntu:/$ sudo vim /etc/exports

/opt/nfs *(rw,sync,no_root_squash)

 

NFS데몬을 restart시킨다.

@ubuntu:/$ sudo /etc/init.d/nfs-kernel-server restart

 

NFS서비스 확인은 다음과 같은 방법으로 할 수 있다.

 

@ubuntu:/$ netstat –a | grep nfs

 

Client 설정

 

먼저 아래와 같이 업데이트를 진행한다.

@arm:/$ sudo apt-get update

 

NFS사용을 위해서 관련 패키지를 설치한다.

@arm:/$ sudo apt-get install nfs-common

 

Client에서 mount 포인트 디렉터리 생성한다.

@arm:/$ sudo mkdir /mnt/nfs

 

mount명령으로 mount포인트 디렉터리에 host작업 디렉터리를 mount한다.

@arm:/$ sudo mount -t nfs -o nolock 호스트IP:/opt/nfs /mnt/nfs

 

디렉터리를 확인해보면 host에서 생성한 파일들을 확인할 수 있다.

 

참조 사이트

 

http://elinux.org/TFTP_Boot_and_NFS_Root_Filesystems