これは日々の作業を通して学んだことや毎日の生活で気づいたことをを記録しておく備忘録である。
HTML ファイル生成日時: 2024/11/21 17:40:55.112 (台灣標準時)
NetBSD だと amd を使うと、いちいち root にならなくても、必要なときに必 要なディスクを NFS マウントしてくれるようにすることができる。 Debian だと autofs がその役割を果たしてくれるようなので、その設定方法を記録し ておく。
まず、 root になって、 autofs のインストールを行う。 apt コマンドを使 えば簡便である。
# apt search autofs Sorting... Done Full Text Search... Done afuse/stable 0.4.1-1+b3 amd64 automounting file system implemented in user-space using FUSE autodir/stable 0.99.9-10+b1 amd64 Automatically creates home and group directories for LDAP/NIS/SQL/local accounts autofs/stable 5.1.2-4 amd64 kernel-based automounter for Linux autofs-hesiod/stable 5.1.2-4 amd64 Hesiod map support for autofs autofs-ldap/stable 5.1.2-4 amd64 LDAP map support for autofs fusiondirectory-plugin-autofs/stable 1.2.3-4+deb10u1 all autofs plugin for FusionDirectory fusiondirectory-plugin-autofs-schema/stable 1.2.3-4+deb10u1 all LDAP schema for FusionDirectory autofs plugin obexfs/stable 0.11-2+b1 amd64 mount filesystem of ObexFTP capable devices # apt install autofs Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: linux-image-4.19.0-11-amd64 linux-image-4.19.0-12-amd64 Use 'apt autoremove' to remove them. The following additional packages will be installed: keyutils libnfsidmap2 libtirpc-common libtirpc3 nfs-common rpcbind Suggested packages: open-iscsi watchdog The following NEW packages will be installed: autofs keyutils libnfsidmap2 libtirpc-common libtirpc3 nfs-common rpcbind 0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded. Need to get 973 kB of archives. After this operation, 4,553 kB of additional disk space will be used. Do you want to continue? [Y/n] Get:1 http://deb.debian.org/debian buster/main amd64 autofs amd64 5.1.2-4 [501 kB] Get:2 http://deb.debian.org/debian buster/main amd64 keyutils amd64 1.6-6 [51.7 kB] Get:3 http://deb.debian.org/debian buster/main amd64 libnfsidmap2 amd64 0.25-5.1 [32.0 kB] Get:4 http://deb.debian.org/debian buster/main amd64 libtirpc-common all 1.1.4-0.4 [16.7 kB] Get:5 http://deb.debian.org/debian buster/main amd64 libtirpc3 amd64 1.1.4-0.4 [93.5 kB] Get:6 http://deb.debian.org/debian buster/main amd64 rpcbind amd64 1.2.5-0.3+deb10u1 [47.1 kB] Get:7 http://deb.debian.org/debian buster/main amd64 nfs-common amd64 1:1.3.4-2.5+deb10u1 [231 kB] Fetched 973 kB in 1s (774 kB/s) Selecting previously unselected package autofs. (Reading database ... 100058 files and directories currently installed.) Preparing to unpack .../0-autofs_5.1.2-4_amd64.deb ... Unpacking autofs (5.1.2-4) ... Selecting previously unselected package keyutils. Preparing to unpack .../1-keyutils_1.6-6_amd64.deb ... Unpacking keyutils (1.6-6) ... Selecting previously unselected package libnfsidmap2:amd64. Preparing to unpack .../2-libnfsidmap2_0.25-5.1_amd64.deb ... Unpacking libnfsidmap2:amd64 (0.25-5.1) ... Selecting previously unselected package libtirpc-common. Preparing to unpack .../3-libtirpc-common_1.1.4-0.4_all.deb ... Unpacking libtirpc-common (1.1.4-0.4) ... Selecting previously unselected package libtirpc3:amd64. Preparing to unpack .../4-libtirpc3_1.1.4-0.4_amd64.deb ... Unpacking libtirpc3:amd64 (1.1.4-0.4) ... Selecting previously unselected package rpcbind. Preparing to unpack .../5-rpcbind_1.2.5-0.3+deb10u1_amd64.deb ... Unpacking rpcbind (1.2.5-0.3+deb10u1) ... Selecting previously unselected package nfs-common. Preparing to unpack .../6-nfs-common_1%3a1.3.4-2.5+deb10u1_amd64.deb ... Unpacking nfs-common (1:1.3.4-2.5+deb10u1) ... Setting up libtirpc-common (1.1.4-0.4) ... Setting up keyutils (1.6-6) ... Setting up libnfsidmap2:amd64 (0.25-5.1) ... Setting up autofs (5.1.2-4) ... Creating config file /etc/auto.master with new version Creating config file /etc/auto.net with new version Creating config file /etc/auto.misc with new version Creating config file /etc/auto.smb with new version Creating config file /etc/autofs.conf with new version Creating config file /etc/default/autofs with new version Created symlink /etc/systemd/system/multi-user.target.wants/autofs.service → /lib/systemd/system/autofs.service. update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults Setting up libtirpc3:amd64 (1.1.4-0.4) ... Setting up rpcbind (1.2.5-0.3+deb10u1) ... 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.5+deb10u1) ... Creating config file /etc/idmapd.conf with new version Adding system user `statd' (UID 110) ... Adding new user `statd' (UID 110) 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 (241-7~deb10u6) ... Processing triggers for man-db (2.8.5-2) ... Processing triggers for libc-bin (2.28-10) ...
autofs がインストールされると、 /etc 以下に必要なファイルがコピーされ る。
# cd /etc # ls -l auto* -rw-r--r-- 1 root root 13354 Jul 9 2018 autofs.conf -rw-r--r-- 1 root root 797 Jul 9 2018 auto.master -rw-r--r-- 1 root root 524 Jul 9 2018 auto.misc -rwxr-xr-x 1 root root 1039 Jul 9 2018 auto.net -rwxr-xr-x 1 root root 2191 Jul 9 2018 auto.smb auto.master.d: total 0
設定ファイルに必要な変更を加える。
# cd /etc # cp -pi auto.master auto.master.original # vi auto.master # diff auto.master.original auto.master 13c13 < #/net -hosts --- > /net -hosts
必要なディレクトリを作成する。
# mkdir /net
以下のようにして autofs を起動する。
# /etc/init.d/autofs Usage: /etc/init.d/autofs {start|forcestart|stop|restart|forcerestart|reload|force-reload|status} # /etc/init.d/autofs start [ ok ] Starting autofs (via systemctl): autofs.service.
これで、 NFS サーバのディレクトリが見えるようになる。ホスト名 nfs_server の /tmp を読み書きしたい場合には、 /net/nfs_server/tmp を見 てみれば、自動的に NFS マウントされる。