


RHEL 8にNFSサーバをインストールしました。
今回はUbuntu 20にNFS Clientをインストールして共有フォルダをマウントしてみます。
環境
・Ubuntu 20.04.3 LTS
・Kernel 5.11.0-43-generic
- NFS Clientのインストール
- 共有フォルダの確認
- 共有フォルダのマウント
- アンマウント
- 起動時にマウント
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
rootlinks@Ubuntu20:~$ sudo apt install nfs-common Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: libfprint-2-tod1 libllvm10 Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: keyutils libevent-2.1-7 libnfsidmap2 libtirpc-common libtirpc3 rpcbind Suggested packages: open-iscsi watchdog The following NEW packages will be installed: keyutils libevent-2.1-7 libnfsidmap2 libtirpc-common libtirpc3 nfs-common rpcbind 0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded. Need to get 542 kB of archives. After this operation, 1922 kB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 libtirpc-common all 1.2.5-1 [7632 B] Get:2 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 libtirpc3 amd64 1.2.5-1 [77.2 kB] Get:3 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 rpcbind amd64 1.2.5-8 [42.8 kB] Get:4 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 keyutils amd64 1.6-6ubuntu1 [45.0 kB] Get:5 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 libevent-2.1-7 amd64 2.1.11-stable-1 [138 kB] Get:6 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 libnfsidmap2 amd64 0.25-5.1ubuntu1 [27.9 kB] Get:7 http://jp.archive.ubuntu.com/ubuntu focal-updates/main amd64 nfs-common amd64 1:1.3.4-2.5ubuntu3.4 [204 kB] Fetched 542 kB in 0s (4393 kB/s) Selecting previously unselected package libtirpc-common. (Reading database ... 165469 files and directories currently installed.) Preparing to unpack .../0-libtirpc-common_1.2.5-1_all.deb ... Unpacking libtirpc-common (1.2.5-1) ... Selecting previously unselected package libtirpc3:amd64. Preparing to unpack .../1-libtirpc3_1.2.5-1_amd64.deb ... Unpacking libtirpc3:amd64 (1.2.5-1) ... Selecting previously unselected package rpcbind. Preparing to unpack .../2-rpcbind_1.2.5-8_amd64.deb ... Unpacking rpcbind (1.2.5-8) ... Selecting previously unselected package keyutils. Preparing to unpack .../3-keyutils_1.6-6ubuntu1_amd64.deb ... Unpacking keyutils (1.6-6ubuntu1) ... Selecting previously unselected package libevent-2.1-7:amd64. Preparing to unpack .../4-libevent-2.1-7_2.1.11-stable-1_amd64.deb ... Unpacking libevent-2.1-7:amd64 (2.1.11-stable-1) ... Selecting previously unselected package libnfsidmap2:amd64. Preparing to unpack .../5-libnfsidmap2_0.25-5.1ubuntu1_amd64.deb ... Unpacking libnfsidmap2:amd64 (0.25-5.1ubuntu1) ... Selecting previously unselected package nfs-common. Preparing to unpack .../6-nfs-common_1%3a1.3.4-2.5ubuntu3.4_amd64.deb ... Unpacking nfs-common (1:1.3.4-2.5ubuntu3.4) ... Setting up libtirpc-common (1.2.5-1) ... Setting up libevent-2.1-7:amd64 (2.1.11-stable-1) ... Setting up keyutils (1.6-6ubuntu1) ... Setting up libnfsidmap2:amd64 (0.25-5.1ubuntu1) ... Setting up libtirpc3:amd64 (1.2.5-1) ... Setting up rpcbind (1.2.5-8) ... Created symlink /etc/systemd/system/multi-user.target.wants/rpcbind.service -> /lib/systemd/system/rpcbind.service. Created symlink /etc/systemd/system/sockets.target.wants/rpcbind.socket -> /lib/systemd/system/rpcbind.socket. Setting up nfs-common (1:1.3.4-2.5ubuntu3.4) ... Creating config file /etc/idmapd.conf with new version Adding system user `statd' (UID 128) ... Adding new user `statd' (UID 128) with group `nogroup' ... Not creating home directory `/var/lib/nfs'. Created symlink /etc/systemd/system/multi-user.target.wants/nfs-client.target -> /lib/systemd/system/nfs-client.target. Created symlink /etc/systemd/system/remote-fs.target.wants/nfs-client.target -> /lib/systemd/system/nfs-client.target. nfs-utils.service is a disabled or a static unit, not starting it. Processing triggers for systemd (245.4-4ubuntu3.13) ... Processing triggers for man-db (2.9.1-1) ... Processing triggers for libc-bin (2.31-0ubuntu9.2) ... |
showmountコマンドでNFS Serverが提供している共有フォルダを確認してみます。
1 2 3 |
rootlinks@Ubuntu20:~$ showmount -e 192.168.1.1 Export list for 192.168.1.1: /share 192.168.1.0/24 |
/mntにマウントしてみます。マウントできました。
1 2 3 4 |
rootlinks@Ubuntu20:~$ sudo mount -t nfs 192.168.1.1:/share /mnt rootlinks@Ubuntu20:~$ df -Th | grep nfs 192.168.1.1:/share nfs4 50G 6.9G 44G 14% /mnt |
マウントを解除します。
1 2 |
rootlinks@Ubuntu20:~$ sudo umount /mnt rootlinks@Ubuntu20:~$ df -Th | grep nfs |
/etc/fstabに記述してクライアント起動時に共有フォルダ/shareを/shareマウントします。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
rootlinks@Ubuntu20:~$ sudo mkdir /share rootlinks@Ubuntu20:~$ sudo cat /etc/fstab # /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> # / was on /dev/nvme0n1p5 during installation UUID=5ffb143c-b6d7-43e5-af4b-86f1cdbdfe45 / ext4 errors=remount-ro 0 1 # /boot/efi was on /dev/nvme0n1p1 during installation UUID=58CA-888A /boot/efi vfat umask=0077 0 1 /swapfile none swap sw 0 0 rootlinks@Ubuntu20:~$ sudo vi /etc/fstab rootlinks@Ubuntu20:~$ sudo grep nfs /etc/fstab 192.168.1.1:/share /share nfs rw,hard,intr,rsize=8192,wsize=8192,timeo=14 0 0 |
再起動後にログインすると/shareにマウントされていました。フォルダの作成、削除もできました。
1 2 3 4 5 6 7 8 9 |
rootlinks@Ubuntu20:~$ sudo df -Th | grep nfs 192.168.10.22:/share nfs4 50G 6.9G 44G 14% /share rootlinks@Ubuntu20:~$ ls -la /share 合計 4 drwxrwxrwx 4 root root 39 12月 27 2021 . drwxr-xr-x 21 root root 4096 12月 26 19:57 .. drwx------ 4 rootlinks rootlinks 31 12月 27 2021 .Trash-1000 drwxrwxr-x 2 rootlinks rootlinks 6 12月 27 2021 user01 |