Udev can run shell scripts as an action, use that when device is plugged in
and have smarter symlink naming logic in the script.

On Thu, 16 Nov 2023, 22:10 Moritz Both, <m...@aldebaran.de> wrote:

> Greetings,
>
> we use amanda with usb disks and manually change them every day. I
> configured udev to create a symlink to /dev/amanda-vtape when the disk
> is plugged in.
>
> In /etc/fstab I configured this device so it can be mounted to
> /mnt/amanda-vtape by the amanda user. This works for many years very
> well. Changer configuration is:
>
> define changer mnt-amanda-vtape {
>         tpchanger "chg-disk:/mnt/amanda-vtape"
>         property "num-slot" "1"
>         property "auto-create-slot" "yes"
>         property "removable" "yes"
>         property "mount" "yes"
>         property "umount" "yes"
>         property "umount-lockfile" "/var/lib/amanda/amanda-vtape.lock"
>         property "umount-idle" "1"
>         device-property "ENFORCE_MAX_VOLUME_USAGE" "false"
> }
>
> Nowerdays the people changing the disks frequently work at home. So it
> would be nice to plug in more than one disk and have a tape changer scan
> for more than one disk. I understand there is no changer included in
> amanda which is directly capable of that.
>
> I tried to use chg-aggregate, duplicated the above changer, but changed
> the mount point and lock file, and created this changer:
>
> define changer mnt-amanda-morethanone-vtape {
>          tpchanger "chg-aggregate:{mnt-amanda-vtape,mnt-amanda-vtape2}"
>          property "state-filename" "/var/lib/amanda/aggregate-state"
> }
>
> Experiments with this suggest that on failure to mount a disk for the
> first chg-disk, it aborts with error and does not try the other one:
>
> root@peapod:~# su backup -s /bin/bash -c "/usr/sbin/amcheck DailySet1"
> Amanda Tape Server Host Check
> -----------------------------
> NOTE: Holding disk '/mnt/amandaholdingdisk/hd/DailySet1': 2960 MB disk
> space available, using 2960 MB
> mount: /mnt/amanda-vtape2: must be superuser to use mount.
> ERROR: mnt-amanda-vtape2: No removable disk mounted on '/mnt/amanda-vtape2'
> Server check took 0.349 seconds
>
> Shoudn't the aggregate changer try the next changer in this case? (The
> error message "must be superuser" can be ignored, when the device
> symlink from udev exists, it works.)
>
> Also, I cannot think of a way to tell udev to create stable distinct
> device symlinks for more than one arbitrary usb disk. I could use
> /dev/sdc, /dev/sdd... but this is not very reliable if someone adds a
> disk to the system. It would be possible to create nodes like
> /dev/amanda-vdisk-3.1.2-0... or so (using the linux system device path)
> but how could amanda find these? After all, chg-disk needs the mount
> point, not the device node.
>
> Current amanda version: 3.5.1
> System: Debian bullseye
>
> udev config:
> KERNEL=="sd[a-z]", SUBSYSTEMS=="usb", DRIVERS=="usb-storage",
> SYMLINK+="amanda-vtape-disk", OWNER="backup", GROUP="backup
>
> /etc/fstab:
> /dev/amanda-vtape       /mnt/amanda-vtape       ext4
> noauto,owner,nofail     0 2
>
>
> Any hints? Thanks in advance.
> Moritz
>
>
>
> --
> aldebaran Programmierung & IT-Lösungen GmbH
> Softwareentwicklung / Individualsoftware
>
> mail:    i...@aldebaran.de     https://www.aldebaran.de
> Tel:     +49-511-270 416-0     Fax:  +49-511-270 416-33
> Adresse: Hanomaghof 2          Ort:    D-30449 Hannover
>
> Geschäftsführung: Moritz Both    -    Dr. Torsten Crass
>                    Barbara Kraus  -  Ursula (Usch) Wildt
>
> Handelsregister:        Amtsgericht Hannover HRB 56 991
>
> Informationen zur Verarbeitung personenbezogener Daten:
> https://www.aldebaran.de/datenschutz/
>

Reply via email to