Bug 18780 - grub.cfg entries uses "root=/dev/sdXY" (instead of "root=UUID...") which breaks boot if devices change order
Summary: grub.cfg entries uses "root=/dev/sdXY" (instead of "root=UUID...") which brea...
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: Cauldron
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: Mageia Bug Squad
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 416
  Show dependency treegraph
 
Reported: 2016-06-23 23:05 CEST by Barry Jackson
Modified: 2020-11-30 10:55 CET (History)
7 users (show)

See Also:
Source RPM: systemd, grub2
CVE:
Status comment:


Attachments
full diff of grub.cfg from install and from update-grub2 in system (2.89 KB, text/plain)
2016-06-28 18:31 CEST, Barry Jackson
Details
/etc/grub.d/10_linux debug patch (837 bytes, patch)
2016-07-17 16:33 CEST, Thierry Vignaud
Details | Diff
sh -x grub2-mkconfig output diff (w/ & w/o previous patch) (758 bytes, patch)
2016-07-17 16:34 CEST, Thierry Vignaud
Details | Diff
commands output (453 bytes, text/plain)
2016-07-17 16:36 CEST, Thierry Vignaud
Details
my autoinst file (5.14 KB, text/plain)
2016-07-17 16:42 CEST, Thierry Vignaud
Details
proposed patch (905 bytes, patch)
2016-07-18 19:04 CEST, Barry Jackson
Details | Diff
report_bug from install using grub2-common-2.02-0.git10457.11.mga6 (247.51 KB, application/octet-stream)
2016-07-19 23:51 CEST, Barry Jackson
Details

Description Barry Jackson 2016-06-23 23:05:12 CEST
Description of problem:
grub.cfg entries have e.g.

linuxefi /boot/vmlinuz-4.6.2-desktop-2.mga6 root=/dev/sdb4 ro   splash quiet noiswmd resume=UUID=1097bb8c-3820-4b3a-b796-b417c9aa56d

Note the "root=/dev/sdb4"

This breaks boot if another HD is added and the device enumeration changes.

At one time the root=/dev/... was needed, but now I find that simply removing it allows the system to boot normally despite the root having moved to /dev/sdc.

Since grub2 uses UUIDs by default there should really be no need to specify a device by ID as well - it sort of defeats the object.

Can anyone (Colin, tmb ?) comment on this?



Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
Comment 1 Thierry Vignaud 2016-06-24 04:41:58 CEST
I don't know what happen.
When running update-grub2, the right UUID entries are used.
Looks like it mis used /etc/fstab while installing.

CC: (none) => thierry.vignaud
Blocks: (none) => 416

Comment 2 Barry Jackson 2016-06-24 12:55:15 CEST
My bad - this was entry in my 'master' causing the issue not real system :\

Closing invalid.

Status: NEW => RESOLVED
Resolution: (none) => INVALID

Comment 3 Barry Jackson 2016-06-28 18:25:02 CEST
I have just hit this again and it seems to be the installer that creates menu entries with device IDs.

I just made a clean net-install from cauldron and backed up the grub.cfg from the newly installed system.

I then ran update-grub2 and took a diff of the two grub.cfg files.

The difference is the same for all entries so here is just one as example:

-linuxefi /boot/vmlinuz-4.6.3-desktop-1.mga6 root=/dev/sda4 ro   splash quiet noiswmd resume=UUID=1097bb8c-3820-4b3a-b796-b417c9aa56d8 vga=791
+	linuxefi /boot/vmlinuz-4.6.3-desktop-1.mga6 root=UUID=93ccb9dc-ef4e-401a-9e24-c4ee130f08ec ro   splash quiet noiswmd resume=UUID=1097bb8c-3820-4b3a-b796-b417c9aa56d8 vga=791

As you can see the original from the installer uses root=/dev/sda4
where the one created by update-grub2 uses root=UUID=....

I don't think this is relevant, but the install was on btrfs / with "Don't touch MBR/ESP", otherwise it was a default Plasma install to real hardware.

Resolution: INVALID => (none)
Status: RESOLVED => REOPENED

Comment 4 Barry Jackson 2016-06-28 18:31:32 CEST
Created attachment 8084 [details]
full diff of grub.cfg from install and from update-grub2 in system
Comment 5 Thierry Vignaud 2016-06-28 19:03:39 CEST
AFAIC that's a grub2's grub2-mkconfig bug.
/etc/fstab is the same in the installer & in the rebooted system
Comment 6 Thierry Vignaud 2016-06-28 19:05:14 CEST
You could do the installer up to the point it offers to reboot, then:
- got to tty2
- chroot /mnt
- cp /boot/grub2/grub.cfg{,.bak}
- update-grub2

if it's broken, you can run "urpmi strace" then "strace -e file -f /bin/update-grub2" in order to find out if it misses something in the install chroot
Comment 7 Barry Jackson 2016-06-28 23:07:09 CEST
All went OK up to the strace.
The original grub.cfg in the chroot used /dev/* and running update-grub2 in the chroot produced the same.
Running update-grub2 under strace (which was installed) did not give me any clues as it all scrolled past and there was not much scrollback available when it finished.
I re-ran the installer (opting to upgrade the same installation) and did the same again with the intention of getting a file output from strace, however this time grub.cfg had UUIDs.
I have spent hours and am giving up for today.
I will have another go tomorrow some time.
Comment 8 Thierry Vignaud 2016-06-29 09:08:22 CEST
The goal is to redirect strace to some /tmp/ file and the browse it with less
Comment 9 Thierry Vignaud 2016-07-04 15:59:55 CEST
It only seems to happen if one doesn't click the "bootloader" button in summary
Comment 10 Barry Jackson 2016-07-04 19:10:15 CEST
Ah - that's maybe why I have been struggling to reproduce as I always do in order to "not touch ESP" :\
Comment 11 Thierry Vignaud 2016-07-17 15:41:06 CEST
Maybe grub2-mkconfig got confused by being run in a chroot (discrepancy between /etc/fstab & /proc/mounts)?
Thierry Vignaud 2016-07-17 16:32:46 CEST

CC: (none) => mageia, tmb

Comment 12 Thierry Vignaud 2016-07-17 16:33:14 CEST
Created attachment 8195 [details]
/etc/grub.d/10_linux debug patch
Comment 13 Thierry Vignaud 2016-07-17 16:34:43 CEST
Created attachment 8196 [details]
sh -x grub2-mkconfig output diff (w/ & w/o previous patch)
Comment 14 Thierry Vignaud 2016-07-17 16:36:25 CEST
Created attachment 8197 [details]
commands output

one can see the uptodate output of blkid (which matches /etc/fstab) doesn't match outdated /dev/disk/by-uuid/ contents
Comment 15 Thierry Vignaud 2016-07-17 16:38:11 CEST
This discrepancy is what cause grub.cfg to contains root=/dev/vda6 instead of root=UUID=...

Colin, is there a way to make those links be updated?
Some kind of udevadm command?

Source RPM: grub2/dracut/systemd => systemd, grub2

Comment 16 Thierry Vignaud 2016-07-17 16:40:46 CEST
@Colin: you can reproduce all of this by doing an install where you recreate partitions, then go to summary, etc.
But before rebooting, go to tty2, run "chroot /mnt" and you'll see that /boot/grub2/grub.cfg doesn't use uuid for root fs, but root=/dev/... instead.

You can redo the above change in /etc/grub.d and check my findings...

I used an autoinst with clearall + auto_allocate + partitions so you should be able to reproduce by clearing the whole disk/...
Comment 17 Thierry Vignaud 2016-07-17 16:42:37 CEST
Created attachment 8198 [details]
my autoinst file

in order to ease testing,
to be used with eg: "auto_install=http://192.168.0.10/auto_inst.cfg.pl"
Thierry Vignaud 2016-07-17 16:44:01 CEST

Summary: grub.cfg entries include /dev/sdXY which breaks boot if devices change order. => grub.cfg entries uses "root=/dev/sdXY" (instead of "root=UUID...") which breaks boot if devices change order

Comment 18 Thierry Vignaud 2016-07-17 17:20:36 CEST
@Barry: one solution would be to patch /etc/grub.d/10_linux so that the UUID check (the one verifying the presence of /dev/disk/by-uuid/foobar) is skipped if DURING_INSTALL is set.
Can you do that in the meantime?
Thanks
Comment 19 Barry Jackson 2016-07-17 23:25:55 CEST
OK I will take a look - have a good holiday ;)
Comment 20 Barry Jackson 2016-07-18 19:04:13 CEST
Created attachment 8207 [details]
proposed patch

Could someone please check that this patch is likely to achieve the desired result (as suggested by Thierry) before I push it?

Thanks,
Barry
Comment 21 Barry Jackson 2016-07-18 19:34:04 CEST
Comment on attachment 8207 [details]
proposed patch

I think that's wrong - too many inversions, my brain hurts :\

I think it should be:
...
+    || ( ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" && [ "x${DURING_INSTALL}" != "x1" ] ) \

We need false (from the bracketed expression) if we are in the installer whatever the test says so we drop through to the else.

I will think more later - must go.
Comment 22 Barry Jackson 2016-07-19 19:15:51 CEST
Yes that now looks right to me.
It should now only *not* drop through to 'else' when the uuid check fails and we are *not* in the installer.

r1042593 | barjac | 2016-07-19 18:11:06 +0100 (Tue, 19 Jul 2016) | 3 lines

- Patch to ignore test of disk/by-uuid when in installer
- workaround for Mga#18780 ( grub.cfg entries use root=/dev/sdXY instead of root=UUID...)

Submitted.
Comment 23 Barry Jackson 2016-07-19 23:51:50 CEST
Created attachment 8213 [details]
report_bug from install using grub2-common-2.02-0.git10457.11.mga6

@Thomas Is there any reason why $DURING_INSTALL would not be visible to grub2 in the installer? ...or is my logic flawed?
Comment 24 Barry Jackson 2016-07-19 23:54:41 CEST
Forgot to mention that the amended patch in grub2-common-2.02-0.git10457.11.mga6 failed to fix this issue.
Comment 25 Barry Jackson 2016-07-28 22:02:26 CEST
@Thierry
Hope you had a good break.
I tried with this but $DURING_INSTALL seems invisible to grub2 (or indeed to me) in the installer chroot (or the installer).

So, the current situation is unchanged except for a non-working patch in grub2.

I checked at various points in an install and could not see $DURING_INSTALL so I'm obviously missing something here.
Comment 26 Marja Van Waes 2016-12-15 07:05:53 CET
Is this bug still valid?

Assignee: bugsquad => zen25000
CC: (none) => marja11

Comment 27 Barry Jackson 2016-12-15 11:45:11 CET
(In reply to Marja van Waes from comment #26)
> Is this bug still valid?

I would imagine so as nobody updated this bug with news of a fix and Colin never replied to Thierry (here).

If you or any testers have a clean fresh install of cauldron:

cat /boot/grub2/grub.cfg|grep "=/dev/"

... will check - any output will show it's still valid.

Note that a kernel or grub2 update or running update-grub2 will have removed the evidence.
Harold Hill 2019-11-13 05:42:25 CET

CC: (none) => silvershadesa

Barry Jackson 2020-11-26 01:01:35 CET

Assignee: zen25000 => bugsquad

Morgan Leijström 2020-11-26 11:29:27 CET

CC: (none) => fri

Comment 29 Aurelien Oudelet 2020-11-30 10:55:04 CET
New installation of Mageia 7 and Cauldron uses UUID for root and swap device as long as nothing is modified in DrakX default setup.

Even if user choose custom partitioning, generated fstab uses UUID and so does Grub2.

I think this should be closed.

Resolution: (none) => FIXED
CC: (none) => ouaurelien
Status: REOPENED => RESOLVED


Note You need to log in before you can comment on or make changes to this bug.