recommended systemd unit for automount

45 views
Skip to first unread message

Martin

unread,
Mar 15, 2018, 5:06:16 AM3/15/18
to s3ql
Hi,

I can read in the doc:

you should do so with a dedicated S3QL init job (instead of using /etc/fstab. When using systemd, mount.s3ql can be run as a service of type notify.

I supposed it's not detailed because not in the scope of S3QL (at least only partially).

Could anyone share a working/notify unit systemd file ?

Regards,

Martin

unread,
Mar 15, 2018, 7:41:26 AM3/15/18
to s3ql

Daniel Jagszent

unread,
Mar 15, 2018, 9:59:43 AM3/15/18
to s3ql
Hi Martin,

I'm using the following 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=/media/container-test

[Service]
Type=notify
ExecStart=/usr/local/sbin/mount-media-container-test.sh
LimitNOFILE=66000
TimeoutStopSec=10min
TimeoutStartSec=10min

[Install]
WantedBy=multi-user.target

With /usr/local/sbin/mount-media-container-test.sh being:
#!/bin/bash

FSCK_OPTS="--batch --authfile /path/to/s3ql.txt --backend-options=tcp-timeout=20"
MOUNT_OPTS="--fg --allow-other --authfile /path/to/s3ql.txt --backend-options=tcp-timeout=20 --max-cache-entries 65536"
STORAGE_URL="swiftks://xxx"
MOUNTPOINT="/media/container-test"

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
echo executing mount.s3ql $MOUNT_OPTS "$STORAGE_URL" "$MOUNTPOINT"
exec /usr/bin/mount.s3ql $MOUNT_OPTS "$STORAGE_URL" "$MOUNTPOINT"


S3QL stops gracefully when getting a INT-Signal, so no need for the ExecStop.
With "Conflicts=shutdown.target" the unit gets stoped before shutdown – that is important because S3QL can take quite some time to shut down properly (it needs to upload all dirty blocks) otherwise systemd would forcefully kill S3QL after some time (and do not honor the TimeoutStopSec option)
I use an extra bash script to make the mounting a little bit more robust (if S3QL was not cleanly unmounted it needs a fsck before it can re-mount the file system).

Reply all
Reply to author
Forward
0 new messages