Skip to contentSkip to conversation

incorrect root device while /dev/ on tmpfs

PATCH In review Vasily Averin 4 participants 6 messages Oct 17, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 incorrect root device while /dev/ on tmpfs

While /dev mounted as tmpfs it does not contain /dev/disk/by-uuid directory, 10_linux script did not check it properly and do not set root device via UUID. Therefore following kernel boot can fail (incorrect root device) if device names was changed.

Attached path fixes this issue. Please review and commit it

thank you,
Vasily Averin

util/grub.d/10_linux.in renamed from util/grub.d/10_linux.in.tmpdevuuid +1 -1
diff -up ./util/grub.d/10_linux.in.tmpdevuuid ./util/grub.d/10_linux.in
@@ -36,7 +36,7 @@ case ${GRUB_DEVICE} in
 esac
 
 if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
-    || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" ; then
+    || ( test -d /dev/disk/by-uuid  && ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}") ; then
   LINUX_ROOT_DEVICE=${GRUB_DEVICE}
 else
   LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
#1 lore raw

Am Samstag, den 17.10.2009, 16:24 +0400 schrieb Vasily Averin:

Quoted 9 lines

While /dev mounted as tmpfs it does not contain /dev/disk/by-uuid directory,
10_linux script did not check it properly and do not set root device via UUID.
Therefore following kernel boot can fail (incorrect root device) if device names
was changed.

Attached path fixes this issue. Please review and commit it

On Debian at least /dev is always a udev managed tmpfs, except in the case you boot from a livecd and chroot of course.
I fail to see why the check if /dev/disk/by-uuid is a directory does fix anything.
If /dev/disk/by-uuid/abc123 doestn't exit, then this implies that /dev/disk/by-uuid is not a directory.
Or is this some bug in the test command we need to workaround?

Signature · 2 lines
Felix Zielcke
Proud Debian Maintainer and GNU GRUB developer
#2 lore raw
Quoted 2 lines · Felix Zielcke

If /dev/disk/by-uuid/abc123 doestn't exit, then this implies that /dev/disk/by-uuid is not a directory.

I think you are misreading the original patch. Check it again ...

Signature · 1 line
Colin Watson                                       [[email protected]]
#3 lore raw

Am Samstag, den 17.10.2009, 13:56 +0100 schrieb Colin Watson:

Quoted 6 lines · Felix Zielcke
Quoted 2 lines

If /dev/disk/by-uuid/abc123 doestn't exit, then this implies that /dev/disk/by-uuid is not a directory.

I think you are misreading the original patch. Check it again ...

Ok thanks to Vladimir on IRC I got it now. But I don't think it's a good idea to use root=UUID= if /dev/disk/by-uuid doestn't exist at all.

The only case I can imagine where this would work, would be booting from a livecd, chrooting to the installed system, which still has the disk devices in the static dev so you don't need to bind mount /dev. But that should be only a one time situation.

If in the then booted system /dev/disk/by-uuid still doesn't exist, I don't think the initrd supports root=UUID= and then every boot would fail as long as GRUB_LINUX_DISABLE_UUID=true isn't set.

Signature · 2 lines
Felix Zielcke
Proud Debian Maintainer and GNU GRUB developer
#4 lore raw
In reply to Vasily Averin
Quoted 11 lines · Vasily Averin

While /dev mounted as tmpfs it does not contain /dev/disk/by-uuid directory, 10_linux script did not check it properly and do not set root device via UUID. Therefore following kernel boot can fail (incorrect root device) if device names was changed.

Attached path fixes this issue. Please review and commit it

diff -up ./util/grub.d/10_linux.in.tmpdevuuid ./util/grub.d/10_linux.in

util/grub.d/10_linux.in case ${GRUB_DEVICE} in · line 42

Quoted 8 lines
util/grub.d/10_linux.in renamed from util/grub.d/10_linux.in.tmpdevuuid +1 -1
@@ -36,7 +36,7 @@ case ${GRUB_DEVICE} in
 esac
 
 if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
-    || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" ; then
+    || ( test -d /dev/disk/by-uuid  && ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}") ; then
   LINUX_ROOT_DEVICE=${GRUB_DEVICE}
 else
   LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}

It seems to me that this eliminates the safety check to ensure that Linux actually recognises this UUID. If for some reason GRUB and Linux are out of sync in how they calculate UUIDs, this will probably result in an unbootable system.

Would it help to double-check with blkid in this case, or something like that?

Signature · 1 line
Colin Watson                                       [[email protected]]
#5 lore raw
In reply to Vasily Averin
Quoted 6 lines · Vasily Averin

While /dev mounted as tmpfs it does not contain /dev/disk/by-uuid directory, 10_linux script did not check it properly and do not set root device via UUID. Therefore following kernel boot can fail (incorrect root device) if device names was changed.

I would be inclined to say that for mainline presence of /dev/disk/by-uuid is a reasonable indication that initrd supports root specified by UUID. If it's not present then we should assume initrd is dumb and doesn't recognises UUID= and just hardcode the device. The distributors can modify it as they see fit.

Quoted 12 lines

Attached path fixes this issue. Please review and commit it

thank you,
Vasily Averin

------------------------------------------------------------------------

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 3 lines
Regards
Vladimir 'phcoder' Serbinenko
Personal git repository: http://repo.or.cz/w/grub2/phcoder.git