'grub-install --force "(hd0)"' fails on trusty during installation

Bug #1292628 reported by William Van Hevelingen on 2014-03-14
This bug affects 4 people
Affects Status Importance Assigned to Milestone
grub-installer (Ubuntu)
Colin Watson

Bug Description

Network/PXE installs of Trusty fail on installing grub.

The error message in syslog is:

Installing grub on '(hd0)'
Running chroot /target grub-install --force "(hd0)"
Installing for i386-pc platform
grub-install: error: disk `hd0' not found
error: Running 'grub-install --force ''(hd0)''' failed.

The workaround is the following

chroot target
echo "(hd0) /dev/sda" > /boot/grub/device.map

Then prompting the installer to try installing again.

Steve Langasek (vorlon) on 2014-03-14
Changed in grub2 (Ubuntu):
importance: Undecided → High
description: updated
Ben Kero (ben-kero) wrote :

I've helped look into this for the OP.

It seems the part that is failing is:

# /usr/sbin/grub-install --force "(hd0)"
/usr/sbin/grub-bios-setup: error: disk `hd0' not found.

Which I thought was odd, so I created a device.map file:

# echo "(hd0) /dev/sda" > /boot/grub/device.map
# /usr/sbin/grub-install --force "(hd0)"
Installation finished. No error reported.

At the end of the grub-bios-setup help page it says:
DEVICE must be an OS device (e.g. /dev/sda).

description: updated
description: updated
Launchpad Janitor (janitor) wrote :

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

Changed in grub2 (Ubuntu):
status: New → Confirmed
Steve Langasek (vorlon) wrote :

The code in grub-installer does the following:

# Try to avoid using (hd0) as a boot device name. Something which can be
# turned into a stable by-id name is better.
default_bootdev_os="$($chroot $ROOT grub-mkdevicemap --no-floppy -m - | head -n1
 | cut -f2)"
if [ "$default_bootdev_os" ]; then
        default_bootdev="$($chroot $ROOT readlink -f "$default_bootdev_os")"

So it would be useful to know the output of the intermediate commands in your environment.

Steve Langasek (vorlon) wrote :

This problem has been tracked back to a use of 'bootloader --location mbr' in a kickstart file, which kickseed translates into:

   ks_preseed d-i grub-installer/bootdev string '(hd0)'

grub-installer then uses this string as-is as an argument to grub-install, without first ensuring the availability of a grub device map. Apparently with the recently rewritten grub-install, that doesn't work.

Not sure if this should be fixed in grub-install or grub-installer, but clearly somebody needs to take responsibility for creating the grub devicemap. :)

Changed in grub2 (Ubuntu):
status: Confirmed → Triaged
Colin Watson (cjwatson) wrote :

This is a regression caused by the fix for bug 1012629.

affects: grub2 (Ubuntu) → grub-installer (Ubuntu)
Changed in grub-installer (Ubuntu):
assignee: nobody → Colin Watson (cjwatson)
status: Triaged → In Progress
status: In Progress → Fix Committed
Launchpad Janitor (janitor) wrote :

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

grub-installer (1.78ubuntu19) trusty; urgency=medium

  * If grub-installer/bootdev was set to (hd0), override it to the OS device
    name for the first disk if possible (LP: #1292628).
 -- Colin Watson <email address hidden> Fri, 28 Mar 2014 13:11:31 +0000

Changed in grub-installer (Ubuntu):
status: Fix Committed → Fix Released
bekks (bekks) wrote :

As of today, grub-installer 2.00~beta2-9 works fine for me. :)

Jason Sharp (jsharp) wrote :

Just an update to this

I use kickstart as well, and was using an older cfg

bootloader --location=partition

This IS still failing because kickstart see it as (hd0, 1)

If i use 'mbr' it works just great

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

Duplicates of this bug

Other bug subscribers