Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

please provide mount.weed for fstab #1323

Closed
onlyjob opened this issue May 18, 2020 · 3 comments
Closed

please provide mount.weed for fstab #1323

onlyjob opened this issue May 18, 2020 · 3 comments

Comments

@onlyjob
Copy link

onlyjob commented May 18, 2020

Please consider providing mount.weed wrapper for /etc/fstab compatibility.

Here is the generic syntax for fuse mounts in /etc/fstab:

mount.weed    /mnt/weed    fuse    _netdev,nodev    0    0

It would be particularly useful to support passing -o options to weed mount as the above example passes /mnt/weed -o rw,nodev,suid parameters to mount.weed.

Here is a draft wrapper (/usr/bin/mount.weed or /usr/local/bin/mount.weed) to illustrate the idea:

#!/bin/sh

set -u

dir="$1"
shift
shift     # remove "-o"

opt=""

IFS=","
for O in $1; do
    key="${O%%=*}"
    case "${key}" in
        dataCenter|dir|cacheCapacityMB|asyncMetaDataCaching|cacheCapacityMB|cacheDir|filer|replication)
            opt="${opt} -$O"
    esac
done
unset IFS

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \
exec /usr/bin/weed mount -dir="${dir}" ${opt} 2>>/dev/null &
@thiscantbeserious
Copy link

Trying to dig a bit deeper on this I found the following:

https://systemd-devel.freedesktop.narkive.com/aAxHaRZM/unit-configuration-for-fuse-file-system#post4

The official API to mount file systems of any kind on Linux is
/bin/mount. Only that makes sure we don't have to add additional hooks
to various components of our stack to support specific file system
types. It also makes sure that fstab works for this service the way it
should. /bin/mount is capable of invoking helper tools for specific file
systems, via a hook tool /sbin/mount..

So thats what your draft wrapper above is about? Then a quick 'man mount' tells us that the correct syntax above should be 'fuse.weed' - quote from the manpage:

The programs mount and umount support filesystem subtypes. The subtype is defined by a '.subtype' suffix. For example 'fuse.sshfs'. It's recommended to use subtype notation rather than add any prefix to the mount source (for example 'sshfs#example.com' is deprecated).

See also

https://lwn.net/Articles/221779/

@jameno123
Copy link

A good example of a wrapper script would be that from "ceph"

See: "mount.fuse.ceph"

https://github.com/ceph/ceph/blob/master/src/mount.fuse.ceph

The mount helper just needs installed to /sbin/mount.fuse.ceph and the filesystem type would be set to "fuse.ceph"... this could easily be adapted to seaweedfs and ported to go you could then symlink /sbin/mount.fuse.seaweedfs to /usr/bin/weed and maybe add some code to weed to determine its execution name (ie: if argv[0] == 'mount.fuse.seaweedfs') then execute the above code otherwise go into the normal execution routines. (more complex, but requires only 1 binary and a symlink to be installed).

Alternatively the program could be compiled separately and then just call 'weed mount' with the acceptable options (cleaner), but requires two binaries on the system.

If i understand correctly, mount will by default call "mount.$FSTYPE" to try to mount the filesystem type specified in fstab and pass it the options as specified. In this case "fstype=fuse.seaweedfs" so mount would try to call "mount.fuse.seaweedfs" which would run the logic above and call "weed mount" passing the correct options.

I would suggest also taking a play from ceph and making sure all options in the fstab file are prefixed with seaweedfs or weed so "dataCenter" becomes "weed.dataCenter=xyz" in fstab which will be extracted and then passed to "weed mount -dataCenter xyz"

@chrislusf
Copy link
Collaborator

#2085 should have resolved this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants