Invalid grub.cfg generated if root on RAID1 btrfs

Bug #1238347 reported by Toby Corkindale
40
This bug affects 5 people
Affects Status Importance Assigned to Milestone
grub2 (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

If Ubuntu Saucy is installed onto a btrfs root device, which is configured to be a RAID1 mirror (or probably other configurations) then the grub.cfg is generated with invalid entries.

This is because /etc/grub.d/10_linux gets *both* device names from btrfs, with a newline between them, and then just sticks that everywhere in the config file where it was expecting just one device. The newline in the middle prematurely truncates lines and then starts new invalid ones.

To reproduce, create your btrfs device something like this during install:
mkfs.btrfs -d raid1 -m raid1 /dev/sda1 /dev/sdb1

ProblemType: Bug
DistroRelease: Ubuntu 13.10
Package: grub-common 2.00-19ubuntu1 [modified: usr/sbin/grub-mkconfig usr/share/grub/grub-mkconfig_lib]
ProcVersionSignature: Ubuntu 3.11.0-11.17-generic 3.11.3
Uname: Linux 3.11.0-11-generic x86_64
NonfreeKernelModules: nvidia
ApportVersion: 2.12.5-0ubuntu1
Architecture: amd64
Date: Fri Oct 11 12:21:17 2013
InstallationDate: Installed on 2013-10-09 (1 days ago)
InstallationMedia: Ubuntu 13.10 "Saucy Salamander" - Beta amd64 (20130925.1)
MarkForUpload: True
SourcePackage: grub2
UpgradeStatus: No upgrade log present (probably fresh install)
modified.conffile..etc.grub.d.10.linux: [modified]
mtime.conffile..etc.grub.d.10.linux: 2013-10-11T12:18:01.364605

Revision history for this message
Toby Corkindale (tjc-wintrmute) wrote :
Revision history for this message
Toby Corkindale (tjc-wintrmute) wrote :

I have a sort-of workaround, which is to edit grub-mkconfig_lib and add a " | head -n 1 " to the call to grub_prove in get_get_device_id(), but it's not great.

Revision history for this message
Toby Corkindale (tjc-wintrmute) wrote :

From /usr/sbin/grub-mkconfig
Note the addition of the "head -n 1" to the pipeline. Not a great fix, but does work.

# Device containing our userland. Typically used for root= parameter.
GRUB_DEVICE="`${grub_probe} --target=device / | head -n 1`"
GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true

# Device containing our /boot partition. Usually the same as GRUB_DEVICE.
GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot | head -n 1`"

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in grub2 (Ubuntu):
status: New → Confirmed
Revision history for this message
Wojciech Niziński (niziak) wrote :

Problem still valid for version 2.02~beta2-36ubuntu11.
I'm using multi-device BTRFS as root file system.
Configuration generated by grub-install adds wrong kernel argument with newline:
        linux /vmlinuz-4.4.0-62-generic root=/dev/mapper/sth--proc-root
/dev/mapper/sth--proc2-root ro rootflags=subvol=@ panic=30

but it should generate UUID (UUIDs are not disabled in my config):
        linux /vmlinuz-4.4.0-62-generic root=UUID=ed730508-753e-4a7f-ac1e-bf8646f7bd63 ro rootflags=subvol=@ panic=30

because of
# blkid
/dev/mapper/sth--proc2-root: LABEL="btrfs_root" UUID="ed730508-753e-4a7f-ac1e-bf8646f7bd63" UUID_SUB="3508e65d-22af-43c3-9fe6-446f63e203cc" TYPE="btrfs"
/dev/mapper/sth--proc-root: LABEL="btrfs_root" UUID="ed730508-753e-4a7f-ac1e-bf8646f7bd63" UUID_SUB="27c2248f-4072-4e3a-b782-99161460fcb2" TYPE="btrfs"

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.