[pbs-devel] [PATCH proxmox-backup 25/26] debian/etc: add udev rules and simple service for automounting

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Jul 6 13:49:50 CEST 2022


On Tue, Jul 05, 2022 at 01:08:33PM +0000, Hannes Laimer wrote:
> Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
> ---
>  debian/proxmox-backup-server.install    | 1 +
>  debian/proxmox-backup-server.udev       | 3 +++
>  etc/Makefile                            | 3 ++-
>  etc/removable-device-attach at .service.in | 6 ++++++
>  4 files changed, 12 insertions(+), 1 deletion(-)
>  create mode 100644 etc/removable-device-attach at .service.in
> 
> diff --git a/debian/proxmox-backup-server.install b/debian/proxmox-backup-server.install
> index 6e2219b4..3cabd46e 100644
> --- a/debian/proxmox-backup-server.install
> +++ b/debian/proxmox-backup-server.install
> @@ -3,6 +3,7 @@ etc/proxmox-backup.service /lib/systemd/system/
>  etc/proxmox-backup-banner.service /lib/systemd/system/
>  etc/proxmox-backup-daily-update.service /lib/systemd/system/
>  etc/proxmox-backup-daily-update.timer /lib/systemd/system/
> +etc/removable-device-attach at .service /lib/systemd/system/
>  etc/pbs-enterprise.list /etc/apt/sources.list.d/
>  usr/lib/x86_64-linux-gnu/proxmox-backup/proxmox-backup-api
>  usr/lib/x86_64-linux-gnu/proxmox-backup/proxmox-backup-proxy
> diff --git a/debian/proxmox-backup-server.udev b/debian/proxmox-backup-server.udev
> index afdfb2bc..e5aa26c3 100644
> --- a/debian/proxmox-backup-server.udev
> +++ b/debian/proxmox-backup-server.udev
> @@ -16,3 +16,6 @@ SUBSYSTEM=="scsi_generic", SUBSYSTEMS=="scsi", ATTRS{type}=="1", ENV{ID_SCSI_SER
>    SYMLINK+="tape/by-id/scsi-$env{ID_SCSI_SERIAL}-sg"
>  
>  LABEL="persistent_storage_tape_end"
> +
> +# triggers the mounting of a removable device
> +ACTION=="add", SUBSYSTEM=="block", ENV{ID_FS_UUID}!="", TAG+="systemd", ENV{SYSTEMD_WANTS}="removable-device-attach@$env{ID_FS_UUID}"

Have you tried using systemd generators? (man 7 systemd.generator)

Because this adds `Wants=removable-device-attach at ...` to *all* blockdevs
with uuids. I don't like this.

I think we could put a binary in `/lib/systemd/system-generators/` which
writes out a unit file for all the removable datastores which depends on
the `.device` unit created by the `TAG+="systemd"` bit of the udev rule.
(We could then remove the ENV bit).

Additionally, further unit files in `/run` would have to be created and
removed by the daemon when they are added/removed via the API/CLI.

> diff --git a/etc/Makefile b/etc/Makefile
> index 42f639f6..730de4f8 100644
> --- a/etc/Makefile
> +++ b/etc/Makefile
> @@ -7,7 +7,8 @@ DYNAMIC_UNITS := \
>  	proxmox-backup-banner.service \
>  	proxmox-backup-daily-update.service \
>  	proxmox-backup.service \
> -	proxmox-backup-proxy.service
> +	proxmox-backup-proxy.service \
> +	removable-device-attach at .service
>  
>  all: $(UNITS) $(DYNAMIC_UNITS) pbs-enterprise.list
>  
> diff --git a/etc/removable-device-attach at .service.in b/etc/removable-device-attach at .service.in
> new file mode 100644
> index 00000000..12fa103f
> --- /dev/null
> +++ b/etc/removable-device-attach at .service.in
> @@ -0,0 +1,6 @@
> +[Unit]
> +Description=Try to mount the removable device with uuid '%i'.
> +
> +[Service]
> +Type=simple
> +ExecStart=/usr/sbin/proxmox-backup-manager removable-device mount-uuid %i
> -- 
> 2.30.2





More information about the pbs-devel mailing list