grub-install failed: Wrong number of args: mapdevfs with multi disk btrfs

Bug #1354730 reported by Willem Ligtenberg
166
This bug affects 24 people
Affects Status Importance Assigned to Milestone
grub-installer (Ubuntu)
Fix Released
Critical
khanh
Nominated for Bionic by Rolf Leggewie
Trusty
Fix Released
Medium
khanh

Bug Description

I was previously able to install ubuntu on a root btrfs filesystem in raid1 mode as I described here:
http://askubuntu.com/questions/87241/how-to-install-using-btrfs-in-raid10-mode

So I used gparted to create btrfs partitions on all the disksand left 1 MB at the beginning of the disks for GRUB. (I also tried 2, and 5)

Then later I made the btrfs filesystem as follows:
mkfs.btrfs -m raid1 -d raid1 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
And performed:
btrfs dev scan

Then I went back through normal installation.

I am now trying to do this again, using Ubuntu 14.04.
Everything goes fine up to the point that it wants to install grub.
It mentions the error in the title and fails.

Apparently, somebody else also reported an error like this with 14.04.
https://bugs.launchpad.net/ubuntu/+source/grub-installer/+bug/912431 (at the bottom a person mentions that it occurs in 14.04)

I will attach some files later.

Tags: bionic trusty
Revision history for this message
Willem Ligtenberg (wligtenberg) wrote :

syslog of the installer

Revision history for this message
Willem Ligtenberg (wligtenberg) wrote :

preseed file

description: updated
TJ (tj)
Changed in grub-installer (Ubuntu):
status: New → In Progress
importance: Undecided → High
assignee: nobody → TJ (tj)
Revision history for this message
TJ (tj) wrote :

The failure is due to grub_probe() returning more than one line when using btrfs. In the case of a 4-device raid1 created with:

make.btrfs -m raid1 -d raid1 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sds1

grub_probe() returns and assigns to $rootfs:

/dev/sda1
/dev/sdb1
/dev/sdc1
/dev/sdd1

which causes calls to mapdevfs to fail since it receives 4 arguments with error code 1 and message "Wrong number of args: mapdevfs <path>".

The fix is to amend the grub-installer script's grub_probe() function:

 diff -u grub-installer.orig grub-installer
--- grub-installer.orig 2014-08-10 04:22:23.009006148 +0100
+++ grub-installer 2014-08-10 04:22:38.249815612 +0100
@@ -113,7 +113,7 @@
                apt-install grub-common
                is_grub_common_installed=true
        fi
- $chroot $ROOT grub-probe $@
+ $chroot $ROOT grub-probe $@ | head -1
 }

Changed in grub-installer (Ubuntu):
status: In Progress → Triaged
Revision history for this message
TJ (tj) wrote :

Bug-fix branch linked

Changed in grub-installer (Ubuntu):
assignee: TJ (tj) → nobody
Revision history for this message
Willem Ligtenberg (wligtenberg) wrote :

Is there a way I can test this patch?
Because I assume that it is more complicated since it has to be on the install media.

Revision history for this message
TJ (tj) wrote : Re: [Bug 1354730] Re: 14.04 grub-install failed: Wrong number of args: mapdevfs <path>

On 10/08/14 08:02, Willem Ligtenberg wrote:
> Is there a way I can test this patch?

1. Start the installer and pause it at some user prompt
2. Start a terminal shell (switch to an alternative VT or start an xterm or if using -server install use the "Execute a Shell" main-menu option)
3. Execute "sed -i 's/\($chroot $ROOT grub-probe $@\)/\1 | head -1/' /usr/bin/grub-installer
4. Return to the installer and continue

TJ (tj)
Changed in grub-installer (Ubuntu):
assignee: nobody → TJ (tj)
Revision history for this message
Launchpad Janitor (janitor) wrote : Re: 14.04 grub-install failed: Wrong number of args: mapdevfs <path>

This bug was fixed in the package grub-installer - 1.78ubuntu25

---------------
grub-installer (1.78ubuntu25) vivid; urgency=medium

  * grub_probe(): return a single line in BTRFS multi-disk RAID configurations
    (LP: #1354730).
 -- TJ <email address hidden> Thu, 19 Feb 2015 11:44:43 -0500

Changed in grub-installer (Ubuntu):
status: Triaged → Fix Released
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

As I recall there is also a branch to bring this to Trusty, but it's not closing the bug.

(fwiw, that's https://code.launchpad.net/~tj/ubuntu/trusty/grub-installer/lp1354730/+merge/230222)

I'm nominating this for Trusty, so as soon as you have time to update the branch (following the same changes as done in vivid), TJ, we can SRU this... but this bug report will also need an update of it's description for the SRU process (http://wiki.ubuntu.com/StableReleaseUpdates#Procedure).

Thanks!

Changed in grub-installer (Ubuntu Trusty):
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

I'm reverting this, as it's been found that it misbehaves when trying to install the bootloader using Guided - use entire disk with LVM, on recent server images.

Reopening...

Changed in grub-installer (Ubuntu):
status: Fix Released → Triaged
assignee: TJ (tj) → nobody
Revision history for this message
Nick Fish (nichfish) wrote :

FYI, for anyone that wants to use the original fix as a workaround until an official fix is released, the grub-installer script can be found at /usr/share/grub-installer/grub-installer on more recent versions of Ubuntu. So, step #3 given by TJ above becomes:

sed -i 's/\($chroot $ROOT grub-probe $@\)/\1 | head -1/' /usr/share/grub-installer/grub-installer

Changing this (I used nano to edit the file instead of sed) enabled me to install Ubuntu 14.04 LTS Desktop on a BTRFS raid setup without issue.

Phillip Susi (psusi)
Changed in grub-installer (Ubuntu):
importance: High → Critical
Changed in grub-installer (Ubuntu):
status: Triaged → Incomplete
status: Incomplete → New
Revision history for this message
Rolf Leggewie (r0lf) wrote :

Still affects bionic

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

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

Changed in grub-installer (Ubuntu):
status: New → Confirmed
Rolf Leggewie (r0lf)
tags: added: bionic trusty
ziya (bazzkpr1)
Changed in grub-installer (Ubuntu):
assignee: nobody → ziya (bazzkpr1)
dino99 (9d9)
Changed in grub-installer (Ubuntu):
assignee: ziya (bazzkpr1) → nobody
Phillip Susi (psusi)
summary: - 14.04 grub-install failed: Wrong number of args: mapdevfs <path>
+ grub-install failed: Wrong number of args: mapdevfs with multi disk
+ btrfs
khanh (duykhanh1996)
Changed in ubuntu-release-notes:
status: New → Fix Committed
assignee: nobody → khanh (duykhanh1996)
Changed in grub-installer (Ubuntu):
status: Confirmed → Fix Released
assignee: nobody → khanh (duykhanh1996)
Changed in grub-installer (Ubuntu Trusty):
assignee: nobody → khanh (duykhanh1996)
status: Triaged → Fix Released
no longer affects: ubuntu-release-notes
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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