Hello Jaimala,

Ubuntu 20.04 uses systemd for startup scripts.
Normally mounting can be done via /etc/fstab or
https://www.freedesktop.org/software/systemd/man/systemd.mount.html but
both variants have problems when using them for S3QL.


So you should use a dedicated systemd service unit that has a
Conflicts=shutdown.target property and an increased TimeoutStopSec
property. With that it gets stopped before the system shuts down and
does not get killed prematurely by systemd (otherwise the file system
will get stopped while the system shuts down and you sometimes do not
have enough time stop the file system – S3QL can take quite some time to
stop since it needs to uploads all dirty blocks and its metadata to the
cloud storage)

Here is the service unit I am using (for a backend
"swiftks://my-backend-url" and a mount point /cloud/data):
/lib/systemd/system/cloud-data.service
[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=/cloud/data

[Service]
Type=notify
#Type=simple
ExecStartPre=/usr/local/sbin/pre-mount-cloud-data.sh
ExecStart=/usr/bin/mount.s3ql --fg --systemd--log none --allow-other
--authfile /root/.s3ql/authinfo2 --keep-cache
--backend-options=tcp-timeout=20,domain=default --compress zlib-6
--max-cache-entries 65536 "swiftks://my-backend-url" "/cloud/data"
ExecStop=/usr/bin/umount.s3ql "/cloud/data"
LimitNOFILE=65936
TimeoutStopSec=10min# <- increase when needed (big cache)
TimeoutStartSec=10min # <- increase when needed (big file system)

[Install]
WantedBy=multi-user.target


This unit file references pre-mount-cloud-data.sh. That is a little
script that tries to repair the filesystem when it is needed. It is
optional (just remove the ExecStartPre line) but quite useful.
/usr/local/sbin/pre-mount-cloud-data.sh
#!/bin/bash

# Check for a crashed S3QL
if ls "/cloud/data" 2>&1 | grep -Fq 'Transport endpoint is not
connected'; then
  fusermount -u "/cloud/data"
fi

# Check and mount file system
echo executing fsck.s3ql --batch--log none --authfile
/root/.s3ql/authinfo2 --keep-cache
--backend-options=tcp-timeout=20,domain=default  "swiftks://my-backend-url"
/usr/bin/fsck.s3ql --batch--log none --authfile /root/.s3ql/authinfo2
--keep-cache --backend-options=tcp-timeout=20,domain=default 
"swiftks://my-backend-url"
FSCK_RESULT=$?
if [[ $FSCK_RESULT != 0 && $FSCK_RESULT != 128 ]]; then
  echo "fsck.s3ql reported errors! exit code $FSCK_RESULT"
  exit $FSCK_RESULT
fi
exit 0




If you have a service that depend on the file system to be mounted, then
create an overwrite file for its service unit and use
"After=cloud-data.service" to start the service only when the file
system was mounted.
E.g. for nginx execute "sudo systemctl edit nginx" paste the following
in the editor and save&exit:
[Unit]
After=cloud-data.service


If your file system exits after the TimeoutStartSec then your system
does not have the Python bindings for systemd installed. Either (a) try
to install them with "apt-get install python3-systemd" or (b) use the
Type=simple
line instead of the Type=notify line in the unit file. Variant (a) is
preferred since only with it depending services (see above) work correctly.

You obviously need to change some arguments (e.g. the backend URL or the
mount point) before you can use this unit file and its ExecPreStart
helper script and you need to create the empty mount point directory
once e.g. with "sudo mkdir -p /cloud/data".

Some pointers:
https://www.freedesktop.org/software/systemd/man/systemd.service.html
https://www.rath.org/s3ql-docs/mount.html#automatic-mounting
https://groups.google.com/g/s3ql/search?q=systemd%20mount
https://www.google.com/search?q=s3ql+systemd+mount
https://www.brightbox.com/docs/guides/s3ql/

-- 
You received this message because you are subscribed to the Google Groups 
"s3ql" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/s3ql/b9b36ebc-0eff-6fc1-1598-32c33c31989c%40jagszent.de.

Reply via email to