[newbee] Switching to grub and dual boot

Hi there!

I’m a Linux user for 20 years (most of them using Ubuntu), but switching distros after such a long time shows me what it is like to be a newbee again. :wink:

I tried to enable dual boot, but I’m facing 2 problems (I’ve read Dual Booting and Bootloader)

Here are the (so far) only changes I’ve did to my /etc/nixos/configuration.nix:

  # Bootloader.
  # boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
  boot.loader.grub.enable = true;
  boot.loader.grub.device = "nodev";
  boot.loader.grub.useOSProber = true;

When I run sudo nixos-rebuild boot, I get this error:

building Nix...
building the system configuration...
updating GRUB 2 menu...
/nix/store/8fv91097mbh5049i9rglc73dx6kjg3qk-bash-5.2-p15/bin/bash: line 1: /etc/grub.d/30_os-prober: No such file or directory

I assume the /etc/grub.d/30_os-prober should have been installed by some package, can I force a reinstall?

Also, I still boot into systemd-boot. The FAQ says:

Make sure to check if in your boot order, NixOS-bootloader is the default / first option.

I assume it’s talking about boot order in the BIOS, but I don’t see that option there. My default is Linux Boot Manager (starts systemd-boot and Nixos), and the other two alternatives are ubuntu (no idea how it got here, I overwrote the Ubuntu partition with Nixos. It drops me into a grub shell) and NVMe0 SAMSUNG + some code, which just reboots. Maybe NixOS-bootloader shows up once I’ve installed grub correctly?

The other OS I want to be able to boot into is Windows 11.

You’re likely running a computer with UEFI firmware. In UEFI land, the bootloader is stored in a separate efi partition - it’s completely unrelated to the rest of the system.

So by overwriting the ubuntu partition, you only removed the system that boot loader will boot, not the boot loader. Hence it goes to a grub shell, it can’t find what it’s actually supposed to boot.

You can safely delete this bootloader from /efi.

Odd, that’s usually the default on the efi partition for that drive. Oh well.

Note that Windows will override all other bootloaders if you install it second. Install Windows first when dual booting, and pray that system updates don’t break things (or better yet skip Windows altogether, screw that piece of crap).

Yep, or at least I suspect so too… Which means we need to fix:

Given the rest of your post I suspect you don’t have Windows installed yet? Maybe if there is no other OS os-prober doesn’t create a file it should, and you end up with this confusing error message?

1 Like

Thanks for the reply so far.

I do have windows installed from before switching to NixOS. I just replaced my Ubuntu partition with NixOS and formatted my “boot” partition with Fat32 (was ext4 before) as recommended by the installer. Here my partition table:

nvme0n1                                       259:0    0 476,9G  0 disk  
├─nvme0n1p1                                   259:1    0   260M  0 part  
├─nvme0n1p2                                   259:2    0    16M  0 part  
├─nvme0n1p3                                   259:3    0 237,4G  0 part  
├─nvme0n1p4                                   259:4    0     2G  0 part  
├─nvme0n1p5                                   259:5    0     2G  0 part  /boot
└─nvme0n1p6                                   259:6    0 235,4G  0 part  
  └─luks-0528c8b6-e6ec-4f00-b427-14d43d0a0eeb 254:0    0 235,4G  0 crypt /nix/store

The p1 to 4 should be Windows related.

Hmm, I looked around a bit, the manual says:

If you want to use GRUB, set boot.loader.grub.device to nodev and boot.loader.grub.efiSupport to true.

Looks like you’re missing the efiSupport option?