1

Can grub whitelist or blacklist drives/partitions?

Use case: defective main drive, installed (live usb) distro to second drive.

Now I want to configure grub to boot off the partition in the second drive.

The problem is that grub-install continuously hangs when reading the defective first drive. I need to tell grub to ignore the first drive and only os-probe the second drive (plus any other drives).

Therefore, simply disabling os-probe is not a valid remedy.

I don't want to remove first drive for various reasons, including warranty on the laptop and time constraints in this rescue situation.

Editorial: I cannot find how to do this despite a couple of days of searching google. I think drive failure would be a reasonably common scenario -- enough to make the inability to blacklist partitions a bug.

BTW, the workaround was to continuously monitor processes in a terminal and pkill any job with /dev/sda in its parameters. This got tiresome fast and took over an hour with 20 partitions on a 1TB drive. The new drive is 2TB and will have a few dozen partitions.

1
  • AFAIK, this is not possible. You'll have to resort to using static entries.
    – Larssend
    Jun 8, 2017 at 7:51

1 Answer 1

2

I can think of a couple of ways to achieve the result you want, but not quite in the way you seem to be expecting. Specifically:

  • Manually configure GRUB 2 -- Instead of relying on GRUB 2's configuration scripts, you can maintain its configuration file manually. This article I wrote in 2010 (before I understood the scope of the configuration scripts) covers the basics. This Arch Linux page also provides some examples that you might be able to incorporate in a manual GRUB 2 configuration file.
  • Use another boot loader -- GRUB 2 is not the only boot loader for Linux. If you're booting in BIOS/CSM/legacy mode, you could use GRUB Legacy, LILO, or SYSLINUX. If you're booting in EFI/UEFI mode, you could use a heavily patched GRUB Legacy, ELILO, SYSLINUX, the EFI stub loader, rEFInd, or gummiboot/systemd-boot. (See this page of mine for more on the EFI options.) Configuration details vary greatly from one boot loader to another, but most require one extent or another of manual configuration and so do not have the elaborate configuration scripts of GRUB 2. A caveat: If you're dual-booting with a non-Linux OS, ELILO, SYSLINUX, and the EFI stub loader are unlikely to do an acceptable job, at least not by themselves.

Of course, most of these options require doing more in the way of manual configuration than is necessary with a stock GRUB 2 and its configuration scripts. The exception is rEFInd, which auto-scans the disk whenever it boots. Depending on the nature of the problem with your main disk, rEFInd might or might not be affected by the issue you're having with GRUB 2. Of course, rEFInd requires EFI firmware, so it would not be a workable solution if you've got a BIOS-only computer.

As GRUB 2 is open source, you could almost certainly hack its configuration scripts to ignore your problem disk; but I'm afraid I wouldn't know how to do this -- at least, not without spending far too long digging through the relevant source code. If you're motivated enough, though, this might be another option.

1
  • I just realised who you are. Wow. I've been using rEFind for years as my standard loader. Thanks for the detailed reply. Jun 14, 2017 at 22:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .