On 2020-09-03 14:05:46 Roger Oberholtzer wrote:
A while back I posted a question about using /dev/disk/by-path to mount drives. I have udev rules to initiate a mount when a disk is inserted. My worry at the time was that the by-path values were not constant for a specific drive bay.
I have since verified that these are constant and correct. Activity in a specific drive bay always has the same by-path value. I should be able to mount a disk in a specific drive bay at the same place.
However, the drives are still not being mounted correctly. I am using udev.
It seems that one must use systemd-mount when mounting drives in udev rules. So I am doing that.
My udev rule runs a small script that lists where the by-path entry is pointing (e.g., sdm1) before the systemd-mount command runs.
I can verify that the by-path entry is pointing to the correct sdX entry.
However, the systemd-mount command mounts some other sdX, not the one it should - the one that is pointed to. It is also not the old value from a previous drive in that drive bay. It seems random. Or at least I have not seen a pattern.
Sample udev rule (on one line in the rule file called 99-hydra-disk-array.rules):
ACTION=="add", SUBSYSTEM=="block", ENV{ID_PATH}=="pci-0000:b3:00.0-sas-exp0x5003048020cc467f-phy5-lun-0", ENV{ID_PART_ENTRY_NUMBER}=="1", RUN+="/damount %E{ID_PATH}-part1 a 1"
There are 24 rules, one for each drive bay, In this rule, the by-path is pci-0000:b3:00.0-sas-exp0x5003048020cc467f-phy5-lun-0, and I want partition 1. It should be mounted on /array/a1
Script it runs (/damount):
#!/bin/sh
DEV=$1 COL=$2 ROW=$3
DISK=$COL$ROW
/usr/bin/mkdir -p /array/$DISK ls -l /dev/disk/by-path/$DEV >> /tmp/damount.log
/usr/bin/systemd-mount --no-block /dev/disk/by-path/$DEV /array/$DISK
# This does not work at all # mount /dev/disk/by-path/$DEV /array/$DISK
I see in /tmp/damount.log that the by-path is pointing to a new sdx1 value. But it is some other sdx1 that is mounted.
The commented mount command in the script is what one might think they could use. But in the udev rule, when it is used, nothing gets mounted. So we use systemd-mount
This is on leap 15.1.
I really do not know how to proceed. I can't see what I can do to make the mount command not mount what it is told to mount.
The system journal shows the expected sdX value when the disk is inserted. But the mount is something else.
I suspect some systemd issue. But where?
Could there be some issue if one inserts multiple disks at the same time that confuses systemd-mount? The by-path and where it points is correct when multiple disks are inserted (as listed by the udev rule). So the confusion must be elsewhere. And all that's left is systemd-mount...
Any words of wisdom?
-- Roger Oberholtzer
I know nothing about systemd-mount, but could these two options have any relevance? | --user | Talk to the service manager of the calling user, rather than the service manager of the system. | | --system | Talk to the service manager of the system. This is the implied default. The second mentions "implied" default, so it might or might not be in effect due to other options? As usual, the documentation is pitifully inadequate. Leslie -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org