fuse 應用(curlftpfs, sshfs, convmvfs, vmfs-tools)

最後更新: 2015-06-04

 

介紹:

簡言一句, fuse 的目的是 "在用戶層實現核心檔案功能"

fuse 最少要有 fuse-utils 及 libfuse2 這兩個包,

所以無論 mount 什麼也好, 都要事先安裝它們.

安裝 FUSE 後, 再安裝特定的 "file system" 包去實現 "mount" 東西

現在可以 mount 的 file system 有 ftp, ssh, glusterfs, webdav, ntfs

網絡:

FS:

  • ntfs-3g - read-write NTFS driver for FUSE
  • fusesmb - filesystem client based on the SMB file transfer protocol
  • vmfs-tools - mount vmfs filesystem

功能:

  • unionfs-fuse
  • bindfs - mirrors or overlays a local directory with altered permissions
  • mhddfs - file system for unifying several mount points into one
  • encfs - encrypted virtual filesystem
  • fuse-convmvfs - mirrors a whole filesystem tree from one charset to another

檔案:

  • avfs - virtual filesystem to access archives, disk images, remote locations
  • fuseiso - FUSE module to mount ISO filesystem images

工具:

  • afuse - automounting file system implemented in user-space using FUSE

 

安裝

apt-get install fuse-utils

它會建立 fuse 的用戶組 (GID: 106)

並且透過 udev 去建立所須的裝置檔

ls -al /dev/fuse

crw-rw---- 1 root fuse 10, 229 Apr  6 16:52 /dev/fuse

還有會載入 kernel modules fuse

vzserver:~# lsmod | grep fuse

fuse                   44592  1

 


基本設定:

 

fuse-utils package 提供以下東西:

  • /etc/fuse.conf
  • /etc/init.d/fuse
  • /usr/bin/fusermount
  • /sbin/mount.fuse

libfuse2 package 提供以下東西:

  • /usr/lib/libfuse.so.*
  • /usr/lib/libulockmgr.*

設定

在 /etc/fuse.conf 有一個幾重要的 defaul  設定

# 可以比 non-root users 用 allow_other / allow_root 的 mount opts

user_allow_other

# maximum number of FUSE mounts allowed to non-root users. The default is 1000.

mount_max = NNN

# 在一般情況下, 如果 A mount 來的目錄, 只有 A 才可存取

# 不過當以上指令(allow_other)生效, A mount 的東西就可以被任何人存取 ~

fusermount:

opts:

  • -u  unmount.
  • -z  lazy unmount

fuse:

[iconv]

    -o from_code=CHARSET   original encoding of file names (default: UTF-8)
    -o to_code=CHARSET      new encoding of the file names (default: UTF-8)

allow_other

allow_root

uid=N  Override the st_uid field set by the filesystem

gid=N  Override the st_gid field set by the filesystem

default_permissions

By default FUSE doesn't check file access permissions.

This  option  enables  permission  checking, restricting  access  based on file mode.

checking

mount | grep fuse

fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
/dev/fuse on /mnt/vmfs type fuse (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions)

 


sshfs

 

掛載 ssh:

sshfs root@myserver:/root ~/mnt-myserver

查看是否真的成功

ls mnt-myserver/

umount:

umount /root/mnt

注意:

由於我不是用 fusermount 去 mount 的, 所以不能用 fusermount -u 去 umount

實用選項:

    -o reconnect           reconnect to server
    -o sshfs_sync          synchronous writes
    -o cache_timeout=N     sets timeout for caches in seconds (default: 20)
    -o follow_symlinks     follow symlinks on the server
    -o sftp_server=SERV    path to sftp server or subsystem (default: sftp)
 


掛載 FTP(curlftpfs):

curlftpfs -o user=datahunter lamp ./mnt

 


convmvfs: 不同 charset 掛載:

 

雖然 convmv 亦可轉碼, 不過萬一出錯就大件事了 .......

事先 preview 一次十分可取 ^^

convmvfs ~/mnt -o srcdir=/home/ftp/tmp/,icharset=big5,ocharset=utf8

常見 charset:

  • big5
  • gbk
  • utf8

 


vmfs-tools

 

Install:

apt-get install vmfs-tools

Usage:

vmfs-fuse VOLUME... MOUNT_POINT

i.e.

mkdir /mnt/vmfs

vmfs-fuse /dev/sdd1 /mnt/vmfs

 


其他資料:

 


dokan-sshfs (window)

 

Dokan library

User mode file system library for windows; FUSE for windows.

HomePage:

http://dokan-dev.net/en/

Supported version:

  • Windows XP
  • 2003
  • Vista
  • 2008
  • win7