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

Bug #1354730 reported by Willem Ligtenberg on 2014-08-09
This bug affects 23 people
Affects Status Importance Assigned to Milestone
Release Notes for Ubuntu
grub-installer (Ubuntu)
Nominated for Bionic by Rolf Leggewie

Bug Description

I was previously able to install ubuntu on a root btrfs filesystem in raid1 mode as I described here:

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. (at the bottom a person mentions that it occurs in 14.04)

I will attach some files later.

Willem Ligtenberg (wligtenberg) wrote :

syslog of the installer

Willem Ligtenberg (wligtenberg) wrote :

preseed file

description: updated
TJ (tj) on 2014-08-10
Changed in grub-installer (Ubuntu):
status: New → In Progress
importance: Undecided → High
assignee: nobody → TJ (tj)
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:


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
- $chroot $ROOT grub-probe $@
+ $chroot $ROOT grub-probe $@ | head -1

Changed in grub-installer (Ubuntu):
status: In Progress → Triaged
TJ (tj) wrote :

Bug-fix branch linked

Changed in grub-installer (Ubuntu):
assignee: TJ (tj) → nobody
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.

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) on 2014-08-11
Changed in grub-installer (Ubuntu):
assignee: nobody → TJ (tj)

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

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

(fwiw, that's

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 (


Changed in grub-installer (Ubuntu Trusty):
importance: Undecided → Medium
status: New → Triaged

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.


Changed in grub-installer (Ubuntu):
status: Fix Released → Triaged
assignee: TJ (tj) → nobody
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) on 2016-07-11
Changed in grub-installer (Ubuntu):
importance: High → Critical
Changed in grub-installer (Ubuntu):
status: Triaged → Incomplete
status: Incomplete → New
Rolf Leggewie (r0lf) wrote :

Still affects bionic

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) on 2018-04-07
tags: added: bionic trusty
ziya (bazzkpr1) on 2018-04-27
Changed in grub-installer (Ubuntu):
assignee: nobody → ziya (bazzkpr1)
dino99 (9d9) on 2018-04-30
Changed in grub-installer (Ubuntu):
assignee: ziya (bazzkpr1) → nobody
Phillip Susi (psusi) on 2018-05-23
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) on 2018-10-18
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
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers