URL: <https://savannah.gnu.org/bugs/?61620>
Summary: Grub2 fails to detect LVM volumes with: error: disk `lvmid/*/*' not found Project: GNU GRUB Submitted by: rogier777 Submitted on: Sat 04 Dec 2021 10:44:41 PM UTC Category: Disk & Partition Severity: Major Priority: 5 - Normal Item Group: Software Error Status: None Privacy: Public Assigned to: None Originator Name: Originator Email: Open/Closed: Open Release: Release: Git master Discussion Lock: Any Reproducibility: Every Time Planned Release: None _______________________________________________________ Details: See also https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=987008 When handling a regular LVM volume, Grub can fail with the message: error: disk `lvmid/******-****-****-****-****-****- ******/******-****-****-****-****-****-******' not found. If the condition which triggers this exists, grub-probe will report the error mentioned above. Similarly, the grub boot code will fail to detect LVM volumes, resulting in a failure to boot off of LVM disks/partitions. The condition can be created on any LVM VG by an LVM configuration change, so any system with /boot on LVM can become unbootable at 'any' time (after any LVM configuration change). ==== Cause === The problem is caused by an incorrect computation of mda_end in lvm.c, when the metadata area wraps around. Patch included below. === How to reproduce === Run the (first) attached script (as root!). On my system, it reliably fails at lv81. If not, the second script can be run until the error occurs. It requires a parameter indicating the number of iterations. WARNING: Don't run the scripts if you don't understand what they do. WARNING 2: The name of the loop device may have to be changed before running the script! === Patch === I hereby release this patch to the public domain, to (hopefully) avoid any copyright assignment problems. --------------------------------------------------- Index: grub2-2.02+dfsg1/grub-core/disk/lvm.c =================================================================== --- grub2-2.02+dfsg1.orig/grub-core/disk/lvm.c +++ grub2-2.02+dfsg1/grub-core/disk/lvm.c @@ -253,7 +253,7 @@ error_parsing_metadata: p = q = (char *)ptr; - if (grub_add ((grub_size_t)metadatabuf, (grub_size_t)mda_size, &ptr)) + if (grub_add (ptr, (grub_size_t)grub_le_to_cpu64 (rlocn->size), &ptr)) goto error_parsing_metadata; mda_end = (char *)ptr; ---------------------------------------------------- _______________________________________________________ File Attachments: ------------------------------------------------------- Date: Sat 04 Dec 2021 10:44:41 PM UTC Name: setup-report Size: 729B By: rogier777 <http://savannah.gnu.org/bugs/download.php?file_id=52432> ------------------------------------------------------- Date: Sat 04 Dec 2021 10:44:41 PM UTC Name: test-grub Size: 414B By: rogier777 <http://savannah.gnu.org/bugs/download.php?file_id=52433> _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?61620> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/