[Bug 1427859] Comment bridged from LTC Bugzilla
bugproxy
bugproxy at us.ibm.com
Wed Mar 11 12:19:47 UTC 2015
------- Comment From mauricfo at br.ibm.com 2015-03-11 12:13 EDT-------
Hi,
Unfortunately this is not a bug (although it really seems so :).
The rationale..
There are 2 distinct/orthogonal things:
1) Listing the partitions in a disk
2) Creation of the block devices for them (i.e., /dev/something)
They happen to diverge with multipath because of the *option* to choose
the disk-partition separator.
This separator is introduced when the wholedisk device name's last
character is a number/digit (i.e., /dev/mpath0), so you can
differentiate 'mpath1 partition 1' from 'mpath 11 wholedisk' (that,
without a separator, are 'mpath11').
It is relatively unknown because the popular wholedisk device names are
sd[a-z] / vd[a-z] / LVM volume that ends in [a-z]).
Back to the 2 things, when a tool reads a disk's partition table, and then prints it, the *tool* chooses the format.
Notice that /listing/ has *nothing* to do with the actual block devices (/dev/something) of the disk, and must not, because the partitions may not exist (e.g., you're partitioning the disk for the first time, and listing the partitions you created).
In summary, there's no rule saying "print it as it exists/or would exist" in /dev.
With sd[a-z] et al, there's usually no mismatch, because there's no separator.
Notice kpartx has the -p option:
-p set device name-partition number delimiter
kpartx is one of the tools that gives you that option (which is great, but actually leads to the "problems" noticed)
Most other tools just hard-code 'p' and that's all.
And, on kparx, the /default/ is 'p'., but you can choose.
So, if you list multipath partitions w/ kpartx, choose the separator:
# kpartx -l -p SEPARATOR /dev/mapper/mpath0
mpath0SEPARATOR1 : 0 14336 /dev/mapper/mpath0 2048
mpath0SEPARATOR2 : 0 64239616 /dev/mapper/mpath0 16384
mpath0SEPARATOR3 : 0 2850816 /dev/mapper/mpath0 64256000
Then, we get to thing #2, the creation of the block devices.
On multipath, again, this is different from other/non-multipath block
devices, because there must be some more talk with the kernel (to create
the device mappings, I guess, and assign them to a given block device,
/dev/something).
This is done with kpartx. See its manpage:
This tool, derived from util-linux' partx, reads partition tables on
specified device and create device maps over partitions segments
detected. It is called from hotplug upon device maps creation and
deletion.
So, it reads the partition table (which just says 'partition 1, 2, 3'; no separator informed, of course),
and then (different thing) creates block devices in /dev.
This also uses the '-p' option to choose a separator.
If you look at the udev rules, which create the block devices when a multipath disk is detected (i.e., run 'multipath'):
$ grep -H -- -part /lib/udev/rules.d/*kpartx*
/lib/udev/rules.d/95-kpartx.rules: SYMLINK+="disk/by-id/$env{DM_TYPE}-$env{DM_NAME}-part$env{DM_PART}"
/lib/udev/rules.d/95-kpartx.rules: RUN+="/sbin/dmsetup ls --target multipath --exec '/sbin/kpartx -a -p -part' -j %M -m %m"
/lib/udev/rules.d/95-kpartx.rules: RUN+="/sbin/kpartx -a -p -part /dev/$kernel"
Which just says: use '-part' when creating the block devices for
multipath partitions on /dev/mapper.
Finishing..
The bug title is "Need a common format for partition listing using
kpartx,fdisk.distrib and ls -l "
That's mistaken, because "ls -l" is not listing partitions, it is listing "block devices" in /dev/mapper/.
Sorry, but that's it. :)
It just happens to be consistent w/ partitioning tools for non-multipath
partitions for a coincidence / no need for disk-partitoin separator.
That's all.
And, BTW, *if* you want to *list* existing multipath partitions in a way that's coherent w/ what's in /dev/mapper,
you have to find what's the separator adopted for udev (in this case, "-part"), and use it in "kpartx -l -p -part".
$ sudo kpartx -l -p -part /dev/mapper/mpath0
mpath0-part1 : 0 14336 /dev/mapper/mpath0 2048
mpath0-part2 : 0 64239616 /dev/mapper/mpath0 16384
mpath0-part3 : 0 2850816 /dev/mapper/mpath0 64256000
But remember, those are different things :)
If some tooling broke because of that, it's not generic enough; and must be fixed.
(for reference, libparted has to check whether a partition/device is on device-mapper for listing its name.)
--
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to multipath-tools in Ubuntu.
https://bugs.launchpad.net/bugs/1427859
Title:
ISST-SAN:Need a common format for partition listing using
kpartx,fdisk.distrib and ls -l
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/multipath-tools/+bug/1427859/+subscriptions
More information about the Ubuntu-server-bugs
mailing list