Hi! I’m clsung

Hi! I’m clsung

clsung’s blog site, or you can call me AlanSung

Hi! I’m clsung RSS Feed
 
 
 
 

[FUSE] fusefs-sshfs in FreeBSD

FUSE 的全名是 Filesystem in USErspace(1) ,正式介紹當然是官網來的好。

一言以蔽之,FUSE 讓你上天堂可以以一般 User 的身份來 mount 遠端(?)的檔案系統而不需要 root 權限。

我要分享的經驗是 FUSE 在 FreeBSD 上的使用,以 sshfs 為例。

一開始當然是先利用 ports 安裝 fusefs-sshfs

% cd /usr/ports/sysutils/fusefs-sshfs; make install clean

它會順便檢查(沒有就幫你安裝)fusefs-libsfusefs-kmod

接下來,開啟使用 fusefs 的功能吧(就是 kldload fuse.ko):

% /usr/local/etc/rc.d/fusefs start
Starting fusefs.

接下來是比較有問題的部份,要將 kernel 中的 vfs.usermount 設為 1 ,不然就:

% sysctl vfs.usermount=0
vfs.usermount: 1 -> 0
% sshfs clsung@xxxxxxxx: /fs/to/mount                                
% mount_fusefs: /dev/fuse0 on /fs/to/mount: Operation not permitted

所以要上天堂,要先

% sysctl vfs.usermount=1
vfs.usermount: 0 -> 1

接下來還是有可能有問題,會得到"fuse: failed to open fuse device: Permission denied"的訊息。原因出在 /dev/fuse* 的權限,所以參照這個網頁要設一下 devfs rule,不過在我的機器上(6.2-PRERELEASE)會有這問題:

devfs rule: ioctl DEVFSIO_RADD: Input/output error

Google 一下也沒找到解決,後來就改將 rule 放在 devfs.rules 裡,/etc/rc.d/devfs restart 一下就解決了:

% cat /etc/devfs.rules
[fuse=10]
add path ‘fuse*’ mode 0666 group operator
% /etc/rc.d/devfs restart

不過我自己還是順手將自己加入 operator 這個 group 。接下來就可以自由使用囉:

% sshfs clsung@xxxxxxxx: /fs/to/mount

離開的方法很簡單, umount 就好了:

% umount /fs/to/mount
% /usr/local/etc/rc.d/fusefs stop
Stopping fusefs.

Reference

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • funp
  • Haohao
  • Hemidemi
  • Live
  • MisterWong
  • TwitThis
  • udn
  1. 關於取名 FUSE 的原因還可以看這裡,很有趣 [back]

One Response to “[FUSE] fusefs-sshfs in FreeBSD”

  1. 1
    -TMA-1- » links for 2007-01-05:

    [...] Hi! I’m clsung » [FUSE] fusefs-sshfs in FreeBSD (tags: Tech FreeBSD FileSystem FUSE Guide SSH) [...]

Leave a Reply

噗浪:

分類

Flickr

    clsung. Get yours at bighugelabs.com/flickr

Blogroll

    馬的警總回來了
Creative Commons Attribution-NonCommercial-ShareAlike 2.5 Taiwan
Creative Commons Attribution-NonCommercial-ShareAlike 2.5 Taiwan