4

I triple boot Arch Linux, Gentoo Linux and NixOS. The problem is that these operating systems, specifically their version of the GRUB2 bootloader, do not play nice with one another. If I set up the bootloader with NixOS then the Gentoo and NixOS entries boot fine but the Arch Linux entries in the GRUB2 config actually boot NixOS not Arch Linux. If I set up GRUB2 from Arch Linux NixOS isn't recognized, but Gentoo is (os-prober is installed). My partitions are like this:

/dev/sda
 - /dev/sda1 - my EFI partition
 - /dev/sda2 - my Gentoo partition
 - /dev/sda3 - my Arch Linux partition
 - /dev/sda4 - my NixOS partition
 - /dev/sda5 - my swap partition
/dev/sdb
 - /dev/sdb1 - my data partition on which I store config files, documents, etc.

/dev/sda has a GPT partition table with a protective MBR, if relevant.

So my question is, is there is a way to get Arch Linux's GRUB2 bootloader to recognize and create appropriate boot entries for NixOS? Or if not, is there a way to get NixOS' bootloader to create appropriate entries for Arch Linux? Here is my configuration.nix file and here is my hardware-configuration.nix file.

To be clear when I set up GRUB2 on one of these systems to manager bootloading I make sure that only that distribution's bootloader is managing it. The other distro's bootloader files I delete from the EFI partition. For example, when I used NixOS to manage bootloading I deleted the /boot/EFI/arch folder (where EFI is mounted on /boot) and moved the Arch Linux kernel images from the EFI partition onto the Arch Linux root partition in its /boot folder.

EDIT: I've managed to get NixOS to almost set up GRUB2 properly to run Arch. I noticed that in /etc/fstab for Arch it was still mounting /dev/sda1 on /boot when it wasn't meant to anymore as I had changed the bootloader from being from Arch to being from NixOS.

The only problem with its config file now is that it has:

initrd  /boot/intel-ucode.img

instead of:

initrd  /boot/intel-ucode.img /boot/initramfs-linux.img

or:

initrd  /boot/intel-ucode.img /boot/initramfs-linux-fallback.img

depending on the precise entry. So the result is that if I boot Arch it goes into kernel panic. So how do I add the appropriate /boot/initramfs-linux*.img line without manually editing this file everytime?

2

Having more than one OS on a system manage GRUB tends to lead them to fight each other over how GRUB should be configured, including what boot entries go where.

It's best to let only one of the systems manage GRUB. In your case, it would be nixOS, due to how it manages the rollback linking.

|improve this answer|||||
  • Yeah I only have one managing it at a time. I set up one to manage it at a time and I still get this problem. I thought it was implied by my question, but apparently I need to clarify. I'll edit my question, thanks for pointing this out. – BH2017 Nov 17 '17 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.