[英]How to register FUSE filesystem type with mount(8) and fstab?
I've written a small FUSE-based filesystem and now the only part's missing is that I want to register it with fstab(5) to auto-mount it on system startup and/or manually mount it with just mount /srv/virtual-db
.我已经编写了一个基于 FUSE 的小型文件系统,现在唯一缺少的部分是我想使用 fstab(5) 注册它以在系统启动时自动挂载它和/或仅使用mount /srv/virtual-db
手动挂载它mount /srv/virtual-db
。 How can I achieve this?我怎样才能做到这一点?
I know, I can just run /usr/bin/vdbfs.py /srv/virtual-db
from some init script, but that's not exactly pretty.我知道,我可以从一些 init 脚本运行/usr/bin/vdbfs.py /srv/virtual-db
,但这并不完全正确。
I'm sorry because this may be not exactly a programming question, but it's highly related, as the packaging and deployment is still the programmer's job.我很抱歉,因为这可能不完全是一个编程问题,但它是高度相关的,因为打包和部署仍然是程序员的工作。
In general, one "registers" a new mount filesystem type by creating an executable mount.fstype
.通常,通过创建可执行文件mount.fstype
“注册”新的挂载文件系统类型。
$ ln -s /usr/bin/vdbfs.py /usr/sbin/mount.vdbfs
If vdbfs.py
takes mount
-ish arguments (ie dev path [-o opts]
), then mount -t vdbfs
and using vdbfs
as the 3rd field in fstab
will work.如果vdbfs.py
采用mount
-ish 参数(即dev path [-o opts]
),则mount -t vdbfs
并使用vdbfs
作为fstab
的第三个字段将起作用。 If it doesn't, you can create a wrapper which does take arguments of that form and maps them to whatever your vdbfs.py
takes.如果没有,您可以创建一个包装器,该包装器确实采用该形式的参数并将它们映射到您的vdbfs.py
采用的任何vdbfs.py
。
FUSE should also install a mount.fuse
executable; FUSE 还应该安装一个mount.fuse
可执行文件; mount.fuse 'vdbfs.py#dev' path -o opts
will go on and call vdbfs.py dev path -o opts
. mount.fuse 'vdbfs.py#dev' path -o opts
将继续调用vdbfs.py dev path -o opts
。 In that case, you can use fuse
as your filesystem type and prefix your device with vdbfs.py#
.在这种情况下,您可以使用fuse
作为您的文件系统类型,并使用vdbfs.py#
您的设备添加前缀。
So to clarify ephemient's answer, there are two options:因此,为了澄清 ehemient 的答案,有两种选择:
Edit /etc/fstab
like this:像这样编辑/etc/fstab
:
# <file system> <mount point> <type> <options> <dump> <pass> # ... vdbfs.py#<dev> /srv/virtual-db fuse user,<other-opts> 0 0
Or,要么,
Create an executable prefixed with "mount."创建一个以“mount”为前缀的可执行文件。 (ensuring it can be used with mount
-like options): (确保它可以与类似mount
的选项一起使用):
$ ln -s /usr/bin/vdbfs.py /usr/sbin/mount.vdbfs
And edit /etc/fstab
like this:并像这样编辑/etc/fstab
:
# <file system> <mount point> <type> <options> <dump> <pass> # ... <dev> /srv/virtual-db vdbfs.py user,<other-opts> 0 0
With regards to auto-mounting at start up and manually mounting with mount
, the user
and noauto
options are relevant and fully supported by fuse itself so you don't have to implement them yourself.关于启动时自动安装和使用mount
手动安装, user
和noauto
选项是相关的,并且由保险丝本身完全支持,因此您不必自己实现它们。 The user
option lets a non-priveleged user who is a member of the "fuse" group mount your filesystem with the mount
command, and noauto
directs your filesystem not to automatically mount at startup. user
选项允许作为“fuse”组成员的非特权用户使用mount
命令挂载您的文件系统,而noauto
指示您的文件系统不在启动时自动挂载。 If you don't specify noauto
, it will automatically mount.如果不指定noauto
,它将自动挂载。
To clarify @patryk.beza comment on the accepted answer, the correct way to mount a FUSE file system is by setting the file system type to fuse.<subtype>
.为了澄清@patryk.beza 对已接受答案的评论,挂载 FUSE 文件系统的正确方法是将文件系统类型设置为fuse.<subtype>
。
For example, to mount an s3fs-fuse implementation, which does not provide a specific /sbin/mount.*
wrapper and uses normally the s3fs
user command to mount S3 buckets, one can use this command as root:例如,以安装s3fs熔丝实现,它不提供特定/sbin/mount.*
包装和用途通常是s3fs
用户命令装入S3水桶,人们可以使用该命令作为根:
mount -t fuse.s3fs bucket-name /path/to/dir -o <some,options>
or this line in /etc/fstab
:或/etc/fstab
这一行:
bucket-name /path/to/dir fuse.s3fs <some,options> 0 0
or this SystemD mount unit (for example, /etc/systemd/system/path-to-dir.mount
):或者这个 SystemD 挂载单元(例如, /etc/systemd/system/path-to-dir.mount
):
[Unit]
Description=S3 Storage
After=network.target
[Mount]
What=bucket-name
Where=/path/to/dir
Type=fuse.s3fs
Options=<some,options>
[Install]
WantedBy=multi-user.target
How this works: mount
recognizes the concept of "filesystem subtypes" when the type is formatted with a period (ie <type>.<subtype>
), so that a type with the format fuse.someimpl
is recognized to be the responsibility of the FUSE mount helper /sbin/mount.fuse
.这是如何工作的:当类型用句点格式化时(即<type>.<subtype>
), mount
识别“文件系统子类型”的概念,因此格式为fuse.someimpl
的类型被识别fuse.someimpl
FUSE 挂载助手/sbin/mount.fuse
。 The FUSE mount helper then resolves the someimpl
part to the FUSE implementation, in the same way as the #
format is used in the original answer (I think this is just a path search for a program named <subtype>
, but I'm not 100% sure about it). FUSE 挂载助手然后将someimpl
部分解析为 FUSE 实现,其方式与原始答案中使用的#
格式相同(我认为这只是对名为<subtype>
的程序的路径搜索,但我不是100% 确定)。
You could just use fuse filesystem type.您可以只使用保险丝文件系统类型。 The following works on my system:以下适用于我的系统:
smbnetfs /media/netbios fuse defaults,allow_other 0 0
Another example:另一个例子:
sshfs#user@example.com:/ /mnt fuse user,noauto 0 0
After researching a lot found this solution to mount fuse filesystem suing fstab
entry.经过大量研究,发现此解决方案可以通过fstab
条目挂载保险丝文件系统。 I was using fuse for s3bucket to mount on local linux machine.我正在使用 s3bucket 的保险丝安装在本地 linux 机器上。
.passwd-s3fs
: Is containing credentials to access your aws account 1] Secret key and 2] Access Key . .passwd-s3fs
:包含访问您的 aws 帐户的凭据 1] Secret key 和 2] Access Key 。uid
: User Id. uid
: 用户 ID。 You can type linux command id
and you can get uid你可以输入linux命令id
就可以得到uidSyntax:句法:
s3fs#<Bucket_Name> <Mounted_Direcotry_Path> fuse _netdev,allow_other,passwd_file=/home/ubuntu/.passwd-s3fs,use_cache=/tmp,umask=002,uid=<User_Id> 0 0
Example:例子:
s3fs#myawsbucket /home/ubuntu/s3bucket/mys3bucket fuse _netdev,allow_other,passwd_file=/home/ubuntu/.passwd-s3fs,use_cache=/tmp,umask=002,uid=1000 0 0
To mount you need run following command.要挂载,您需要运行以下命令。
mount -a
To check your bucket is mounted properly or not use following command to check which shows all mounted points.要检查您的存储桶是否正确安装,请使用以下命令检查哪个显示所有安装点。
df -h
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.