shfs を入れてみる

shfs というのは他のサーバのディレクトリを ssh経由でマウントでき、しかもサーバの方はsshdさえ動いていれば、ほかにデーモンは必要なし、という夢のようなシステム。キタコレ!*1
で shfs を colinux に入れてみることに。

なんかカーネルソースが必要なようなので、まずカーネルソースをとってくる。/usr/srcに展開

 # apt-get install kernel-package
 # cd /usr/src
 # wget http://ring.nihon-u.ac.jp/pub/linux/kernel.org/kernel/v2.6/linux-2.6.10.tar.bz2
 # tar jxf linux-2.6.10.tar.bz2
 # wget http://jaist.dl.sourceforge.net/sourceforge/colinux/colinux-0.6.2.tar.gz
 # tar zxf colinux-0.6.2.tar.gz
 # ln -s linux-2.6.10 linux
 # cd linux
 # patch -p1 < ../colinux-0.6.2/patch/linux
 # cp ../colinux-0.6.2/conf/linux-config .config
 # make dep && make clean
 # cd /usr/src

これでカーネルソースができたはず…?cd ..

shfsをとってくる

 # cd /usr/src
 # apt-get install shfs-source shfs-utils
 # tar jxf shfs.tar.bz2
 # cd linux
 # rm localversion-cooperative # -co- の付加バージョンを消す
 # fakeroot make-kpkg --append-to-version '-co-0.6.2' modules_image
 # cd ..

で、/usr/src に shfs-module-2.6.10-co-0.6.2_0.35-3+10.00.Custom_i386.deb なるファイルができているのでこれをインストール

 # dpkg -i shfs-module-2.6.10-co-0.6.2_0.35-3+10.00.Custom_i386.deb

ということで試してみる

 # shfsmount nazoking@www.example.org /mnt
 nazoking@www.example.org's password: パスワードを入れる
 shfsmount: shfs filesystem not supported by the kernel

orz... カーネルモジュールが…なぜか /lib/modules/2.6.10-co- にインストールされているのであった orz.. 何がいけないんでしょうか。とりあえず

 # /sbin/insmod /lib/modules/2.6.10-co-/shfs/shfs.ko

とした後、shfsmount nazoking@www.example.org /mnt を繰り返すと、うまくマウントできている模様。やったね!
いや、モジュールのインストール先がおかしいし…誰か助けて…(修正:id:secondlifeさんに教えてもらいましたー)

 # shfsmount nazoking@www.example.org /mnt
 nazoking@www.example.org's password: パスワードを入れる

とすると、ls /mnt で、www.example.org の nazoking ホームディレクトリが見えるはず!
これ、ls や cd で普通にいじれるので、つまり、sambaで公開してWindowsで共有フォルダとしてマウントしておくと、Windowsエクスプローラーでリモートサーバのディレクトリをいじり放題! キタコレ!

参考にしたところ

*1:sshfs ってのも debian パッケージにあるけど、これとどう違うんだろう…? sshfs はapt-getで簡単に入るようだけど、満足に動かせなかったorz