[systemd-devel] mount unit with special requirements

Michael Hirmke mh at mike.franken.de
Sat Sep 8 17:10:00 UTC 2018


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.

To achive that, at the moment my backup routine calls the following
commands:
- systemctl mask var-backup.mount
- systemctl stop nfsserver smb (to avoid the partition being busy)
- systemctl stop var-backup.mount
- systemctl start nfsserver smb
- fsck -yf /dev/sdf1
- mount -o ro /dev/sdf1 /var/backup
- (mount dup partition, fsck dup partition, rsync, umount dup partition)
- mount -o remount,rw /dev/sdf1 /var/backup
- systemctl unmask var-backup.mount

It seems to be unnecessary complicated, but I didn't find a way to
achive what I described above with a less complicated approach.
Everything else I tried, led to problems with systemd, that tried
to take unwanted actions. Even using the commands above, 1 out of 10
jobs fails with messages like "Specified filename /dev/sdf1 has no
mountpoint." when *stopping* var-backup.mount.
I suspect, though, there is a less complicated and perhaps even more
stable approach.

Can anyone lead me on the right way?

TIA.

Bye.
Michael.
-- 
Michael Hirmke


More information about the systemd-devel mailing list