Hello Randy,
[...]
The volume mounts great if I start the service via systemctl after startup (if the file system is clean), that is, "systemctl start s3ql"But if I reboot I find the file system is corrupt and fails to remount, and need to run fsck.s3ql before it will mount again.It appears the file system isn't unmounting cleanly on shutdown.
[...]
Here's my /lib/systemd/system/s3ql.service file:[Unit]Description=mount s3ql filesystemRequire=NetworkManager-wait-online.serviceAfter=NetworkManager-wait-online.service[Service]ExecStart=/usr/bin/mount.s3ql --fg --authfile /etc/s3ql.authinfo --allow-other swift://tin.fhcrc.org/fast_dr/ /fast_drExecStop=/usr/bin/umount.s3ql /fast_drTimeoutStopSec=5min
I am using this this unit file:
[Unit]
Description=Mount s3ql file system
Requires=nss-lookup.target network.target time-sync.target
After=nss-lookup.target network.target network-online.target remote-fs-pre.target time-sync.target
Conflicts=shutdown.target
ConditionPathIsDirectory=/fast_dr
[Service]
#Type=notify
Type=simple
ExecStart=/usr/local/sbin/mount-fast_dr.sh
LimitNOFILE=66000
NotifyAccess=all
TimeoutStopSec=10min
TimeoutStartSec=10min
[Install]
WantedBy=multi-user.target
It uses the
following start script (/usr/local/sbin/mount-fast_dr.sh):
#!/bin/bash
FSCK_OPTS="--batch --authfile /etc/s3ql.authinfo"
MOUNT_OPTS="--fg --allow-other --authfile /etc/s3ql.authinfo"
STORAGE_URL="swift://tin.fhcrc.org/fast_dr/"
MOUNTPOINT="/fast_dr"
# Check and mount file system
echo executing fsck.s3ql $FSCK_OPTS "$STORAGE_URL"
/usr/bin/fsck.s3ql $FSCK_OPTS "$STORAGE_URL"
FSCK_RESULT=$?
if [[ $FSCK_RESULT != 0 && $FSCK_RESULT != 128 ]]; then
echo "fsck.s3ql reported errors! exit code $FSCK_RESULT"
exit $FSCK_RESULT
fi
/bin/systemd-notify --ready --status="Waiting for data..."
echo executing mount.s3ql $MOUNT_OPTS "$STORAGE_URL" "$MOUNTPOINT"
exec /usr/bin/mount.s3ql $MOUNT_OPTS "$STORAGE_URL" "$MOUNTPOINT"
Hi Nikolaus,
Nikolaus Rath wrote:
/bin/systemd-notify --ready --status="Waiting for data..."If you use systemd-notify, you should set "Type = notify". However, you don't actually need to use systemd-notify -- mount.s3ql is already doing that for you.
A cool – nice to know. If I
recall correctly I tried Type=notify and it did not work (probably was
S3QL 2.17 and Debian 8 back then). I did not bother to figure out why
since it works great with Type=simple for my use case but it probably was
a problem with my self-packaged .deb.
> echo executing mount.s3ql $MOUNT_OPTS "$STORAGE_URL" "$MOUNTPOINT" > exec /usr/bin/mount.s3ql $MOUNT_OPTS "$STORAGE_URL" "$MOUNTPOINT"... and this should be run with --foreground, *especially* if you use "Type = simple".
Yes, --fg is in the $MOUNT_OPTS
[Unit]
Description=mount s3ql filesystem
Require=NetworkManager-wait-online.service
Before=nfs-server.service
After=NetworkManager-wait-online.service
[Service]
ExecStart=/usr/bin/mount.s3ql --fg --authfile /etc/s3ql.authinfo --allow-other swift://tin.fhcrc.org/fast_dr/ /fast_dr
ExecStop=/usr/bin/umount.s3ql /fast_dr
ExecStopPost=/usr/bin/sleep 60
TimeoutStopSec=1min
[Install]
WantedBy=multi-user.target
RequiredBy=nfs-server.servicetry:
from systemd.daemon import notify as sd_notify
except ImportError:
sd_notify = Nonesd_notify = NoneNikolaus Rath wrote:
You need to configure systemd to wait until the mount.s3ql process terminates. I don't know how, but I do know that it can be done.
That’s what the Conflicts=shutdown.target in my unit file is
for. With that line the unit file will get shut down before the shutdown
target gets reached and systemd honors the TimeoutStopSec. Without it
the unit file gets shut down during the shutdown target and then it
cannot wait that long before it gets forcefully killed.
[...] if I reboot I find the file system is corrupt and fails to remount, and need to run fsck.s3ql before it will mount again.
It appears the file system isn't unmounting cleanly on shutdown.