I have one physical disk (/dev/sda
) which is divided in /dev/sda1
(which is /boot
bootable GRUB2 partition used and setup with Arch) and /dev/sda2
which is my cryptroot
that, when unlocked, is a single large lvmpool
with the full size of the partition /dev/sda2
. I have installed Arch on 3 lvs
, as seen in the image below.
This setup is basically LVM on LUKS as described on the Arch Wiki on Dm-crypt.
Since I read lots of great things about NixOS, I am trying to install NixOS next to my current Arch install, so I created 3 more lvs
similar to the arch-
lvs
above, and I followed the NixOS installation guide. I have specified boot.loader.grub.device = "nodev"
so that NixOS will not install GRUB anywhere else, because I want to re-use my existing GRUB2 from Arch which resides on /dev/sda1
. It will however write a grub.cfg
file for NixOS to /boot/grub/grub.cfg
that, in this case, is on the NixOS nix-root
lv
(/
, the filesystem root in NixOS) and thus not on the actual (bootable) GRUB2 partition /dev/sda1
.
However, to achieve that, I want to add an extra menu-entry to my grub.cfg
and point to the configfile
that the NixOS-installer has created on my nix-root
lv
(/
, the filesystem root in NixOS), pretty much what is described here. However, I am unsure how to create an entry that will point to the nix-root
lv
, since it seems that GRUB wants some syntax like set root='(hd0,X)'
, but how can I make something like this set root
aware of my lv
to point to instead of to a physical disk and partition number? Both the options configfile
and chainloader
are not very well-described in GRUB, and neither is the set root
as far as I could find.
I hope that somebody could point me in the right direction, tell me what I am doing wrong or why/how I am making this too hard on myself, to just use one bootable GRUB2 partition for multiple Linux distributions that reside on different LVM lvs
on LUKS.
EDIT:
I tried various options for set root=
such as (lv/nix-root)
, (lvmpool/nix-root)
and (/dev/mapper/lvmpool-nix--root)
, however the problem is that the LVM lvs
seem not visible to GRUB yet, since at the point that GRUB loads, /dev/sda2/
is still an encrypted LUKS cryptroot
.
(hd0,X)
.set root=
such as(lv/nix-root)
,(lvmpool/nix-root)
and(/dev/mapper/lvmpool-nix--root)
, however the problem is that the LVMlvs
seem not visible to GRUB yet, since at the point that GRUB loads,/dev/sda2/
is still an encrypted LUKScryptroot
.grub.cfg
(I too have LVM on LUKS, but my/boot
is on that same encrypted partition, so it's a bit different from yours), and it usesset root=(lvmid/A/B)
, whereA
is "VG UUID" andB
is "LV UUID" (can be obtained withvgdisplay
andlvdisplay
).