Description of problem:
In section 4 of chapter 2 of the 5.2 Configuration and Administration guide for using device-mapper multipath, it says that I can use pvcreate on a non-partitioned disk:
However when I try that I get an error:
[root@westwing ~]# pvcreate -f /dev/mapper/mpath8
Can't open /dev/mapper/mpath8 exclusively. Mounted filesystem?
However a pvcreate on a partition works ok:
[root@westwing ~]# pvcreate -f /dev/mapper/mpath8p1
Physical volume "/dev/mapper/mpath8p1" successfully created
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1.Configure device mapper
2.Run pvcreate /dev/mapper/mpath0
What happens is that the "partition" mpath0p1 is a linear device-map holding mpath0. This holder is the reason which the open-exclusive test tried by pvcreate fails.
This behaviour seems sane to me : if you set up a partition, use it. If the partition is not necessary remove it (which is clearly the preferred choice there)
Partition is removal should be handled using "kpartx -d ..." *and* "fdisk" on mpath0.
I do not quite well understand what which mapping you want to use:
- if you want use partitions on mpath8, use mpath8pX - it works
- if you want to use the whole device, do not create partition table on it,
do not activate partitions and use it directly
I expect kpartx maps partitions here, so device cannot be used while partitions
are active on it (partitions here are just device-mapper mappingns, so it locks
Try to run "kpartx -d /dev/mapper/mpath8" (remove partition mappings adn - as Christophe said - remove it with fdisk too) and run pvcreate again.
Does it solve the problem for you? Or the bug report is about some documentation issue only?
Your explaination is find but this seems like a documentation issue. You've explained why its locked in the first case but the error message is not very descriptive and until you've said their may be a lingering partition around and locked I would not have known how to resolve that.
Assigning to the documentation team. I couldn't hurt to mention this...
On June 16 I sent this note to Jonathan Brassow:
I'm looking at Bug 466970, which you assigned to me so that I would document that if you have partitions on a multipathed device you can't create a physical volume on the device directly.
So I'm thinking of adding a note to the DM-Multipath book. Right on this page:
The Note would say something like:
If you attempt to create an LVM physical volume on a whole device on which you have configured partitions, the pvcreate command will fail. If you wish to use the whole device rather than a partition, you must remove the existing partitions from the device with the "kpartx -d" and the fdisk commands.
Would that do it?
I have added the Note in command #5 to the 5.4 draft of the DM-Multipath document. It will be corrected when the RHEL 5.4 document is available.
I've opened Bug 517897 to pursue the issue of virtual machines further. With the release of RHEL 5.4, I'm closing this bug, since the original issued that opened it is addressed in the updated document.