Ubuntu 18.04: NFSクライアントのnfs-commonをインストールする

NFSクライアントのnfs-commonをインストールする手順を記載します。

1 nfs-commonのインストール

nfs-commonパッケージをインストールします。

$ sudo apt install -y nfs-common

2 mount.nfsでマウント

mount.nfsコマンドで/mntディレクトリへマウントします。

$ NFS_SERVER=nfs-server.hiroom2.com
$ NFS_DIR=/srv/nfsshare
$ sudo mount -t nfs ${NFS_SERVER}:${NFS_DIR} /mnt

3 起動時にマウント

他のファイルシステムと同様に/etc/fstabに追記します。ネットワーク初期化前にマウントするのを防ぐために、_netdevをオプションを指定する必要があります。x-systemd.automountにマウントさせるために、x-systemd.automountをオプションに指定する必要があります。

$ cat <<EOF | sudo tee -a /etc/fstab
${NFS_SERVER}:${NFS_DIR}/nfsshare /mnt nfs _netdev,x-systemd.automount 0 0
EOF