Subject: Re: [bug#41011] [PATCH] gnu: grub: Support for network boot via TFTP.

From: Danny Milosavljevic <[email-masked]>
Date: Sat, 26 Sep 2020 18:13:57 +0200

Hi Stefan,

I think this is almost ready to be merged.

There's still one thing I'm unclear about.

I tested it this way:

(1) create ~/config.scm with the following contents:

(use-modules (gnu))

(operating-system
  (timezone "UTC")
  (bootloader
    (bootloader-configuration
      (bootloader grub-efi-netboot-bootloader)
      (target "/boot")))
  (file-systems
    (cons* (file-system
             (mount-point "/")
             (device ":/foo")
             (type "nfs"))
            %base-file-systems))
  (host-name "client1"))

(2) mkdir ~/tf
(3) ./pre-inst-env guix system init ~/config.scm ~/tf

Now, ~/tf contains the system to be booted over the network, right?

But ~/tf/boot/efi/Guix/grub.cfg points to the tftp machine's /boot .
Is that a bug?  Shouldn't it point to the /boot of ~/tf, the system
to be booted?

Likewise, the gnu store directly inside ~/tf is not used, but
~/tf/boot/gnu points to the tftp machines's /gnu.  Shouldn't it
point to the former?

On Sat, 26 Sep 2020 12:54:00 +0200
Stefan <[email-masked]> wrote:

> +         (let* ((net-dir (string-append mount-point target "/"))
> +                (sub-dir (string-append net-dir #$subdir "/"))
> +                (store-link (string-append net-dir (%store-prefix)))
> +                (grub-cfg "/boot/grub/grub.cfg")

Shouldn't that be

 (string-append mount-point "/boot/grub/grub.cfg")

?

> +                (grub-cfg-link (string-append sub-dir (basename grub-cfg)))
> +                (boot-efi-link (string-append sub-dir #$boot-efi-link)))
> +           ;; Prepare the symlink to the store.
> +           (mkdir-p (dirname store-link))
> +           (false-if-exception (delete-file store-link))
> +           (symlink-relative (%store-prefix) store-link)

Shouldn't that be

  (symlink-relative (string-append mount-point (%store-prefix)) store-link)

?

> +           ;; Install GRUB, which refers to the grub.cfg, with support for
> +           ;; encrypted partitions,
> +           (setenv "GRUB_ENABLE_CRYPTODISK" "y")
> +           (invoke/quiet (string-append bootloader "/bin/grub-mknetdir")
> +                         (string-append "--net-directory=" net-dir)
> +                         (string-append "--subdir=" #$subdir))
> +           ;; Prepare the symlink to the grub.cfg, which points into the store.
> +           (false-if-exception (delete-file grub-cfg-link))
> +           (symlink-relative grub-cfg grub-cfg-link)
> +           ;; Prepare the bootloader symlink, which points to GRUB.
> +           (false-if-exception (delete-file boot-efi-link))
> +           (symlink #$efi-bootloader boot-efi-link))))))

Okay.