[arch-general] messing with external USB and .mount/.automount drive

arnaud gaboury arnaud.gaboury at gmail.com
Fri Jan 22 18:21:31 UTC 2016


On Fri, Jan 22, 2016 at 6:32 PM, arnaud gaboury
<arnaud.gaboury at gmail.com> wrote:
> I want to timer a simple backup of part of my system with rsync. The
> partition I want to use for backup is on an external USB drive.
>
> For safety reasons (avoid any accidental erase), I want the partition
> be mounted only for the time of the rsync, then be umounted
>
> Here is my setup:
>
> /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
> -----------------------
>
>  /etc/systemd/system/backup-external.service
> ----------------------------------------------------
> [Unit]
> Description=Backup system to external drive
> Requires=mnt-backup.mount
> 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
> -------------------------------------------------------------------------
>
>
>  /etc/systemd/system/backup-external.timer
> ------------------------------------------
> [Unit]
> Description=Start external-backup service periodically
>
> [Timer]
> OnCalendar=Mon *-*-* 00:00:00
> Persistent=True
>
> [Install]
> WantedBy=timers.target
> ---------------------------------------------------
>
> $ ls /run/systemd/generator
> .....
> mnt-backup.automount
> mnt-backup.mount
> ---------------------------------
>
> The setup works BUT in fact /mnt/backup/hortensia is always mounted,
> even after boot, and I want to avoid it.(maybe because it is USB and
> autmounted like any USB device?)
>
> What surprised me is if I run:
> # umount /mnt/backup
>
> I come back to command with no text BUT
> /dev/dev/mapper/vg1-backup_hortensia (my backup partition) is still
> mounted. Furthermore, I can mount/umount it elsewhere (mnt/toto for
> example).
>
> I can't see what is wrong and how can I achieve my goal.

EDIT: one obvious solution would be to NOT mount the partition at
boot, and include a mount command in my service file. But I would like
to use the .mount/.automount systemd features.
>
> Thank you for help
>
>
> --
>
> google.com/+arnaudgabourygabx



-- 

google.com/+arnaudgabourygabx


More information about the arch-general mailing list