help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Reinstall GuixSD from another distribution with chroot (Recover Grub)


From: Oleg Pykhalov
Subject: Reinstall GuixSD from another distribution with chroot (Recover Grub)
Date: Wed, 28 Feb 2018 09:29:48 +0300

Hello Guix,

The following article fixed my boot problem, but I think that it could
be applied to any Grub or UEFI issue on GuixSD.

I broke my ‘grub.cfg’ probably because of a patch from a discussion
about dualbooting [1].  It worked well until I did a ‘reconfigure’
from a Guix builded from Git without applied patch from [1].
--8<---------------cut here---------------start------------->8---
sudo -E ./pre-inst-env\
env GUIX_PACKAGE_PATH=$HOME/src/guix-wigust\
guix system reconfigure $HOME/dotfiles/fiore/magnolia.scm
--8<---------------cut here---------------end--------------->8---

I got a ‘grub.cfg’ with following entries for all system generations:
--8<---------------cut here---------------start------------->8---
menuentry "GNU with Linux-Libre 4.15.6 (beta)" {
  search --label --set magnolia-root
}
--8<---------------cut here---------------end--------------->8---

I booted to NixOS on another partition of same SSD, with hitting ‘c’
in Grub menu entries and specifying ‘configfile
(hd0,gpt1)/boot/grub/grub.cfg’.  (You could find a partition with ‘ls’
command.)  But the following should work with any distribution booted
from a liveusb, too.

Chrooting into GuixSD system:
--8<---------------cut here---------------start------------->8---
mkdir /tmp/guixsd
sudo mount /dev/sda2 /tmp/guixsd # GuixSD partition
sudo mount -t proc none /tmp/guixsd/proc
sudo mount -t sysfs sys /tmp/guixsd/sys
sudo mount -o bind /dev /tmp/guixsd/dev
sudo mount /dev/sda1 /tmp/guixsd/boot/efi # UEFI partition with ‘EFI’ directory 
inside
sudo chroot /tmp/guixsd /bin/sh
--8<---------------cut here---------------end--------------->8---

You need to “source” a Bash profile with environment variables which
will setup an environment as was GuixSD (such as ‘PATH’ to find
executables).  The thing is if you make a ‘source /etc/profile’ then
you cannot get YOUR-USER's profile PATH environment variable.  Because
of that “source” only a ‘per-user’ profile.
--8<---------------cut here---------------start------------->8---
source /var/guix/profiles/per-user/YOUR-USER/guix-profile/etc/profile
--8<---------------cut here---------------end--------------->8---

NOTE: Per-user profile was required, because with only ‘/etc/profile’
invoking any ‘guix COMMAND’ I got:
--8<---------------cut here---------------start------------->8---
guix system reconfigure /home/natsu/dotfiles/fiore/magnolia.scm
guix system: error: could not find bootstrap binary 'guile-2.0.9.tar.xz' for 
system 'x86_64-linux'
--8<---------------cut here---------------end--------------->8---

Run a Guix daemon with disabled chroot in background:
--8<---------------cut here---------------start------------->8---
guix-daemon --build-users-group=guixbuild --disable-chroot &
--8<---------------cut here---------------end--------------->8---

Reinstall a system with ‘guix init’:
--8<---------------cut here---------------start------------->8---
/home/YOUR-USER/src/guix/pre-inst-env guix system init /etc/config.scm /

substitute: updating list of substitutes from 'https://mirror.hydra.gnu.org'... 
100.0%
The following derivation will be built:
   /gnu/store/8ac2s3dshanlwqmnqkk7jg88j02q0l1m-grub.cfg.drv
/gnu/store/xqs7x48zkld99xp6m39ad6w4zcvf95sh-system
/gnu/store/6piq5j9f59na07ja2s8w7l4v5b6xgnpr-grub.cfg
/gnu/store/kcw90wxwxfm62i9h45myx1nhyzfy5zqz-grub-efi-2.02
/gnu/store/fw8bzf3ic9z5xnm48a1rgx9a5ld6c81r-bootloader-installer

initializing operating system under '/'...
guix system: warning: initializing the current root file system
populating '/'...
Installing for x86_64-efi platform.
Installation finished. No error reported.
--8<---------------cut here---------------end--------------->8---

NOTE: You probably could do it without ‘pre-inst-env’.

Now you could reboot to GuixSD.

I wish a guide like this to be in the Guix documentation.

Footnotes: 
[1]  https://lists.gnu.org/archive/html/guix-devel/2018-02/msg00001.html

Oleg.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]