Bug 187781 - kpartx: can not cleanly delete partition mapping
Summary: kpartx: can not cleanly delete partition mapping
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: device-mapper-multipath
Version: 4.0
Hardware: All
OS: Linux
Target Milestone: ---
: ---
Assignee: Alasdair Kergon
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2006-04-03 16:03 UTC by Eddie Williams
Modified: 2010-01-12 02:24 UTC (History)
9 users (show)

Clone Of:
Last Closed: 2006-04-20 20:27:00 UTC

Attachments (Terms of Use)

Description Eddie Williams 2006-04-03 16:03:46 UTC
Description of problem:  With Red Hatl EL 4 Update 3 the system is automatically
loading the partition tables with kpartx during bootup.  However the partition
delimiters that are being created are not always what I want.  I want the
delimiter to have a "p", aka /dev/mapper/[uuid]p#.  I find some of my partitions
are created with no delimiter, aka /dev/mapper/[uuid]#.  I can delete the the
partition mapping (kpartx -d /dev/mapper/[uuid]) where the partition nodes are
removed (/dev/mapper/[uuid]#).  I am then able to create the mappings that I
like with the 'p' delimiter.  If I then try to delete the mappings again (kpartx
-d /dev/mapper/[uuid]) the partition nodes are not removed, aka
/dev/mapper/[uuid]p# is not removed.

I am trying to determine why the partitions are not always created with the 'p'
delimiter so I am running the commands multiple times trying to trace where it
is causing the "default" behavior.

Version-Release number of selected component (if applicable):

How reproducible:
every time

Steps to Reproduce:
1. kpartx -d /dev/mapper/[uuid]
2. kpartx -a -p 'p' /dev/mapper/[uuid]
3. kpartx -d /dev/mapper/[uuid]
Actual results:
$ ls -l /dev/mapper/3600508b300902930a70a82d7daac002c*
brw-rw----  1 root disk 253, 11 Apr  3 11:09
brw-rw----  1 root disk 253, 46 Apr  3 11:09

$ kpartx -d /dev/mapper/3600508b300902930a70a82d7daac002c
$ ls -l /dev/mapper/3600508b300902930a70a82d7daac002c*
brw-rw----  1 root disk 253, 11 Apr  3 11:09

$ kpartx -a -p 'p' /dev/mapper/3600508b300902930a70a82d7daac002c
$ ls -l /dev/mapper/3600508b300902930a70a82d7daac002c*
brw-rw----  1 root disk 253, 11 Apr  3 11:09
brw-rw----  1 root disk 253, 46 Apr  3 12:06

$ kpartx -d /dev/mapper/3600508b300902930a70a82d7daac002c
$ ls -l /dev/mapper/3600508b300902930a70a82d7daac002c*
brw-rw----  1 root disk 253, 11 Apr  3 11:09
brw-rw----  1 root disk 253, 46 Apr  3 12:06

Expected results:
I expected the second kpartx -d to remove the partition table and leave only the
device node for the full disk.

Additional info:

Comment 1 Ben Marzinski 2006-04-20 20:27:00 UTC
By default, kpartx should insert a 'p' as a delimiter if the last charater in
the device name is a number, otherwise it should use no delimiter. If you
manually specified the partition delimiter when you created the device, you must
also specify it when you remove the partition.

So instead of running
$ kpartx -d /dev/mapper/3600508b300902930a70a82d7daac002c
$ kpartx -d -p 'p' /dev/mapper/3600508b300902930a70a82d7daac002c

If this is not the way that kpartx is working for you, please reopen the bug.

Comment 2 Ben Marzinski 2006-04-20 21:19:42 UTC
Oh yeah, and if you want multipath to automatically create partitions with the 'p'
delimiter, you can just modify the kpartx call in /etc/dev.d/block/multipath.dev

When you remove the device with 'multipath -f', the partition will be removed as
well, regardless of the delimiter.

Also, you can use the user_friendly_names config file option to give the
multipath devices names like mpath1, mpath2, etc.  Since these names will always
end in a number, the partitions will always have a 'p' delimiter in them. Also,
these names are easier to remember and type out. However, while the mappings are
persistent, they may be different across machines (for instance, say that mpath1
refers to the device formerly named 3600508b300902930a70a82d7daac002c on node1.
While this will always be true on node1, on node2 it might be mpath2 that refers
to the device named 3600508b300902930a70a82d7daac002c) To avoid this, after all
the devices have been named by multipath, copy the /var/lib/multipath/bindings
file from one machine to the others. then these bindings will be consistent
across machines.

Note You need to log in before you can comment on or make changes to this bug.