[systemd-devel] mount unit with special requirements

Lennart Poettering lennart at poettering.net
Mon Sep 10 18:38:38 UTC 2018


On Sa, 08.09.18 19:10, Michael Hirmke (mh at mike.franken.de) wrote:

> Hi *,
> 
> for my backups I use disks in a way similar to tapes.
> I have a fixed backup disk with one single partition, which is used for
> backing up the machine hosting this disk and a few other machines from
> remote. At night the contents from this disk get copied via rsync to a
> removable disk of the same size, which is replaced by another one next
> morning.
> 
> For the backup "master" I have the following requirements:
> 
> - The partition has to be mounted on boot.
> - It has to be unmounted before the nightly copy job, so that an fsck
>   can be performed.
> - After that it has to be mounted read only, so that during the copy
>   job no other machine can write to it.
> - After finishing the copy job, the partition has to be remounted read
>   write again.

I am not sure I fully grok the requirements here, but I'd probably
turn this around, and make the mount an .automount unit with a short
TimeoutIdleSec=, so that the partition is available always under its
file system path, but mounted only on access, and so that fsck is
pulled in by the first access, but not repeated after that (except
when the disk appears).

You could then plug a service between the .autmount unit and the
.mount unit that only has ExecStop= and does the rsync operation. This
way you run rsync right after each access, automatically, and you know
the mount is currently not in effect.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list