bugGNU GRUB - Bugs: bug #61620, Grub2 fails to detect LVM volumes...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #61620: Grub2 fails to detect LVM volumes with: error: disk `lvmid/*/*' not found

Submitter:  Rogier <rogier777>
Submitted:  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: 
Open/Closed:  Open Release:  Git master
Release:  Reproducibility:  Every Time
Planned Release:  None

Fri 20 Jan 2023 09:44:16 AM UTC, comment #1: 

Is there a chance this fix could be applied? I was bitten by the issue referred to in the linked Debian bug and apparently fixed by this patch a few days ago.

Thanks for your consideration.

Ronny Adsetts <ronnyadsetts>
Sat 04 Dec 2021 10:44:41 PM UTC, original submission:  

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;
----------------------------------------------------

Rogier <rogier777>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #52432:  setup-report added by rogier777 (729B - application/octet-stream)
file #52433:  test-grub added by rogier777 (414B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by ronnyadsetts (Posted a comment)
  • -email is unavailable- added by rogier777 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-12-04 rogier777 Attached File- Added setup-report, #52432
        Attached File- Added test-grub, #52433

    Back to the top

    Powered by Savane 3.14-3b9d.
    Corresponding source code