[systemd-devel] Fwd: messing with .mount/.automount units

Andrei Borzenkov arvidjaar at gmail.com
Fri Jan 29 23:11:16 PST 2016


29.01.2016 23:07, arnaud gaboury пишет:
> BUMP.
> 
> I run once a week a simple backup with rsync. For that purpose, I
> wrote a service file (rsync) and a timer unit. They both work with no
> issues.
> 
>  /etc/systemd/system/backup-external.service
> ----------------------------------------------------
> [Unit]
> Description=Backup system to external drive
> Requires=mnt-backup.mount

Why you need it if you use automount anyway? /mnt/backup should be
mounted on access. As is, I am not sure what effect it has.

> After=mnt-backup.mount
> 
> [Service]
> Type=oneshot
> ExecStart=/usr/bin/rsync -av --delete --exclude-from
> /etc/conf.d/exclude-hortensia / /mnt/backup/hortensia
> ExecStartPost=/usr/bin/umount /mnt/backup

Same. I am not even sure whether it attempts to unmount underlying file
system or autofs. You need to decicde whether you use automount or
normal mount.

> -----------------------------------------------------------------------------
> 
> I would like to mount/umount the backup partition only when the
> service is triggered. Backup partition is on a USB external drive and
> LVM group.
> My first attempt was to add this line in my /etc/fstab:
> -------------------------------------------------------
> UUID=868560c1-ab69-423f-b76d-b8ea5af1b066     /mnt/backup
>   ext2    noauto,x-systemd.automount,x-systemd.device-timeout=5,x-systemd.idle-timeout=60
>        0    2
> -----------------------------------------------------------
> 
> $ ls /run/systemd/generator
> .....
> mnt-backup.automount
> mnt-backup.mount
> ----------------------------------------
> 
> For unknown reasons, the partition did mount at boot and never umount.

Do you mean - you boot with USB stick inserted (before system power on)
and after boot USB stick is mounted (not automounted)? Could you show
/proc/mounts output?

> The only way I found to achieve my goal is:
> - remove the entry in /etc/fstab
> - copy the .mount and .automonut files in /etc/systemd/system
> 

Copy from where? Please show these units you use now.

And does it unmount in this case after backup is finished?

> I have the expected behavior this way.
> My question: is this the standard way and advised to do it? Why my
> ftsab entry did not work?
> 


What is your systemd version?


More information about the systemd-devel mailing list