Dual Booting NixOS and NixOS - Grub shows only one

Hi I’ve been happily been using NixOS for my desktop for a year.

I’m trying to dual boot two instances of NixOS on a different machine but when I enter the bootloader only the most recently installed partition shows up. I used the graphical install, mistakenly used up the whole drive and encrypted it. Went to install it again, used GParted to clean up my mess and ended up with the untouched boot partition and the two different root partitions I want.

Nothing that I try gets both partitions to show up in the bootloader. systemd-boot wasn’t working so I changed my configuration.nix to include:

boot.loader = {
efi = {
canTouchEfiVariables = true;
efiSysMountPoint = “/boot”; # I’ve also tried “/boot/EFI“
};
grub = {
default = “saved”; # not sure if this is required
device = “nodev”;
enable = true;
useOSProber = true;
efiSupport = true;
};
};

Notably I get this message when I rebuild:

modprobe: can’t change directory to ‘/lib/modules’: No such file or directory

But other than that it rebuilds without errors. I’m wondering if having two boot partitions would work. I’m guessing os-prober isn’t detecting the other partition. Notably both root partitions are encrypted. I’ve learned a fair bit through all my googling but alas come here with no solution.

I see from this that maybe I could get it to work with systemd-boot, but I am unsure what to put in extraEntries to point to the other partition. Need Advice on switching from systemd to grub on a dual boot on multiple disks - #3 by TLATER

I’d like one partition to be for work and the other for hobbies. I could pivot and make one of the partions a different Linux distro, use an external SSD for one, or just use a VM. I’m more than happy to share more info, but don’t know what is helpful and what is not.

mb try without encryption will it work that way

Thank you!

Not for giving me the solution, but the inspiration to try something different that does work. I doubt that having both partitions unecrypted on its own would work, but if the first one installed is using Grub, via editing the configuration.nix file, and the second isn’t, then I can choose to either by going into the boot menu, F12 for me. And both can be encrypted.

Is it an ideal solution, no. But, assuming it doesn’t break, it will work just fine for me. If someone wanted 3 or more partitions with NixOS I doubt something like this would work.

This seems like an X/Y problem.

I’d like one partition to be for work and the other for hobbies.

You don’t need to dual-boot NixOS for this. You can do this with the NixOS specializations feature. You could have a shared partition for the Nix store. One config can be for work, and another can be for hobbies. You can have the different configs mount different filesystems for things like /home or your whole root filesystem (aside from /nix) if you want.

The effect will be a lot like dual booting (choose what you want to boot in the boot menu) but you’ll have a single boot loader configuration that’s managed by the single NixOS install.

But also, even a separate partition might not be the ideal solution for managing the split you want. Do you need different home directories? Different installed applications? Protecting work data from personal apps, or vice-versa?

1 Like