diff --git a/fstab---systemd-mount.md b/fstab---systemd-mount.md new file mode 100644 index 0000000..fbfff58 --- /dev/null +++ b/fstab---systemd-mount.md @@ -0,0 +1,84 @@ +# fstab + +To mount SeaweedFS using `/etc/fstab` (such as on boot): + +* Follow the directions in https://github.com/seaweedfs/seaweedfs/wiki/FUSE-Mount for setting up a SeaweedFS mount subtype for FUSE (hint: `cp weed /sbin/weed`) +* Install SeaweedFS as usual, making sure any specific settings (such as `security.toml`) are in the correct location to be read +* Add the fstab entry as described below + +If you have a single filer server, this is the syntax you will use: + +`fuse /path/to/mountpoint fuse.weed filer=localhost:8888,filer.path=/,defaults,_netdev 0 0` + +If you have multiple filer servers, this is the syntax you will use: + +`fuse /path/to/mountpoint fuse.weed filer='192.168.0.1:8888,192.168.0.2:8888',filer.path=/,defaults,_netdev 0 0` + +Place the appropriate line into `/etc/fstab` and attempt to mount your filesystem. If you encounter any issues, run `weed mount` directly in verbose/debug mode to diagnose the issue, and switch back to fstab-style mounting once you have resolved the issues. + +## Systemd + +Systemd takes over and enhances fstab-based mount in the following two ways: + +* `systemd-fstab-generator(8)` will translate the mount option in /etc/fstab into `systemd.mount` / `systemd.automount` units. Systemd-related enhancement option (`nofail`, `x-systemd.device-timeout`, `x-systemd.mount-timeout`, `x-systemd.automount`, etc.) will be parsed into systemd.mount options. +* Explicit `systemd.mount` / `systemd.automount` unit files configured. + +If you don't use `systemd.automount` option, editing /etc/fstab as above and enable systemd-fstab-generator. (On modern systemd-based systems this is enabled by default). + +### systemd.automount + +[`systemd.automount`](https://www.freedesktop.org/software/systemd/man/latest/systemd.automount.html) is a tool where systemd automatically and transparently handles on-demand connection and disconnect when not needed. + +**Mount onto root-owned mountpoint** + +If mountpoint is owned by root, fstab can do the job, by adding x-systemd.automount (and related options) and `autofs` to fstab entries. + +`fuse /path/to/mountpoint fuse.weed filer='192.168.0.1:8888,192.168.0.2:8888',filer.path=/,x-systemd.automount,x-systemd.idle-timeout=300,autofs,defaults,_netdev 0 0` + +Added options: +- `x-systemd.automount`: enables systemd automount +- `x-systemd.idle-timeout=300`: set systemd auto-disconnect timeout +- `autofs`: makes weed fuse compatible with systemd.automount. + +**Mount onto user-owned mountpoint** + +If the mountpoint needs to be owned by a user, e.g. mounting `/home/user` which is owned by user:user, manual systemd.mount / systemd.automount files is required to pass correct uid/gid to autofs. + +Create following systemd unit files: + +/etc/systemd/system/path-to-mount.automount +``` +[Automount] +Where=/path/to/mount +TimeoutIdleSec=30 +ExtraOptions=uid=USERID,gid=GROUPID +``` + +Here ExtraOptions sets the uid/gid. + +/etc/systemd/system/path-to-mount.mount +``` +[Mount] +What=fuse +Where=/path/to/mount +Type=weed +Options=filer=localhost:8888,filer.path=/,autofs +``` + +If you are unsure about the options, you can utilize systemd-fstab-generator to generate one: + +Add your line to /etc/fstab temporarily: +``` +fuse /path/to/mountpoint fuse.weed filer='192.168.0.1:8888,192.168.0.2:8888',filer.path=/,x-systemd.automount,x-systemd.idle-timeout=300,autofs,defaults,_netdev 0 0 +``` + +run `systemd daemon-reload` and check generated files: + +``` +systemd cat path-to-mountpoint.mount +systemd cat path-to-mountpoint.automount +``` + +Add the line `ExtraOptions=uid=USERID,gid=GROUPID` to the automount and create both files in /etc/systemd/system. Remove the temporary fstab entries, and run `systemd daemon-reload` again. + +You can enable the automount by `systemctl enable --now path-to-mountpoint.automount`. diff --git a/fstab.md b/fstab.md deleted file mode 100644 index c00c360..0000000 --- a/fstab.md +++ /dev/null @@ -1,30 +0,0 @@ -To mount SeaweedFS using `/etc/fstab` (such as on boot): - -* Follow the directions in https://github.com/seaweedfs/seaweedfs/wiki/FUSE-Mount for setting up a SeaweedFS mount subtype for FUSE (hint: `cp weed /sbin/weed`) -* Install SeaweedFS as usual, making sure any specific settings (such as `security.toml`) are in the correct location to be read -* Add the fstab entry as described below -* But make sure that `systemd-fstab-generator(8)` is not used on your system - -If you have a single filer server, this is the syntax you will use: - -`fuse /path/to/mountpoint fuse.weed filer=localhost:8888,filer.path=/,defaults,_netdev 0 0` - -If you have multiple filer servers, this is the syntax you will use: - -`fuse /path/to/mountpoint fuse.weed filer='192.168.0.1:8888,192.168.0.2:8888',filer.path=/,defaults,_netdev 0 0` - -Place the appropriate line into `/etc/fstab` and attempt to mount your filesystem. If you encounter any issues, run `weed mount` directly in verbose/debug mode to diagnose the issue, and switch back to fstab-style mounting once you have resolved the issues. - -## Systemd - -* No matter what systemd options (`nofail`, `x-systemd.device-timeout`, `x-systemd.mount-timeout`, etc.) you add to /etc/fstab, you won’t be able to make `systemd.mount(5)` handle the mount properly. You will always get an error when starting mount unit, even though the filesystem ends up being mounted. -* `x-systemd.automount` doesn’t work at all. -* The `_netdev` results in errors like: - - ```log - kernel: fuse: Unknown parameter '_netdev' - ``` - - p.s. Not sure if it’s related. (systemd 255.6) - -In general, if your system is deeply integrated with systemd, it is better to create `systemd.service(5)` to mount. \ No newline at end of file