debian woody における、NFS と Autofs の覚え書きです。
1.NFS Serverのインストール
NFS ServerはNFS Clientに対し、ディレクトリを公開します。バックアップなどに活用すると便利です。インストールは簡単です。
# apt-get install nfs-kernel-server
さらに、modconfコマンドで、kernel/fs/nfsd を有効にします。
2.exports
どのディレクトリを外部に公開するかを記載します。
# vi /etc/exports ----- /home 192.168.1.102(rw,no_root_squash) -----
このマシンのホームディレクトリを、192.168.1.102マシンに対し、読み書き自由で公開するという意味になります。詳しくは、man exportsで。
3.NFS Clientの設定
いちいちマウントしてもいいのですが、fstabに書いてしまうのがとりあえず簡単です。起動時に自動的にマウントされます。
192.168.1.101:/usr/home /mnt nfs rw 0 0
4.autofs
もちろん、このままでもでいいのですが、Serverがダウンしたときや、ネットワークが切れた時にClientも道連れです。それを防ぐのが、オートマウントソフトの autofsです。これはアクセスが合ったときに自動的にマウントしてくれます。その代わり、アクセスしないと、ls しても見えません。
まずインストールします。
# apt-get install autofs
/etc/auto.master と /etc/auto.misc を確認します。
auto.master ----- /var/autofs/misc /etc/auto.misc timeout=30 /var/autofs/net /etc/auto.net -----
/var/autofs/misc がマウントポイントで、それに対応するmapが、/etc/auto.misc です。timeout=30 は、アクセスがない場合に30秒後にアンマウントするように、付け足したものです。2行目の意味はよくわかりません。
auto.misc ----- # $Id: auto.misc,v 1.2 1997/10/06 21:52:04 hpa Exp $ # This is an automounter map and it has the following format # key [ -mount-options-separated-by-comma ] location # Details may be found in the autofs(5) manpage #kernel -ro ftp.kernel.org:/pub/linux #boot -fstype=ext2 :/dev/hda1 #removable -fstype=ext2,sync,nodev,nosuid :/dev/hdd cd -fstype=iso9660,ro,sync,nodev,nosuid :/dev/cdrom fd -fstype=auto,sync,nodev,nosuid :/dev/fd0 orca1 -rw 192.168.1.101:/home/orca -----
cdrom が /var/auto/misc/cd に、floppy が /var/auto/misc/fd にマウントされます。また、NFS Server の192.168.1.101マシンの/home/orcaが、/var/auto/misc/orca1 にマウントされます。リンクをはると便利でしょう。
# ln -s /var/autofs/misc/cd /cdrom # ln -s /var/autofs/misc/fd /floppy # ln -s /var/autofs/misc/orca1 /mnt/orca1