[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
Foundations Bugs, 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

Status in multipath-tools package in Ubuntu:
  New

Bug description:
  == Comment: #0 - LEKSHMI C. PILLAI <lekshmi.cpillai at in.ibm.com> - 2015-02-25 09:02:18 ==
  This is a KVM guest with Ubuntu 15.04.

  I am facing issues with format with partition listing using different
  commands

  In zap06 I created partitions on mpath29 using fdisk.distrib

  Before partition creation:

  root at zap06:/dev/mapper# fdisk.distrib  -l /dev/mapper/mpath29---------->
  Disk /dev/mapper/mpath29: 15 GiB, 16106127360 bytes, 31457280 sectors
  Units: sectors of 1 * 512 = 512 bytes
  Sector size (logical/physical): 512 bytes / 512 bytes
  I/O size (minimum/optimal): 512 bytes / 512 bytes

  root at zap06:/dev/mapper# kpartx -r /dev/mapper/mpath29--------------->
  root at zap06:/dev/mapper# ls -l mpath29--------------------------------->
  lrwxrwxrwx 1 root root 7 Feb 24 08:46 mpath29 -> ../dm-6
  root at zap06:/dev/mapper# 

  After Partition  creation:

  root at zap06:/dev/mapper# fdisk.distrib -l
  /dev/mapper/mpath29--------------->

  Disk /dev/mapper/mpath29: 15 GiB, 16106127360 bytes, 31457280 sectors
  Units: sectors of 1 * 512 = 512 bytes
  Sector size (logical/physical): 512 bytes / 512 bytes
  I/O size (minimum/optimal): 512 bytes / 512 bytes
  Disklabel type: dos
  Disk identifier: 0xce509b1c

  Device                Boot    Start      End  Sectors Size Id Type
  /dev/mapper/mpath29p1          2048     2048        0   0B 83 Linux
  /dev/mapper/mpath29p2          4096 10489855 10485760   5G 83 Linux
  /dev/mapper/mpath29p3      10489856 20975615 10485760   5G 83 Linux

  root at zap06:/dev/mapper# kpartx -r /dev/mapper/mpath29
  mpath29p2 : 0 10485760 /dev/mapper/mpath29 4096--------------
  mpath29p3 : 0 10485760 /dev/mapper/mpath29 10489856-------------------

  But instead of names like mpath29pX, the actual device nodes have
  names like mpath29-partX:

  root at zap06:/dev/mapper# ls -l /dev/mapper/mpath29*
  lrwxrwxrwx 1 root root       7 Feb 25 01:30 /dev/mapper/mpath29 -> ../dm-6
  brw-rw---- 1 root disk 252, 68 Feb 25 01:30 /dev/mapper/mpath29-part2
  brw-rw---- 1 root disk 252, 69 Feb 25 01:30 /dev/mapper/mpath29-part3
  root at zap06:/dev/mapper# 

  After that I created the filesystem on these partitions using the
  convention "mpath-part2".Its created successfully and I am able to
  mount it

  root at zap06:/dev/mapper# mount | grep "29"
  /dev/mapper/mpath29-part2 on /Fs29 type ext4 (rw)
  /dev/mapper/mpath29-part3 on /FS29_1 type xfs (rw)
  root at zap06:/dev/mapper# 

  Thanks
  Lekshmi

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/multipath-tools/+bug/1427859/+subscriptions



More information about the foundations-bugs mailing list