grub is installed to /dev/sda by default and fails

Bug #1769404 reported by Yevhen

This bug report was converted into a question: question #668780: grub installation in ubiquity implementation.

12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
ubiquity (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

I choose to install Ubuntu 18.04 on /dev/sdb. I don't want to do partitioning manually so I don't open advanced partitioning tool.

I expect grub to be installed on same disk. Because my /dev/sdb is SSD and it is first in boot list in BIOS, and my /dev/sda is empty HDD and I'm not going to install anything on it and going to use it as storage.

But it seems grub-installer tries to install grub on /dev/sda by default. There are 2 cases:

1) If /dev/sda has no partition grub-installer fails. After the failure it suggests to choose another disk for grub. I choose /dev/sdb and it still fails.

2) If /dev/sda has any partition Ubuntu installation finishes successfully. But it doesn't boot after installation. I see only black screen with cursor blinking.

The workaround I found is to open advanced partitioning tool, change grub installation disk to /dev/sdb, go back, and again choose Ubuntu installation on /dev/sdb.

All logs attached here are from VirtualBox where I have reproduced the issue with grub-installer failure. I've reproduced second case as well but I'm not sure how to collect logs in this case.

ProblemType: Bug
DistroRelease: Ubuntu 18.04
Package: ubiquity 18.04.14
ProcVersionSignature: Ubuntu 4.15.0-20.21-generic 4.15.17
Uname: Linux 4.15.0-20-generic x86_64
ApportVersion: 2.20.9-0ubuntu7
Architecture: amd64
CasperVersion: 1.394
CurrentDesktop: ubuntu:GNOME
Date: Sun May 6 00:21:57 2018
InstallCmdLine: file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz quiet splash --- maybe-ubiquity
LiveMediaBuild: Ubuntu 18.04 LTS "Bionic Beaver" - Release amd64 (20180426)
ProcEnviron:
 LANGUAGE=en_US.UTF-8
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 LC_NUMERIC=C.UTF-8
SourcePackage: grub-installer
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Yevhen (yevhen.b) wrote :
Yevhen (yevhen.b)
description: updated
Yevhen (yevhen.b)
description: updated
Yevhen (yevhen.b)
description: updated
Yevhen (yevhen.b)
affects: grub-installer (Ubuntu) → ubiquity (Ubuntu)
summary: - grub-installer fails during installation
+ grub is installed to /dev/sda by default and fails
Revision history for this message
Bin Li (binli) wrote :

It depend on the boot sequence of your BIOS. If the SSD is the first one, and you install the grub on HDD, you can't boot up into HDD. You need change the boot order. Or enter the boot menu with F12, after that select HDD to boot.

Revision history for this message
Yevhen (yevhen.b) wrote :

Hi, Bin Li. Thanks for your answer.

Do you mean it's not possible for ubiquity to identify by itself the first disk in boot order without touching manually advanced partitioning tool or there are some other purposes to choose /dev/sda for grub by default?

Yevhen (yevhen.b)
Changed in ubiquity (Ubuntu):
status: New → Invalid
Revision history for this message
AtesComp (atescomp) wrote :

Bin Li is incorrect. The boot order may not determine the allocation of /dev/sdX for any number of hard drives. In general, IDE drives will always be assigned first and SATA drives will be assigned second. If you are booting from a SATA drive and have 2 IDE drives, you will always get /dev/sda to the first IDE, /dev/sdb to the second IDE, and /dev/sdc to the SATA drive NO MATTER HOW YOU SET THE BIOS BOOT ORDER.

Therefore, grub should have a hint, option, or other setting to point to the "default" and not assume /dev/sda. A better way would be to use UUID like in the fstab file since /dev/sdX assignment may not be guaranteed.

Changed in ubiquity (Ubuntu):
status: Invalid → New
Revision history for this message
AtesComp (atescomp) wrote :

Ok, UUID is only for partitions, so maybe the serial number instead.

This error crops up when a new kernel is installed during an update/upgrade. The update-grub command is called which in turn may call grub-install. It seems to always default to /dev/sda instead of the where the sdX grub-install was told to install.

Can grub-install store the last /dev/sdX it was told and use it as default? Or some other solution?

Revision history for this message
AtesComp (atescomp) wrote :

So, the undocumented "GRUB_DEVICE" may be the answer. I could only find it in a Gentoo post:

GRUB_DEVICE (detected) Device node for the volume containing the root filesystem. Set this to override the grub2-mkconfig command's root device auto-detection. For example, GRUB_DEVICE=/dev/ram0 will force root=/dev/ram0 to be used in the kernel command line.

While it clearly exists:
> grep DEVICE -A40 /usr/sbin/grub-mkconfig
it is not documented in the standard:
> https://www.gnu.org/software/grub/manual/grub/grub.html

I will test.

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

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

Changed in ubiquity (Ubuntu):
status: New → Confirmed
Revision history for this message
AtesComp (atescomp) wrote :

Found the issue. Do the following:

> sudo debconf-show grub-pc
> sudo dpkg-reconfigure grub-pc

The last screen sets the default GRUB device(s).

See: https://askubuntu.com/questions/135741/how-should-one-set-the-grub-pc-packages-install-devices-debconf-setting

Changed in ubiquity (Ubuntu):
status: Confirmed → Invalid
Revision history for this message
AtesComp (atescomp) wrote :

FYI: The dpkg configuration setting for all packages are in:

> /var/cache/debconf/config.dat

My setting for the GRUB devices were stored around:

> Name: grub-pc/install_devices

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

Other bug subscribers

Related questions

Remote bug watches

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