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’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.
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.
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?
You might be right. I was unaware of NixOS specializations specifically, but I did assume that something similar could be done with Flakes. I’ll start looking into specializations and thank you for turning me on to it.
Yes to different home directories, yes different apps, and yes I’d like to isolate everything to protect data. I guessed dual booting would be best since I want to completely seperate each partition for security and I if I ever need to give someone my whole work computer, maybe I could convince them to be satisfied with just my whole work partition. I assumed I understood dual booting before and that this would take 30 minutes, haha but I was wrong.
As you infer, I might have found a better solution if I had waited and looked around for other solutions instead of picking the first that came to mind. But I have made a solution that works for me, even if it isn’t the best practice.