Linux系統中使用sshfs掛載遠程主機的目錄到本地系
之前一直在用NFS,但是配置起來比較麻煩(需要N個C一個S),而且不太穩定(斷網后無法卸載!),現在換sshfs,它基于Linux內置的ssh協議,只要又FUSE就能正常工作。
1、下載
到官網下載最新版本,當前是2.3
http://sourceforge.net/projects/fuse/files/sshfs-fuse/2.3/
2、編譯、安裝
#相關代碼
tar -xzvf sshfs-fuse-2.3.tar.gz
cd sshfs-fuse-2.3
./configure
make -j
sudo make install
3、使用
基礎掛載命令即sshfs需要root權限。
sshfs [user@]host:[dir] mountpoint [options]
前面和ssh命令一樣,mountpoint是掛載點
options重點關注下:
-C 壓縮,或者-o compression=yes
-o reconnect 自動重連
-o transform_symlinks 表示轉換絕對鏈接符號為相對鏈接符號
-o follow_symlinks 沿用服務器上的鏈接符號
-o cache=yes
-o allow_other 這個參數最重要,必須寫,否則任何文件都是Permission Deny
#相關代碼
sshfs -o cache=yes,allow_other [email protected]:/dir_remote ./dir_local
