Bug 1303157
Summary: | fdisk does not wipe existing signatures before creating partition table | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux 7 | Reporter: | John Pittman <jpittman> |
Component: | util-linux | Assignee: | Karel Zak <kzak> |
Status: | CLOSED UPSTREAM | QA Contact: | qe-baseos-daemons |
Severity: | high | Docs Contact: | |
Priority: | unspecified | ||
Version: | 7.2 | CC: | agk, heinzm, jbrassow, jwaterwo, msnitzer, prajnoha, prockai, qguo, zkabelac |
Target Milestone: | rc | ||
Target Release: | --- | ||
Hardware: | x86_64 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2017-01-17 14:26:38 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: | |||
Bug Depends On: | |||
Bug Blocks: | 1298243, 1393867, 1400961 |
Description
John Pittman
2016-01-29 17:46:32 UTC
The reason here is that blkid gives preference to partition table over LVM2 PV signature if both are found on disk. When using lvmetad, LVM2 is in event-based autoactivation mode which means it runs "pvscan --cache -aay" (via lvm2-pvscan@major:minor.service) for each device which is identified by blkid as LVM2_member. The "pvscan --cache -aay" informs lvmetad about new PVs that are present in the system and if it finds that this is the last PVs which makes the VG complete, it activates the whole VG. If the device is not identified as LVM2_member by blkid, then there's no "pvscan" triggered and hence lvmetad doesn't know about such device at all and also it can't do any autoactivation. The exact problem here is mixing two different signatures which should be always avoided. For example, lvm2 wipes all existing signatures before creating a its own PV signature on that device. I suppose fdisk should be doing the same and it should either reject creation of partition tables if it finds that there's already an existing signature or it should provide a way to wipe it. LVM2 uses libblkid to do this detection of existing signatures on device before it continues to create its own signature. Simply, it's not correct to mix several signatures. You would need to remove partition table completely for this to work again (the sequence you reported "d 1 w" just removes the partition, not the partition table). You can also check the output of: blkid -o udev <path_to_device> wipefs <path_to_device> For example: # blkid -o udev /dev/sda ID_PART_TABLE_UUID=c08a9ff6 ID_PART_TABLE_TYPE=dos # wipefs /dev/sda offset type ---------------------------------------------------------------- 0x1fe dos [partition table] 0x218 LVM2_member [raid] UUID: GBi2bu-fdld-R4UY-HU66-od4x-G4Nw-8aiwSc You will see that blkid gives you only one signature - blkid needs to return only one type to identify the device deterministically. The wipefs will list all signatures found. If more signatures are found, most of the time it's a pure bug - you can't even be sure that one signature is not overlapping part of another signature and hence damaging it. As said above, if we want to go the safe way, we either need: A: fdisk to do signature detection and possible wiping before it creates its own signatures (or it should just call "wipefs -a <path_to_device>" before it creates its own signature) B: blkid to return with an error if more signatures are found when using "blkid -o udev" which is used in udev to export information about device. Or if it finds partition table (without any partitions defined) and LVM2 signature, it should give preference to LVM2. Parted is better here - when it creates partition tabel, it also wipes LVM2 PV signature, hence we end up with one signature and deterministic state of the device, not mixing the two signatures together. Note: the reason this scenario works without lvmetad is because in this case, we do not rely on blkid to tell us whether this is a PV or not - LVM commands do the scan on their own and if it sees dos partition table *without any partitions* defined, it just ignores that and it gives preference to the LVM PV signature it finds next. If there was at least one partition defined, LVM would filter such device out and it would consider such device as not being able to hold PV signature at the same time. So that's for completeness why this doesn't work with lvmetad (where we rely on blkid result within udev rule execution) and why it works without it (where LVM2 scans for partition table itself). If this were changed, would cfdisk be changed as well? I checked sfdisk and couldn't find any option to delete partitions. Are there other partitioning tools that should be included? John (In reply to John Pittman from comment #5) > If this were changed, would cfdisk be changed as well? I checked sfdisk and > couldn't find any option to delete partitions. > Yes, if cfdisk doesn't do that already, it should as well... The current fdisk upstream prints warning and recommends wipefs if the device already contains a filesystem/LVM/ signature. It does not delete foreign signatures automatically -- maybe we can enable it. I don't plan to implement into libblkid any policies "if PT without partitions then prefer LVM" ... that's too complex and too crazy. It's better to force people to keep their disk without mess and wipe devices in partitioning tools and mkfs-like utils. Note for comment #0, delete all partitions does not mean that whole partition table is gone. It's pretty valid use-case to have empty partition table without partitions. Note that the current fdisk and cfdisk upstream wipe "bootbits" (area before the first sector). Since v2.28 fdisks wipe all device when executed in interactive mode and a new command line option --wipe=auto|never|always controls this behaviour. Unfortunately, this cannot be backported to RHEL7. Closing. fdisk has been improved in upstream tree, but it change is too invasive to backport to RHEL7. |