From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43958) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB6VF-00035g-6F for guix-patches@gnu.org; Wed, 17 May 2017 17:29:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dB6VB-00006t-VJ for guix-patches@gnu.org; Wed, 17 May 2017 17:29:05 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:48735) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dB6VB-00006h-RU for guix-patches@gnu.org; Wed, 17 May 2017 17:29:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dB6VB-0008Eb-Ii for guix-patches@gnu.org; Wed, 17 May 2017 17:29:01 -0400 Subject: bug#26815: [PATCH v4 3/3] vm: Add UEFI loader to disk images. Resent-Message-ID: From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <87r2zoygoi.fsf@gnu.org> <20170517110522.18106-1-mbakke@fastmail.com> <20170517110522.18106-3-mbakke@fastmail.com> Date: Wed, 17 May 2017 23:28:26 +0200 In-Reply-To: <20170517110522.18106-3-mbakke@fastmail.com> (Marius Bakke's message of "Wed, 17 May 2017 13:05:22 +0200") Message-ID: <87ziebtbph.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Marius Bakke Cc: 26815@debbugs.gnu.org Marius Bakke skribis: > * gnu/system/vm.scm (qemu-image): Add GRUB-EFI to inputs. Append 40MiB EFI > System Partition. > * gnu/build/vm.scm (install-efi): New procedure. > (initialize-hard-disk): Generate grub EFI blob when ESP is present. [...] > +(define (install-efi esp config-file) > + "Write a self-contained GRUB EFI loader to the mounted ESP using CONFI= G-FILE." > + (let* ((system %host-type) > + ;; Hard code the output location to a well-known path recognize= d by > + ;; compliant firmware. See "3.5.1.1 Removable Media Boot Behavi= our": > + ;; http://www.uefi.org/sites/default/files/resources/UEFI%20Spe= c%202_6.pdf > + (efi-directory (string-append esp "/EFI/BOOT")) > + ;; Map grub target names to boot file names. > + (efi-targets (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 requires a TMPDIR to prepare the firmware image. > + (setenv "TMPDIR" esp) > + > + (mkdir-p efi-directory) > + (unless (zero? (system* "grub-mkstandalone" "-O" (car efi-targets) > + "-o" (string-append efi-directory "/" > + (cdr efi-targets)) > + ;; Graft the configuration file onto the ima= ge. > + (string-append "boot/grub/grub.cfg=3D" confi= g-file))) So this is where we need to make sure we=E2=80=99re taking =E2=80=98grub-mk= standalone=E2=80=99 from =E2=80=98grub-efi=E2=80=99 and not =E2=80=98grub=E2=80=99, right? How= do we ensure that? > +++ b/gnu/system/vm.scm > @@ -3,6 +3,7 @@ > ;;; Copyright =C2=A9 2016 Christopher Allan Webber > ;;; Copyright =C2=A9 2016 Leo Famulari > ;;; Copyright =C2=A9 2017 Mathieu Othacehe > +;;; Copyright =C2=A9 2017 Marius Bakke > ;;; > ;;; This file is part of GNU Guix. > ;;; > @@ -203,7 +204,7 @@ the image." > (guix build utils)) >=20=20 > (let ((inputs > - '#$(append (list qemu parted e2fsprogs dosfstools) > + '#$(append (list qemu parted e2fsprogs dosfstools grub-e= fi) > (map canonical-package > (list sed grep coreutils findutils gawk)) > (if register-closures? (list guix) '()))) > @@ -228,11 +229,23 @@ the image." > #:system-directory #$os-drv)) > (partitions (list (partition > (size #$(- disk-image-size > - (* 10 (expt 2 20)))) > + (* 50 (expt 2 20)))) > (label #$file-system-label) > (file-system #$file-system-type) > (flags '(boot)) > - (initializer initialize))))) > + (initializer initialize)) > + ;; Append a small EFI System Partiti= on for > + ;; use with UEFI bootloaders. > + (partition > + ;; The standalone grub image is abo= ut 10MiB, but > + ;; leave some room for custom or mu= ltiple images. > + (size (* 40 (expt 2 20))) > + (label "GNU-ESP") ;cosm= etic only > + ;; Use "vfat" here since this prope= rty is used > + ;; when mounting. The actual FAT-ne= ss is based > + ;; on filesystem size (16 in this c= ase). > + (file-system "vfat") > + (flags '(esp)))))) > (initialize-hard-disk "/dev/vda" > #:partitions partitions > #:bootloader-package I thought we=E2=80=99d pass something like (initialize-hard-disk =E2=80=A6 #:grub-efi #$grub-eif) to avoid the ambiguity? Once we=E2=80=99re done with that, we=E2=80=99ll have to update one of the =E2=80=98operating-system=E2=80=99 declaration examples to show UEFI config= uration, and to update the doc to explain the installation process for UEFI. Anyway, thanks for the updated patch series, looks like we=E2=80=99re almost there! :-) Ludo=E2=80=99.