nfs (nfs-kernel-server) / fstab / autofs
日経linuxよりこっちのほうがわかりやすいぞ
http://blog.goo.ne.jp/minoh_edubuntu/e/dab5659bebcfe09093d528bff2f70165
とか
http://masahir0y.blogspot.jp/2012/12/autofs-rhelcentosubuntu.html
とかね
- サーバ側での作業
*apt-get install nfs-kernel-server
*vi /etc/exports
*exportするディレクトリをchmod 777にする?
*exportfsでチェック
/etc/exportsはこんな感じとする
/export/home 192.168.1.0/24(rw,no_subtree_check)
- クライアント(古典的にfstabで)
root@client-machine:/mnt/server# cat /etc/fstab | tail -1 server-machine:/export/home /mnt/server nfs rw,sync 0 0 root@client-machine:/mnt/server#
- クライアント(autofsで) ただしまだうまくいってない orz
以下、クライアント側で必要な作業
autofsの設定ファイルは
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/default/autofs with new version
あたりが自動生成されますね
auto.masterが一番えらい設定ファイルだとして、
.netは クライアント側に/netを想定したテンプレ?
hirasawa@client-machine:/net$ cat /etc/auto.master | tail -1 /net -hosts --timeout 60 hirasawa@client-machine:/net$
と一行追加すると
/netディレクトリのしたで
cd server-machine(サーバー名を指定する)と自動的にマウントしてくれ、
アクティビティがなくなると、自動的にアンマウントしてくれる、みたい
ほほぅ
hirasawa@client-machine:/net$ pwd /net hirasawa@client-machine:/net$ ls hirasawa@client-machine:/net$ hirasawa@client-machine:/net$ hirasawa@client-machine:/net$ pwd /net hirasawa@client-machine:/net$ ls hirasawa@client-machine:/net$ cd server-machine hirasawa@client-machine:/net/server-machine$ pwd /net/server-machine hirasawa@client-machine:/net/server-machine$ find . . ./export ./export/home ./export/home/b ./export/home/a hirasawa@client-machine:/net/server-machine$
root@server-machine:/etc# dpkg -l | grep autofs root@server-machine:/etc# root@server-machine:/etc# root@server-machine:/etc# apt-get install autofs パッケージリストを読み込んでいます... 完了 依存関係ツリーを作成しています 状態情報を読み取っています... 完了 以下のパッケージが自動でインストールされましたが、もう必要とされていません: linux-headers-3.8.0-19 linux-headers-3.8.0-19-generic linux-image-3.8.0-19-generic linux-image-extra-3.8.0-19-generic これを削除するには 'apt-get autoremove' を利用してください。 以下のパッケージが新たにインストールされます: autofs アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 0 個。 663 kB のアーカイブを取得する必要があります。 この操作後に追加で 1,527 kB のディスク容量が消費されます。 取得:1 http://jp.archive.ubuntu.com/ubuntu/ raring/main autofs i386 5.0.7-3ubuntu1 [663 kB] 663 kB を 9秒 で取得しました (68.2 kB/s) 以前に未選択のパッケージ autofs を選択しています。 (データベースを読み込んでいます ... 現在 357371 個のファイルとディレクトリがインストールされています。) (.../autofs_5.0.7-3ubuntu1_i386.deb から) autofs を展開しています... ureadahead のトリガを処理しています ... man-db のトリガを処理しています ... autofs (5.0.7-3ubuntu1) を設定しています ... 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/default/autofs with new version autofs start/running, process 7639 ureadahead のトリガを処理しています ... root@server-machine:/etc#