[Nix-dev] How can I boot into nixos from a grub installed on other drive ? (chroot problem)

James Cook james.cook at utoronto.ca
Tue Apr 18 05:16:05 CEST 2017


On 6 April 2017 at 10:35, Matt <mattator at gmail.com> wrote:
>
> hi,
>
> My macbook SATA wire broke, I plugged its harddrive with nixos (16.XX)
> installed into my workstation and now I would like to boot on it. My
> main workstation harddrive is ubuntu with grub.
> I would like to add a grub entry to boot on it (the grub is on the
> ubuntu harddrive).
>
> From Ubuntu, I mounted the nixos hardrive in /mnt/nixos I played a bit
> with os-prober to have grub-update generate the nixos entry but it
> fails to do so.
>
> Finally I stumbled upon:
> http://lists.science.uu.nl/pipermail/nix-dev/2015-August/017932.html
> which seems like a good idea ?! i.e., have nixos generate its own grub
> entries (without installing grub) and then have the grub ony my ubuntu
> drive include those config file.
>
> The problem I now have is to be able to generate the nixos grub
> entries, which require to run "nixos-rebuild switch" from my ubuntu
> partition.
>
> I've tried to chroot but it fails miserably ? How can I circumvent that ?
> ===
> LANG=C sudo chroot . nix/store/*-nixos-system-*/init
> <<< NixOS Stage 2 >>>
>
> running activation script...
> setting up /etc...
> starting systemd...
> Trying to run as user instance, but the system has not been booted with systemd.
> ===
>
> Here is the content of /mnt/nixos/boot , I don't know much about EFI
> but I wonder if it can be a problem, ie., if I can boot those kernels
> on a different laptop.
> ==
> ubuntu$ ls -R /mnt/nixos/boot
>
> ./boot:
> efi/  loader/
>
> ./boot/efi:
> nixos/
>
> ./boot/efi/nixos:
> 8ii7mf9a1c7d9g09p176z7682smyrg96-initrd-initrd.efi
> mjy1zi0iygs5d676yplrdckjhw011prm-linux-4.4.39-bzImage.efi
> hjbgyi20c2w17vsdcxpprgyzvzp528pp-initrd-initrd.efi
> v440b1as5dpbwv5id2ijkwip5qv6c3mz-initrd-initrd.efi
> jhhfsg8lpvnf16xryk6xdb18mdv52ggd-initrd-initrd.efi
> y10bb973l89wl5n3gwx8zl0ml4h24hg6-linux-4.4.45-bzImage.efi
> jxiz0q5q98yi5bw8hajzdnwrjkx5m6iz-linux-4.4.47-bzImage.efi
> ywrjsjk0l5rak4qmhww3n7fs2gb9kxrn-initrd-initrd.efi
>
> ./boot/loader:
> entries/  loader.conf
>
> ./boot/loader/entries:
> nixos-generation-10.conf  nixos-generation-16.conf
> nixos-generation-21.conf  nixos-generation-27.conf
> nixos-generation-6.conf
> nixos-generation-11.conf  nixos-generation-17.conf
> nixos-generation-22.conf  nixos-generation-28.conf
> nixos-generation-7.conf
> nixos-generation-12.conf  nixos-generation-18.conf
> nixos-generation-23.conf  nixos-generation-2.conf
> nixos-generation-8.conf
> nixos-generation-13.conf  nixos-generation-19.conf
> nixos-generation-24.conf  nixos-generation-3.conf
> nixos-generation-9.conf
> nixos-generation-14.conf  nixos-generation-1.conf
> nixos-generation-25.conf  nixos-generation-4.conf
> nixos-generation-15.conf  nixos-generation-20.conf
> nixos-generation-26.conf  nixos-generation-5.conf

Hi Matt,

Did you ever solve your problem?

Have you tried a chroot without running the init script? E.g. set up
the correct mount points (/proc, /dev, etc) using mount -o bind, and
then start nix-daemon and run nixos-rebuild.

NB: I haven't tried installing NixOS on a mac. Just trying to generate ideas.

James


More information about the nix-dev mailing list