Comment 12 for bug 1371634

Revision history for this message
Scott Moser (smoser) wrote : Re: block devices appear twice

Ok, so Oleg and I were looking at a solution, and figured we'd give the "maybe it just works" path a try.
I installed a system, it installed onto /dev/sda (as this bug shows).
I then 'apt-get install multipath-tools-boot'

I rebooted, with the 'root=LABEL=cloudimg-rootfs' on the cmdline (as normal). It died in initramfs unable to find root. The full bootlog at http://paste.ubuntu.com/11547135/ .

The multipath-tools-boot package puts some code into the initramfs (/usr/share/initramfs-tools/scripts/local-top/multipath) that does this:

| if [ -x /sbin/kpartx -a -x /sbin/dmsetup ]; then
| /sbin/dmsetup ls --target multipath --exec "/sbin/kpartx -a -p -part" >/dev/null
| fi

That looks all well and good.

In the initramfs I did some debugging:
(initramfs) /sbin/dmsetup ls --target multipath
1IBM IPR-0 5EC2A900000000A0 (252, 1)
1IBM IPR-0 5EC2A90000000020 (252, 2)
1IBM IPR-0 5EC2A90000000080 (252, 5)
1IBM IPR-0 5EC2A90000000060 (252, 3)
1IBM IPR-0 5EC2A900000000C0 (252, 4)
1IBM IPR-0 5EC2A90000000040 (252, 0)

And then further debug, I find that dmsetup is calling kpartx seemingly correctly, but kpartx is I think messing up.

I was able to fix this by booting with:
  root=UUID=f7c3b31d-3411-420e-a57d-9318e43248ba ro console=hvc0 break=post-multipath

Then doing:

(initramfs) cat /tmp/myprog
#!/bin/sh
tgt="$1"
fixed=$(echo "$tgt" | sed 's, ,\\x20,g')
{
echo "input: '$tgt'"
echo "fixed: '$fixed'"
echo /sbin/kpartx -a -v -p -part "$fixed"
/sbin/kpartx -a -v -p -part "$fixed"
ret=$?
echo $ret
} >> /tmp/log 2>&1
exit $ret

(initramfs) rm /tmp/log
(initramfs) /sbin/dmsetup ls --target multipath --exec "/bin/myprog"
(initramfs) cat /tmp/log
input: '/dev/mapper/1IBM IPR-0 5EC2A900000000A0'
fixed: '/dev/mapper/1IBM\x20\x20\x20\x20\x20IPR-0\x20\x20\x205EC2A900000000A0'
/sbin/kpartx -a -v -p -part /dev/mapper/1IBM\x20\x20\x20\x20\x20IPR-0\x20\x20\x205EC2A900000000A0
0
input: '/dev/mapper/1IBM IPR-0 5EC2A90000000020'
fixed: '/dev/mapper/1IBM\x20\x20\x20\x20\x20IPR-0\x20\x20\x205EC2A90000000020'
/sbin/kpartx -a -v -p -part /dev/mapper/1IBM\x20\x20\x20\x20\x20IPR-0\x20\x20\x205EC2A90000000020
0
input: '/dev/mapper/1IBM IPR-0 5EC2A90000000080'
fixed: '/dev/mapper/1IBM\x20\x20\x20\x20\x20IPR-0\x20\x20\x205EC2A90000000080'
/sbin/kpartx -a -v -p -part /dev/mapper/1IBM\x20\x20\x20\x20\x20IPR-0\x20\x20\x205EC2A90000000080
add map 1IBM IPR-0 5EC2A90000000080-part1 (252:6): 0 16384 linear /dev/mapper/1IBM\x20\x20\x20\x20\x20IPR-0\x20\x20\x205EC2A90000000080 2048
add map 1IBM IPR-0 5EC2A90000000080-part2 (252:7): 0 554268639 linear /dev/mapper/1IBM\x20\x20\x20\x20\x20IPR-0\x20\x20\x205EC2A90000000080 18432
0
input: '/dev/mapper/1IBM IPR-0 5EC2A90000000060'
fixed: '/dev/mapper/1IBM\x20\x20\x20\x20\x20IPR-0\x20\x20\x205EC2A90000000060'
/sbin/kpartx -a -v -p -part /dev/mapper/1IBM\x20\x20\x20\x20\x20IPR-0\x20\x20\x205EC2A90000000060
0
input: '/dev/mapper/1IBM IPR-0 5EC2A900000000C0'
fixed: '/dev/mapper/1IBM\x20\x20\x20\x20\x20IPR-0\x20\x20\x205EC2A900000000C0'
/sbin/kpartx -a -v -p -part /dev/mapper/1IBM\x20\x20\x20\x20\x20IPR-0\x20\x20\x205EC2A900000000C0
0
input: '/dev/mapper/1IBM IPR-0 5EC2A90000000040'
fixed: '/dev/mapper/1IBM\x20\x20\x20\x20\x20IPR-0\x20\x20\x205EC2A90000000040'
/sbin/kpartx -a -v -p -part /dev/mapper/1IBM\x20\x20\x20\x20\x20IPR-0\x20\x20\x205EC2A90000000040

Then ... after that, I have the devices I needed:
(initramfs) blkid
/dev/sda2: LABEL="cloudimg-rootfs" UUID="f7c3b31d-3411-420e-a57d-9318e43248ba" TYPE="ext4"
/dev/sdg2: LABEL="cloudimg-rootfs" UUID="f7c3b31d-3411-420e-a57d-9318e43248ba" TYPE="ext4"
/dev/mapper/1IBM\x20\x20\x20\x20\x20IPR-0\x20\x20\x205EC2A90000000080-part2: LABEL="cloudimg-rootfs" UUID="f7c3b31d-3411-420e-a57d-9318e43248ba" TYPE="ext4"

I exited from there, the remaining boot took over, and mounted the device mapper device as /.

All happy.

So, if there weren't a bug in kpartx we'd have a very easy solution in just installing the multipath-tools-boot package.
That said, it looks like user_friendly_names in /etc/multipath.conf might be relevant.