Open hamistao opened 6 days ago
Please correct me if I am wrong @simondeziel. This seems to be happening because when using a long block device name, the /dev/disk/by-id
only includes the first 16 characters of the device name (after escaping).
For example, using long-device-name1
as block device name would result in its path on /dev/disk/by-id
to look like 0QEMU_QEMU_HARDDISK_lxd_long--device--na
, and the same would happen for a second added device named long-device-name2
, overwriting the first /dev/disk/by-id
link and leaving the first device without a link on /dev/disk/by-id
.
This could be making multipath-tools assume both devices are the same and creating the inconsistencies described above.
@hamistao I dont think there is much we can do about this I'm afraid.
@tomponline I agree, I don't think we can't fix this without changing /dev/disk/by-id
paths. I wanted to open this in case someone else could think of a solution.
If this is a limitation of udev there isn't much we can do.
@hamistao as you described, I think that due the /dev/disk/by-id
symlinks ending up as the same, the 2nd disk sharing the name prefix is the one taking over the by-id
symlink. This in turn seems to hint multipath
into thinking there are many paths leading to the same disk.
Required information
Issue description
When using two block devices with names that share a prefix of 16 characters (after escaping) and also using multipath, the
/dev/disk/by-id/*
symlinks to those devices are identical resulting in a single symlink being created. The second device would now be accessed through/dev/dm-0
and not/dev/sdc
. Although the latter exists, making a filesystem on it fails and returns/dev/sdc is apparently in use by the system; will not make a filesystem here!
. That problem only occurs when multipath-tools is installed and removing it and restarting the VM fixes this. Note that the second device is still usable, but through/dev/dm-0
. So this may not be critical but it should be worth some discussion to better understand what is happening.Steps to reproduce
lxc launch ubuntu:n vm --vm # Ubuntu images come with multipath-tools installed
longName="long-device-name"
lxc storage volume create default vol1 --type=block
lxc storage volume create default vol2 --type=block
sleep 30
lxc exec vm -- systemctl is-system-running --wait
lxc config device add vm "${longName}1" disk pool=default source=vol1
lxc config device add vm "${longName}2" disk pool=default source=vol2
lxc exec vm -- mkfs.ext4 /dev/sdc # Fails
lxc exec vm -- apt autopurge multipath-tools
lxc restart vm
lxc exec vm -- mkfs.ext4 /dev/sdc # Succeeds