Skip to contentSkip to conversation

10_linux: avoid multi-device root= kernel argument

PATCH In review Andrei Borzenkov 4 participants 8 messages Jan 28, 2016 – Feb 1, 2016 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CAC+fKQW3LZDiuuEiGqWzK8Zkk=eRvJNs02LmEC9Y8v_M8OGrbQ@mail.gmail.com

#1 lore raw

PATCH 1/1 10_linux: avoid multi-device root= kernel argument

If root filesystem is multidev btrfs, do not attempt to pass all devices as kernel root= argument. This results in splitting command line in GRUB due to embedded newline and even if we managed to quote it, kernel does not know how to interpret it anyway. Multidev btrfs requires user space device scanning, so passing single device would not work too.

This still respects user settings GRUB_DISABLE_LINUX_UUID. Not sure what we should do in this case.

Closes 45709
---
 util/grub.d/10_linux.in     | 4 +++-
 util/grub.d/20_linux_xen.in | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
util/grub.d/10_linux.in +3 -1
index 859b608..5a78513 100644
@@ -43,9 +43,11 @@ case ${GRUB_DEVICE} in
   ;;
 esac
 
+# btrfs may reside on multiple devices. We cannot pass them as value of root= parameter
+# and mounting btrfs requires user space scanning, so force UUID in this case.
 if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
     || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
-    || uses_abstraction "${GRUB_DEVICE}" lvm; then
+    || test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm; then
   LINUX_ROOT_DEVICE=${GRUB_DEVICE}
 else
   LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
util/grub.d/20_linux_xen.in +3 -1
index f532fb9..46045db 100644
@@ -43,9 +43,11 @@ case ${GRUB_DEVICE} in
   ;;
 esac
 
+# btrfs may reside on multiple devices. We cannot pass them as value of root= parameter
+# and mounting btrfs requires user space scanning, so force UUID in this case.
 if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
     || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
-    || uses_abstraction "${GRUB_DEVICE}" lvm; then
+    || test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm; then
   LINUX_ROOT_DEVICE=${GRUB_DEVICE}
 else
   LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
Signature · 1 line
tg: (ff84a9b..) u/btrfs-multidev (depends on: master)
#2 lore raw
Quoted 10 lines · Andrei Borzenkov

If root filesystem is multidev btrfs, do not attempt to pass all devices as kernel root= argument. This results in splitting command line in GRUB due to embedded newline and even if we managed to quote it, kernel does not know how to interpret it anyway. Multidev btrfs requires user space device scanning, so passing single device would not work too.

This still respects user settings GRUB_DISABLE_LINUX_UUID. Not sure what we should do in this case.

Closes 45709

JFYI, this patch also has verified to solve a reported installation problem in Btrfs RAID 0 configuration in SUSE Linux. It would be great to have this patch included in upstream.

Thanks,
Michael

Quoted 47 lines
---
 util/grub.d/10_linux.in     | 4 +++-
 util/grub.d/20_linux_xen.in | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
util/grub.d/10_linux.in +3 -1
index 859b608..5a78513 100644
@@ -43,9 +43,11 @@ case ${GRUB_DEVICE} in
   ;;
 esac
 
+# btrfs may reside on multiple devices. We cannot pass them as value of root= parameter
+# and mounting btrfs requires user space scanning, so force UUID in this case.
 if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
     || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
-    || uses_abstraction "${GRUB_DEVICE}" lvm; then
+    || test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm; then
   LINUX_ROOT_DEVICE=${GRUB_DEVICE}
 else
   LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
util/grub.d/20_linux_xen.in +3 -1
index f532fb9..46045db 100644
@@ -43,9 +43,11 @@ case ${GRUB_DEVICE} in
   ;;
 esac
 
+# btrfs may reside on multiple devices. We cannot pass them as value of root= parameter
+# and mounting btrfs requires user space scanning, so force UUID in this case.
 if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
     || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
-    || uses_abstraction "${GRUB_DEVICE}" lvm; then
+    || test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm; then
   LINUX_ROOT_DEVICE=${GRUB_DEVICE}
 else
   LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
Signature · 6 lines
tg: (ff84a9b..) u/btrfs-multidev (depends on: master)

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#3 lore raw
In reply to Andrei Borzenkov

Am 28.01.2016 um 17:46 schrieb Andrei Borzenkov:

Quoted 2 lines

This still respects user settings GRUB_DISABLE_LINUX_UUID. Not sure what we should do in this case.

grub cant possibly know what the device name of the target OS is. This is especially true if it tries to guess what the OS on partitions other than the current / might expect. So:
never append any root= or resume= to the OS cmdline. Its the task of the initrd to find the relevant block devices.

Olaf

#4 lore raw
Quoted 7 lines · Olaf Hering

Am 28.01.2016 um 17:46 schrieb Andrei Borzenkov:

Quoted 2 lines

This still respects user settings GRUB_DISABLE_LINUX_UUID. Not sure what we should do in this case.

grub cant possibly know what the device name of the target OS is. This is especially true if it tries to guess what the OS on partitions other than the current / might expect. So:

it never does it for partitions other than current.

Quoted 9 lines

never append any root= or resume= to the OS cmdline. Its the task of the initrd to find the relevant block devices.

Olaf

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

#5 lore raw
Quoted 10 lines · Andrei Borzenkov
Quoted 7 lines · Olaf Hering

Am 28.01.2016 um 17:46 schrieb Andrei Borzenkov:

Quoted 2 lines

This still respects user settings GRUB_DISABLE_LINUX_UUID. Not sure what we should do in this case.

grub cant possibly know what the device name of the target OS is. This is especially true if it tries to guess what the OS on partitions other than the current / might expect. So:

it never does it for partitions other than current.

/etc/grub.d/30_os-prober does it. The other OS is configured to mount by label but grub forces an incorrect root= into cmdline. For short:
rework the patch to stop forcing root= into cmdline.

Olaf

#6 lore raw

29.01.2016 19:23, Olaf Hering пишет:

Quoted 7 lines · Andrei Borzenkov
Quoted 6 lines · Olaf Hering
Quoted 4 lines

Am 28.01.2016 um 17:46 schrieb Andrei Borzenkov:

Quoted 2 lines

This still respects user settings GRUB_DISABLE_LINUX_UUID. Not sure what we should do in this case.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

grub cant possibly know what the device name of the target OS is. This is especially true if it tries to guess what the OS on partitions other than the current / might expect. So:

it never does it for partitions other than current.

/etc/grub.d/30_os-prober does it. The other OS is configured to mount

I fail to find string 30_os-prober in my patch. If there is problem with 30_os-prober, please start another discussion. And at least explain what the problem is.

Quoted 3 lines

by label but grub forces an incorrect root= into cmdline. For short:
rework the patch to stop forcing root= into cmdline.

#7 lore raw
In reply to Andrei Borzenkov

2016-01-28 17:46 GMT+01:00 Andrei Borzenkov <[email protected]>:

Quoted 11 lines

If root filesystem is multidev btrfs, do not attempt to pass all devices as kernel root= argument. This results in splitting command line in GRUB due to embedded newline and even if we managed to quote it, kernel does not know how to interpret it anyway. Multidev btrfs requires user space device scanning, so passing single device would not work too.

This still respects user settings GRUB_DISABLE_LINUX_UUID. Not sure what we should do in this case.

Closes 45709

This patch fixes my problem reported here:
https://bugzilla.redhat.com/show_bug.cgi?id=1294532
Now, the kernel root option is correctly generated as root=UUID=xxxx instead of the broken multiline list of devices as before.

Thank you.

#8 lore raw

01.02.2016 00:17, Juan Orti Alcaine пишет:

Quoted 13 lines

2016-01-28 17:46 GMT+01:00 Andrei Borzenkov <[email protected]>:

Quoted 11 lines

If root filesystem is multidev btrfs, do not attempt to pass all devices as kernel root= argument. This results in splitting command line in GRUB due to embedded newline and even if we managed to quote it, kernel does not know how to interpret it anyway. Multidev btrfs requires user space device scanning, so passing single device would not work too.

This still respects user settings GRUB_DISABLE_LINUX_UUID. Not sure what we should do in this case.

Closes 45709
Quoted 7 lines

This patch fixes my problem reported here:
https://bugzilla.redhat.com/show_bug.cgi?id=1294532
Now, the kernel root option is correctly generated as root=UUID=xxxx instead of the broken multiline list of devices as before.

Thank you.

Thank you and Michael for testing. Pushed.