all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Reinstall GuixSD from another distribution with chroot (Recover Grub)
@ 2018-02-28  6:29 Oleg Pykhalov
  2018-03-02 13:51 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Oleg Pykhalov @ 2018-02-28  6:29 UTC (permalink / raw)
  To: help-guix

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Reinstall GuixSD from another distribution with chroot (Recover Grub)
  2018-02-28  6:29 Reinstall GuixSD from another distribution with chroot (Recover Grub) Oleg Pykhalov
@ 2018-03-02 13:51 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2018-03-02 13:51 UTC (permalink / raw)
  To: Oleg Pykhalov; +Cc: help-guix

Hi Oleg,

Thanks for sharing your tips.

Oleg Pykhalov <go.wigust@gmail.com> skribis:

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

How did you end up with that?  :-)

> Chrooting into GuixSD system:
>
> 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
>
>
> 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.
>
> source /var/guix/profiles/per-user/YOUR-USER/guix-profile/etc/profile

Looking at this, I thought we should be able to do a better job to start
an already installed GuixSD, for instance by providing a script that
boots the system.

Actually, I suspect that something like this would work:

  cd /tmp/guixsd
  chroot . /gnu/store/…/bin/guile /run/current-system/boot

With a bit of work, we could make it as simple as:

  /tmp/guixsd/run/current-system/spawn

or similar.

Thoughts?

Ludo’.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-02 13:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-28  6:29 Reinstall GuixSD from another distribution with chroot (Recover Grub) Oleg Pykhalov
2018-03-02 13:51 ` Ludovic Courtès

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.