unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Marius Bakke <mbakke@fastmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 26815@debbugs.gnu.org
Subject: bug#26815: [PATCH 3/3] vm: Support EFI boot in base image.
Date: Wed, 10 May 2017 21:58:56 +0200	[thread overview]
Message-ID: <87inl8lbzz.fsf@fastmail.com> (raw)
In-Reply-To: <87efvzl7w8.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 5167 bytes --]

Ludovic Courtès <ludo@gnu.org> writes:

> Marius Bakke <mbakke@fastmail.com> skribis:
>
>> From 9555239cfc9362a15cc3f255040c410395d49e04 Mon Sep 17 00:00:00 2001
>> From: Marius Bakke <mbakke@fastmail.com>
>> Date: Sun, 7 May 2017 15:31:30 +0200
>> Subject: [PATCH] vm: Support EFI boot in base image.
>>
>> * gnu/system/vm.scm (qemu-image): Add GRUB-EFI to inputs. Append 40MB
>> EFI System Partition.
>> * gnu/build/vm.scm (initialize-hard-disk): Generate grub EFI blob when ESP is
>> present.
>
> [...]
>
>> +    ;; If we have an ESP partition, generate a self-contained grub EFI
>> +    ;; image and write it to a well-known location.
>> +    (when esp
>> +      (let* ((system %host-type)
>> +             (efi-payload-directory (string-append efi-directory "/EFI/BOOT"))
>> +             ;; Map the grub targets to the boot file names expected by
>> +             ;; UEFI compliant firmware. See "Removable Media Boot Behavior":
>> +             ;; http://www.uefi.org/sites/default/files/resources/UEFI%20Spec%202_6.pdf
>> +             (efi-target-map (cond
>> +                              ((string-prefix? "x86_64" system)
>> +                               '("x86_64-efi" . "BOOTX64.EFI"))
>> +                              ((string-prefix? "i686" system)
>> +                               '("i386-efi" . "BOOTIA32.EFI"))
>> +                              ((string-prefix? "armhf" system)
>> +                               '("arm-efi" . "BOOTARM.EFI"))
>> +                              ((string-prefix? "aarch64" system)
>> +                               '("arm64-efi" . "BOOTAA64.EFI"))))
>> +             (grub-tmp (string-append target "/tmp"))
>> +             (grub.cfg (string-append grub-tmp "/grub.cfg")))
>> +        (display "mounting EFI system partition...\n")
>> +        (mkdir-p efi-directory)
>> +        (mount (partition-device esp) efi-directory
>> +               (partition-file-system esp))
>> +        (mkdir-p efi-payload-directory)
>> +
>> +        ;; Grub needs a tmpdir to prepare the image.
>> +        (setenv "TMPDIR" grub-tmp)
>> +        ;; We also need a tiny configuration file telling the EFI blob where
>> +        ;; to find the real thing.
>> +        (with-output-to-file grub.cfg
>> +          (lambda _
>> +            (format #t
>> +                    "insmod part_msdos~@
>> +                    search --set=root --label gnu-disk-image~@
>> +                    configfile /boot/grub/grub.cfg~%")))
>> +        (display "creating grub firmware image...\n")
>> +        (unless (zero? (system* "grub-mkstandalone" "-O" (car efi-target-map)
>> +                                "-o" (string-append efi-payload-directory "/"
>> +                                                    (cdr efi-target-map))
>> +                                ;; Graft the contents of our configuration file
>> +                                ;; into the image.  See grub-mkstandalone(1).
>> +                                (string-append "boot/grub/grub.cfg=" grub.cfg)))
>> +          (error "failed to create grub EFI image"))
>> +
>> +        (delete-file grub.cfg)
>> +        (umount efi-directory)))
>
> Could you move the body hi of ‘when’ to a separate procedure, say
> ‘install-efi’, such that this reduces to something like:
>
>   (when esp
>     (install-efi esp grub.cfg))

Good idea. I've moved the grub parts into a separate procedure, but kept
the mounting etc here.

>> +                                    (partition
>> +                                     ;; Append a small FAT32 partition for
>> +                                     ;; use with UEFI bootloaders.
>> +                                     (size (* 40 (expt 2 20)))
>> +                                     (label "gnu-esp")
>> +                                     (file-system "vfat")
>> +                                     (flags '(esp))))))
>>               (initialize-hard-disk "/dev/vda"
>>                                     #:partitions partitions
>>                                     #:bootloader
>
> All the images we create will now have that extra ESP, but maybe that’s
> OK.

It's "only" 40MiB, so didn't see a reason to complicate it. Grub is
actually just ~10MiB, but left some space for..stuff?

There are some rare systems with 32-bit UEFI and 64-bit CPU, those users
should be able to copy "BOOTIA32.EFI" from an i686 image onto the ESP.

> Is the “gnu-esp” label of this partition used for lookup anywhere?  If
> it was, we’d run into problems as soon as we have several partitions
> with this hard-coded label (say you have your installed GuixSD as well
> as the installation image on a USB key that’s plugged in.)  If the label
> is not used for lookup, that’s OK.

It's only used for informational purposes. Now even uppercase to display
properly on ancient systems :-P

I've sent a new patch series taking the reviews into account. The
patches from id:20170506154154.17836-1-m.othacehe@gmail.com are still
required.

(Also, --size=1G is no longer enough after the Guile 2.2 transition!)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

  parent reply	other threads:[~2017-05-10 20:00 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-07 14:35 bug#26815: [PATCH 0/3] Hybrid UEFI disk image Marius Bakke
2017-05-07 14:36 ` bug#26815: [PATCH 1/3] vm: Add support for arbitrary partition flags Marius Bakke
2017-05-07 14:36   ` bug#26815: [PATCH 2/3] vm: Support creating FAT partitions Marius Bakke
2017-05-07 15:26     ` Danny Milosavljevic
2017-05-07 15:52       ` Marius Bakke
2017-05-07 16:32         ` bug#26815: [PATCH v2 " Marius Bakke
2017-05-07 17:06         ` bug#26815: [PATCH " Danny Milosavljevic
2017-05-07 19:15           ` Marius Bakke
2017-05-07 20:07             ` Danny Milosavljevic
2017-05-08 14:45               ` Ludovic Courtès
2017-05-08 15:59     ` Maxim Cournoyer
2017-05-07 14:36   ` bug#26815: [PATCH 3/3] vm: Support EFI boot in base image Marius Bakke
2017-05-07 15:18     ` Danny Milosavljevic
2017-05-07 15:41       ` Marius Bakke
2017-05-07 19:17       ` Marius Bakke
2017-05-08  9:06         ` Marius Bakke
2017-05-08 14:50           ` Ludovic Courtès
2017-05-10 19:52             ` bug#26815: [PATCH 1/3] vm: Support arbitrary partition flags Marius Bakke
2017-05-10 19:52               ` bug#26815: [PATCH 2/3] vm: Support creating FAT partitions Marius Bakke
2017-05-10 19:52               ` bug#26815: [PATCH 3/3] vm: Add UEFI loader to disk images Marius Bakke
2017-05-10 21:05                 ` Ludovic Courtès
2017-05-10 21:21                   ` Marius Bakke
2017-05-10 19:58             ` Marius Bakke [this message]
2017-05-12 22:06               ` bug#26815: [PATCH 3/3] vm: Support EFI boot in base image Ludovic Courtès
2017-05-12 23:12                 ` Marius Bakke
2017-05-13  9:17                   ` Mathieu Othacehe
2017-05-13 13:11                     ` Ludovic Courtès
2017-05-13 14:13                       ` Marius Bakke
2017-05-13 19:23                         ` Ludovic Courtès
2017-05-16 15:17                         ` Ludovic Courtès
2017-05-17 11:05                           ` Marius Bakke
2017-05-17 12:36                             ` Marius Bakke
2017-05-17 13:42                               ` Ricardo Wurmus
2017-05-17 19:47                               ` Ludovic Courtès
2017-05-17 11:05                           ` bug#26815: [PATCH v4 1/3] vm: Support arbitrary partition flags Marius Bakke
2017-05-17 11:05                             ` bug#26815: [PATCH v4 2/3] vm: Support creating FAT partitions Marius Bakke
2017-05-17 11:05                             ` bug#26815: [PATCH v4 3/3] vm: Add UEFI loader to disk images Marius Bakke
2017-05-17 21:28                               ` Ludovic Courtès
2017-05-18 16:21                                 ` Marius Bakke
2017-05-18 17:34                                   ` Marius Bakke
2017-05-18 20:59                                     ` Ludovic Courtès
2017-05-19 16:15                                       ` Marius Bakke
2017-05-19 17:37                                         ` Mathieu Othacehe
2017-05-19 18:06                                           ` Marius Bakke
2017-05-20  8:25                                             ` Ludovic Courtès
2017-05-20  8:55                                               ` Mathieu Othacehe
2017-05-20  9:23                                               ` Marius Bakke
2017-05-20  9:36                                                 ` Ludovic Courtès
2017-05-20  9:36                                             ` Mathieu Othacehe
2017-05-20 10:05                                               ` Marius Bakke
2017-05-19 21:21                                         ` Ludovic Courtès
2017-05-18 20:50                                   ` Ludovic Courtès
2017-05-18 22:52                                     ` Marius Bakke
2017-05-19  7:00                                       ` Ludovic Courtès
2017-05-17 21:21                             ` bug#26815: [PATCH v4 1/3] vm: Support arbitrary partition flags Ludovic Courtès
2017-05-07 15:28   ` bug#26815: [PATCH 1/3] vm: Add support for " Danny Milosavljevic
2017-05-08 14:43   ` Ludovic Courtès
2017-05-08 15:55   ` Maxim Cournoyer
2017-05-08 21:41   ` Danny Milosavljevic
2017-05-07 15:02 ` bug#26815: [PATCH 0/3] Hybrid UEFI disk image Marius Bakke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87inl8lbzz.fsf@fastmail.com \
    --to=mbakke@fastmail.com \
    --cc=26815@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).