Dne 17. 12. 24 v 13:45 Michael Chang napsal(a):
On Tue, Dec 17, 2024 at 11:21:26AM +0100, Zdenek Kabelac wrote:
Dne 17. 12. 24 v 10:13 Glass Su napsal(a):
On Dec 17, 2024, at 16:34, Heming Zhao <heming.zhao@xxxxxxxx> wrote:
Hi LVM2 maintainers,
One of SUSE's customers encountered an issue with LVM2. The user created several partitions, one of which was marked as "BIOS boot" (4) instead of "LINUX LVM" (8E). Subsequently, the user ran pvcreate/vgcreate/lvcreate on this partition. During a system update, grub2-install installed GRUB2 in the "BIOS boot" partition, resulting in LVM2 metadata corruption.
The root cause of this issue is that grub2-install targets the "BIOS boot" partition when this lvm2 device is specified for installation. If the user had initially marked the partition as "LINUX LVM", grub2-install would not have chosen this partition.
On the other hand, it would be beneficial if LVM2 could implement a new filter or a filter function to detect and exclude the "BIOS boot" partition from being considered a valid target for LVM2 device creation. This could involve issuing a warning or error message to alert the user of the potential conflict. This may also help user to notice the issue more easily.
Hi
lvm2 is using blkid to detect 'present' signature on a block device - and
normally prompt to confirm wiping such signature.
We may possibly add similar logic for 'partition signatures'.
However there is still the plain fact that lvm2 with --force or even just
'--yes' option is assumed to simply proceed and clean&clear such
conflicting signatures and simply makes the block device to be a PV.
All that said IMHO primary bug here is within 'grub2-install' which simply
should not be blindingly overwriting block device which is in use - this
should be fixed ASAP as there is the biggest risk of data loss, although I
guess everyone is using 'grub2-install --force' - as without this option
(even in my personal experience) is typically refusing to do any work....
IMHO, the BIOS Boot partition is dedicated to grub boot code and cannot
be shared with other software. Any attempt other than grub writing to
Hi
Sorry to say this, but the fact the 'someone' has created 'GUID' for GPT with
the name 'BIOS boot' doesn't really make anything in the Linux world - so far
I was not even aware such partition type exists (not using this myself).
It's never even been submitted to lvm2 as something to be understood by tool
till this thread.
There are over 220 types shown by 'cfdisk' just for GPT and there is a
completely different set for DOS partition types...
So how should we know which type is lvm2 allowed to 'use' freely ?
Should we now store somewhere those 'hundreds' GUID where there is something
with Linux in its name ?
I don't think this is a practical thing to do in lvm2 nor in many other
userland tools that are doing something with block devices.
There should likely be something in blkid telling other Linux tools 'don't
touch this device unless you are XYZ' eventually you use some --force override
option.
For LVM root with legacy BIOS boot, having a BIOS Boot partition is
mandatory, otherwise grub won't have usable space to embed the boot code
in the GPT partition layout, and you won't be able to boot or access a
functional system in the first place. That said, the BIOS Boot partition
is in use by grub before it is mistakenly used to create a PV and extend
the LVM root onto it. It is unlikely that GRUB is overwriting it. In
such cases, it's more likely the other way around.
Well protection needs to be from all sides here - otherwise it makes no sense.
When the grub sees some signature, it must be telling to a user and not just
let user to loose his data blindly.
And in the same way blkid should expose installed grub loader - currently the
partition with installed grub looks 'empty' with blkid....
Regards
Zdenek