On Sat, Jan 30, 2016 at 8:11 AM, Andrei Borzenkov <arvidj...@gmail.com> wrote: > 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)?
Yes, I boot with the external USB drive plugged. The drive is LVM partitioned, and yes, the /mnt/backup is mounted with the above fstab Could you show > /proc/mounts output? .................... systemd-1 /mnt/backup autofs rw,relatime,fd=26,pgrp=1,timeout=60,minproto=5,maxproto=5,direct 0 0 ............................................. > >> 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. I copied then from /run/systemd/generator. % cat /run/systemd/generator/mnt-backup.automount ---------------------------------------------------------- # Automatically generated by systemd-fstab-generator [Unit] SourcePath=/etc/fstab Documentation=man:fstab(5) man:systemd-fstab-generator(8) Before=local-fs.target [Automount] Where=/mnt/backup TimeoutIdleSec=1min ------------------------------------------------------------ % cat /run/systemd/generator/mnt-backup.mount ---------------------------------------------------------- # Automatically generated by systemd-fstab-generator [Unit] SourcePath=/etc/fstab Documentation=man:fstab(5) man:systemd-fstab-generator(8) Requires=systemd-fsck@dev-disk-by\x2duuid-868560c1\x2dab69\x2d423f\x2db76d\x2db8ea5af1b066.service After=systemd-fsck@dev-disk-by\x2duuid-868560c1\x2dab69\x2d423f\x2db76d\x2db8ea5af1b066.service [Mount] What=/dev/disk/by-uuid/868560c1-ab69-423f-b76d-b8ea5af1b066 Where=/mnt/backup Type=ext2 Options=noauto,x-systemd.automount,x-systemd.idle-timeout=60 ---------------------------------------------------------------------------- > > And does it unmount in this case after backup is finished? YES > >> 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? systemd 228-3 -- google.com/+arnaudgabourygabx _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel