Weird discrepancy between /dev/mapper/* and /dev/dm-* devices breaks lilo
Hi,
When issuing the same dmsetup commands on two device nodes with the same major/minor, the results are puzzling:
bee:~# file /dev/dm-1 /dev/dm-1: block special (254/1) bee:~# file /dev/mapper/bee--sata-refuge /dev/mapper/bee--sata-refuge: block special (254/1) bee:~# dmsetup table /dev/mapper/bee--sata-refuge 0 131072 linear 8:2 117440896 bee:~# dmsetup table /dev/dm-1 dm_task_set_name: Device /dev/dm-1 not found Command failed
(Same problem with short names:)
bee:~# dmsetup table bee--sata-refuge 0 131072 linear 8:2 117440896 bee:~# dmsetup table dm-1 device-mapper: table ioctl failed: No such device or address Command failed
This is a problem hitting lilo relatively hard as it has logic to ignore devices with the same major/minor; that is, if lilo sees "dm-1" first and then the corresponding /dev/mapper device, it will drop any reference to the mapper device. As having /boot on RAID 1 for lilo requires calling "dmsetup table" on the root device, this breaks lilo for a lot of people.
Of course, it would be possible to patch lilo to explicitely skip /dev/dm-* devices, but it seems this would be a workaround instead of the real fix.
This is under 2.6.18 and libdevmapper 1.02.12-1.
You can find more details in Debian bug
<http://bugs.debian.org/401393>, the bug was triggered by the addition of the /dev/dm-* device in udev (see <http://bugs.debian.org/392623>),
and affects other distributions as well,
<https://launchpad.net/distros/ubuntu/+source/lilo-installer/+bug/23835>.
(RAID 1 support in lilo comes from a third-party patch added in the Debian packaging.)
Bye,
Signature · 1 line
Loïc Minier <[email protected]>
Quoted 3 lines · Loïc Minier
bee:~# dmsetup table dm-1 device-mapper: table ioctl failed: No such device or address Command failed
(responding to self)
Is lilo supposed to call something like "dmsetup info" on the major/minor of dm-1 to translate this into a device mapper "device_name"? E.g.:
bee:~# file /dev/dm-1 /dev/dm-1: block special (253/1) bee:~# dmsetup info -c --noheadings -j 253 -m 1 bee--sata-refuge:253:1:L--w:1:1:0:LVM-beM0G1UiiCSaWGi1RkcyX3EhGET9D7GbyLPU0wXiCs OswbyC2LoECortBYa3prWw bee:~# dmsetup table bee--sata-refuge 0 131072 linear 8:2 117440896
Or is the device-mapper code supposed to accept device names from /dev as parameters?
Signature · 1 line
Loïc Minier <[email protected]>
Alasdair G Kergon
maintainerQuoted 2 lines · Loïc Minier
When issuing the same dmsetup commands on two device nodes with the same major/minor, the results are puzzling:
The device-mapper ioctls allow mapped devices to be referenced in three ways:
name
uuid
major+minor
The uuid is optional.
dmsetup provides a command line wrapper around the ioctls. It also maintains the /dev/mapper directory, creating inodes there called 'name'. It understands the above three ways of referencing devices: it does not depend on the existing contents of '/dev'.
Some distributions chose to configure udev to create /dev/dm-N inodes where N is the minor number. (I have always discouraged that as a recipe for
confusion: I believe that using configurable names is a better approach.)
Alasdair
Signature · 1 line
[email protected]
Alasdair G Kergon
maintainerQuoted 3 lines · Loïc Minier
supposed to call something like "dmsetup info" on the major/minor of dm-1 to translate this into a device mapper "
device_name"? E.g.:
That would work.
Quoted 2 lines
Or is the device-mapper code supposed to accept device names from /dev as parameters?
It does not do that at the moment. Perhaps there's a case for adding inode->device number conversions to dmsetup: You're the first person to suggest this.
Alasdair
Signature · 1 line
[email protected]
Quoted 5 lines · Alasdair G Kergon
Quoted 2 lines
Or is the device-mapper code supposed to accept device names from /dev as parameters?
It does not do that at the moment. Perhaps there's a case for adding
inode->devicenumber conversions to dmsetup: You're the first person to suggest this.
Ok; lilo isn't calling the dmsetup command, but uses libdevmapper directly, so even if you add support for any /dev device name in dmsetup, it wont help lilo. Hence, I've changed the problematic dm task call to use major/minor instead of the name (see attached patch) and will wait for feedback from users as I don't have such a setup.
So, thanks for clarifying this! I'm not sure it would be a good idea to accept device mapper names as well as /dev names in dmsetup as I think this would confuse things. I personally like it that dmsetup reflects what the ioctl accepts, nothing more, nothing less.
PS: I was wrong when saying that the code is in a Debian specific patch, the patch is only historic and the problematic code is in the lilo mainline
Signature · 1 line
Loïc Minier <[email protected]>
Quoted 3 lines · Alasdair G Kergon
Some distributions chose to configure udev to create
/dev/dm-Ninodes where N is the minor number. (I have always discouraged that as a recipe for
confusion: I believe that using configurable names is a better approach.)
I seem to recall even RedHat or Fedora attempted to add these devices, but I suppose you know best. The reasons why these were added in udev in Debian and Ubuntu are mentionned in http://bugs.debian.org/392623,
but in short gnome-mount required this to work; perhaps this should be fixed in gnome-mount. The details are in a comment of #401393 though:
<http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=401393;msg=37>
(attaching the patch I mentionned in the preceding mail but forgot, sorry)
Signature · 1 line
Loïc Minier <[email protected]>
debian/patches/00list +1 -0
@@ -31,0 +32 @@ +20_devmapper-use-major-minor
debian/changelog +8 -0
@@ -1,3 +1,11 @@ +lilo (1:22.7.3-1.4) unstable; urgency=low + + * Non-maintainer upload. + * New dpatch, 20_devmapper-use-major-minor, to address device-mapper devices + via major/minor instead of name for DM_DEVICE_TABLE; closes: #401393. + + -- Loic Minier <[email protected]> Wed, 31 Jan 2007 15:21:06 +0100 + lilo (1:22.7.3-1.3) unstable; urgency=low * Non-maintainer upload to fix a few more l10n issues.
debian/patches/20_devmapper-use-major-minor.dpatch +22 -0
@@ -0,0 +1,22 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 20_devmapper-use-major-minor.patch.dpatch by Loic Minier <[email protected]> +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: No description. + +@DPATCH@ +diff -urNad lilo-22.7.3~/geometry.c lilo-22.7.3/geometry.c +--- lilo-22.7.3~/geometry.c 2007-01-31 15:20:37.000000000 +0100 ++++ lilo-22.7.3/geometry.c 2007-01-31 15:20:43.000000000 +0100 +@@ -930,8 +930,9 @@ + slash++; + else + slash = dmdev; +- if (!dm_task_set_name(dmt, slash)) +- die("device-mapper: dm_task_set_name(\"%s\") failed",dmdev); ++ if (!dm_task_set_major(dmt, MAJOR(device)) || ++ !dm_task_set_minor(dmt, MINOR(device))) ++ die("device-mapper: dm_task_set_major() or dm_task_set_minor() failed"); + if (!dm_task_run(dmt)) + die("device-mapper: dm_task_run(DM_DEVICE_TABLE) failed"); +
Quoted 4 lines · Loïc Minier
Quoted 3 lines · Alasdair G Kergon
Some distributions chose to configure udev to create
/dev/dm-Ninodes where N is the minor number. (I have always discouraged that as a recipe for
confusion: I believe that using configurable names is a better approach.)
i tend to agree with Alasdair on the above point
Quoted 6 lines
I seem to recall even RedHat or Fedora attempted to add these devices, but I suppose you know best. The reasons why these were added in udev in Debian and Ubuntu are mentionned in http://bugs.debian.org/392623,
but in short gnome-mount required this to work; perhaps this should be fixed in gnome-mount. The details are in a comment of #401393 though:
<http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=401393;msg=37>
I also looked at the patch to support LUKS into hal and i tought it was badly written (forgot the gory details)
Quoted 2 lines
(attaching the patch I mentionned in the preceding mail but forgot, sorry)
in any case i lost the argument, so i think that i will use your patch, at least until grub2 gets support for the eye-candy gfxboot, then i hope to toss lilo into oblivion.
Thanks for providing the patch,
L.
Signature · 6 lines
Luca Berra -- [email protected] Communication Media & Services S.r.l. /"\ \ / ASCII RIBBON CAMPAIGN X AGAINST HTML MAIL / \