[systemd-devel] Recommended way to automount USB drives and trigger actions?
Lennart Poettering
lennart at poettering.net
Mon Mar 3 06:49:29 PST 2014
On Mon, 03.03.14 10:29, Alejandro Exojo (aexojo at modpow.es) wrote:
> Hi.
>
> I'm asked to do the following "upgrade" procedure to a custom embedded
> system: plug an USB drive and upgrade our application (that runs as a
> systemd service) from the contents of the drive. Is a bit ugly, but is
> a temporary workaround.
>
> I've thought of doing it with:
>
> 1. Automounting USB drives when they are plugged.
> 2. A oneshot service that calls pkcon or the underlying package
> manager, and that is "WantedBy=media-usbdrive.mount" (the package
> already has the machinery to restart the service).
>
> I'm having doubts on the first part. I've already done the
> automounting on some cases with udev rules, but I'm completely unsure
> if is preferred to be done with .mount and .automount unit files. I
> suppose I can do anything with udev rules that trigger commands too.
Hmm, you could just add the USB drive to fstab, and mark it as
auto,nofail. Then, each time you insert the device it should be mounted.
Then with WantedBy=media-usbdrive.mount you could pull in your service,
as you already found out.
>
> If you have any advice, I will be very glad to read it.
> Thank you.
>
> PS: Sorry if is not the right place for this, but there is no
> systemd-users list. :-)
> And since I've bothered you anyway, let me add that switching from
> sysvinit to systemd has been a huge boon to our usability and
> development. We are using the journal quite extensively to debug,
> since we have no other UI that printing stuff to stderr. I think you
> deserve to know, after all the destructive criticism that you tend to
> receive.
Thanks!
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list