mount.nfs: access denied by server while mounting

개요

임베디드 개발에 필수적인 nfs가 검색해보면 여러가지 나오는데 다 해보고도 mount가 안될때가 있습니다. (오늘 제가 그 상황에 처했습니다.)

nfs서버 설정을 하고 임베디드 보드에서 부팅해보았지만 반응이 없어, 다른 리눅스 PC에서 nfs mount를 해보니 다음과 같은 에러 메시지가 발생합니다.

$ sudo mount 192.168.1.201:/nfsroot ./mnt/
mount.nfs: access denied by server while mounting 192.168.1.201:/nfsroot


배경지식

보통 이럴때는 nfs version 차이입니다. nfs version의 차이는 아래에 자세히 기술되어있습니다. (몰라도 되지만 알아두면 좋습니다.)

NFS version 3 (NFSv3)

  • Has support for safe asynchronous writes and is more robust at error handling than the previous NFSv2
  • Supports 64-bit file sizes and offsets, allowing clients to access more than 2 GB of file data.

NFS version 4 (NFSv4)

  • Works through firewalls and on the Internet
  • No longer requires rpcbind service
  • Supports Access Control Lists (ACLs)
  • Utilizes stateful operations.


원인

Ubuntu 20.04 에서 nfs-kernel-server 를 설치했더니 nfs version이 3으로 설치되었나봅니다. 다른 리눅스 PC에서 다음과 테스트해보면 알 수 있습니다.

$ sudo mount -t nfs -o nfsvers=4 192.168.1.201:/nfsroot ./mnt/
mount.nfs: access denied by server while mounting 192.168.1.201:/nfsroot
$ sudo mount -t nfs -o nfsvers=3  192.168.1.201:/nfsroot ./mnt/

Ubuntu 12.04 서버에서는 별도의 nfs version 정보를 넣지 않아도 잘 되었는데, 뭔가 바뀌었나봅니다.


해결

uboot에서 nfs 버전정보를 넣는 문법은 다음과 같습니다.

nfsroot=[<server-ip>:]<root-dir>,nfsvers=3

출처 : Using NFSv3 for NFS Root Filesystem 


제 임베디드 보드에서 아래와 같이 수정 후 잘 동작합니다.

setenv bootargs root=/dev/nfs rw macaddr={$ethaddr} nfsroot=192.168.1.1:/nfsroot/,nfsvers=3



댓글

이 블로그의 인기 게시물

WSL2 Ubuntu 20.04 및 네트워크 설정

리눅스 멀티코어를 사용하는 tar 압축/해제

git pull 을 했더니 branch가 갈라지는 경우