mac OSからubuntu 18.04 LTSにNFSマウントする際の手順は次の通りになります。
Ubuntu側の設定
まずubuntu側にNFSサーバーを構築するために、必要なパッケージのインストールを行います。
1 |
$ sudo apt install -y nfs-kernel-server |
続いて、設定ファイルにマウントさせる場所、接続許可をするアドレス範囲、接続内容を記述します。
/etc/exportsの末尾に
1 |
/nfs 10.0.1.0/24(rw,no_root_squash,no_subtree_check) |
と書きます。意味は次の通りです。
- /nfsはNFSの設定
- 192.168.0.0/24 は接続を許可するクライアントのPアドレスの範囲指定
- rwはクライアントの読み書きの許可
- no_root_squashはクライアント側の root からのファイルの読み出し/書き込み要求を root からの要求として扱うという意味
- no_subtree_checkはクライアントからの要求されたファイルが公開ディレクトリに含まれるかどうかチェックしないという意味
最後に次のコマンドでNFSサーバーを再起動します。
1 |
$ sudo systemctl restart nfs-kernel-server |
mac側の設定
マウントしたい場所を作成します。
1 |
$ sudo mkdir /Volumes/NFS |
次にubuntu側のディスクをマウントします。
1 |
$ sudo mount_nfs -P 192.168.0.2:/nfs /Volumes/NFS |
- -Pはresvportオプション。予約されたポート番号を使ってマウントする方法です。
resvport
Use a reserved socket port number. This is useful for mounting
servers that require clients to use a reserved port number on the
mistaken belief that this makes NFS more secure. (For the rare
case where the client has a trusted root account but untrustwor-
thy users and the network cables are in secure areas this does
help, but for normal desktop clients this does not apply.)
- 192.168.0.2:/nfs はubuntu側のIPアドレスとマウント先のパス
- Volumes/NFSはmac側のどこにマウントするかのパス
これでubuntu側のディスクをマウントして、mac側で作業をすることができるようになります。