Configuring GRUB2 correctly (Dual Boot NixOS/Arch)

Hello, first time poster, so feedback welcome.

Context

I have been running Arch Linux with no /boot dedicated partition. Then I decided to give NixOS a try, and followed the NixOS manual, with some modifications at partitioning time to allow me to have a Dual-booted setup with my Arch and my new NixOS. The result is as follows (from Arch viewpoing):

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0 931.5G  0 disk
├─sda1   8:1    0 780.7G  0 part
├─sda2   8:2    0   599M  0 part /efi
├─sda6   8:6    0   145G  0 part /
└─sda7   8:7    0   5.3G  0 part [SWAP]

sda1 holds NixOS, sda2 holds the /boot partition for NixOS and sda6 root partition (with /boot) on Arch Linux. I know, very very messy, and I plan to do a proper reinstallation, but I’d like to get GRUB2 working.

The Issue

I have this NixOS configuration for booting up in my configuration.nix:

  boot.loader.systemd-boot.enable = true;
  boot.loader.grub = {
    enable = true;
    useOSProber = true;
    efiSupport = true;
    default = "saved";
    device = "nodev";
  };
  boot.loader.efi = {
    canTouchEfiVariables = true;
    efiSysMountPoint = "/boot";
  };

I ran sudo nixos-rebuild --install-bootloader switch and it properly ran os-prober and detected that I indeed used Arch Linux and added the corresponding menu entry. But when I select and boot it appears like GRUB can’t find the vmlinuz-linux and it just kernels panics.

I managed to boot on arch by getting into a grub shell, dropping back into my BIOS boot entry menu and selecting Arch Linux boot (which is also GRUB). I’ve read that I can chainload bootloaders and maybe that is the solution? But I’d like to make the arch image visible to my GRUB and just let NixOS take care of everything because I plan on using it as daily driver.

Help is very much appreciated, thanks in advance!

Chainloading is possible, though I wasn’t aware that you can chainload MBR boot manager from EFI.

I haven’t had the time to test it yet, tbh. I am waiting and still searching forums and the like to see if someone has solved similar issues earlier. If not my plan is to salvage my data and nuke the arch install and clean up /boot so I have a more stable and maintainable system.

1 Like

My experience with EFI boot is, that it is usually the easiest to just let each system its own boot loader on a shared ESP and use the EFIs boot selector to choose among those.

This is usually a lot easier to set up than chainloading.

1 Like