From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36873) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBOBi-0007a6-7O for guix-patches@gnu.org; Thu, 18 May 2017 12:22:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBOBe-0008BS-7Q for guix-patches@gnu.org; Thu, 18 May 2017 12:22:06 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:50994) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dBOBe-0008BI-40 for guix-patches@gnu.org; Thu, 18 May 2017 12:22:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dBOBd-0004R9-Va for guix-patches@gnu.org; Thu, 18 May 2017 12:22:01 -0400 Subject: bug#26815: [PATCH v4 3/3] vm: Add UEFI loader to disk images. Resent-Message-ID: From: Marius Bakke In-Reply-To: <87ziebtbph.fsf@gnu.org> References: <87r2zoygoi.fsf@gnu.org> <20170517110522.18106-1-mbakke@fastmail.com> <20170517110522.18106-3-mbakke@fastmail.com> <87ziebtbph.fsf@gnu.org> Date: Thu, 18 May 2017 18:21:35 +0200 Message-ID: <877f1ecf00.fsf@fastmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" 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: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 26815@debbugs.gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s writes: >> +++ b/gnu/system/vm.scm >> @@ -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 Partit= ion for >> + ;; use with UEFI bootloaders. >> + (partition >> + ;; The standalone grub image is ab= out 10MiB, but >> + ;; leave some room for custom or m= ultiple images. >> + (size (* 40 (expt 2 20))) >> + (label "GNU-ESP") ;cos= metic only >> + ;; Use "vfat" here since this prop= erty is used >> + ;; when mounting. The actual FAT-n= ess is based >> + ;; on filesystem size (16 in this = case). >> + (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? Thanks for the hint. With the attached patch, grub-efi is now passed through to "install-efi". I haven't tested it on "version-0.13.0" but assume it will work. Now, I would like to instead implement an #:efi-loader keyword, and pass it a derivation for the standalone EFI blob, but I'm not sure if I can do that before the weekend. What do you think, is this "good enough" for the time being? > 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 conf= iguration, and > to update the doc to explain the installation process for UEFI. I'll get on that. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-vm-Initialize-hard-disk-now-takes-a-grub-efi-paramet.patch Content-Transfer-Encoding: quoted-printable From=20b2236aa915bfb32e974546790a1e87ef1b268403 Mon Sep 17 00:00:00 2001 From: Marius Bakke Date: Thu, 18 May 2017 18:10:31 +0200 Subject: [PATCH] vm: Initialize-hard-disk now takes a grub-efi parameter. * gnu/build/vm.scm (initialize-hard-disk): Learn #:grub-efi. (install-efi): Use it. * gnu/system/vm.scm (qemu-image): Pass it. =2D-- gnu/build/vm.scm | 8 +++++--- gnu/system/vm.scm | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm index c0c4c17fb..57619764c 100644 =2D-- a/gnu/build/vm.scm +++ b/gnu/build/vm.scm @@ -316,12 +316,13 @@ SYSTEM-DIRECTORY is the name of the directory of the = 'system' derivation." (mkdir-p directory) (symlink bootcfg (string-append directory "/bootcfg")))) =20 =2D(define (install-efi esp config-file) +(define (install-efi grub esp config-file) "Write a self-contained GRUB EFI loader to the mounted ESP using CONFIG-= FILE." (let* ((system %host-type) ;; Hard code the output location to a well-known path recognized = by ;; compliant firmware. See "3.5.1.1 Removable Media Boot Behaviou= r": ;; http://www.uefi.org/sites/default/files/resources/UEFI%20Spec%= 202_6.pdf + (grub-mkstandalone (string-append grub "/bin/grub-mkstandalone")) (efi-directory (string-append esp "/EFI/BOOT")) ;; Map grub target names to boot file names. (efi-targets (cond ((string-prefix? "x86_64" system) @@ -336,7 +337,7 @@ SYSTEM-DIRECTORY is the name of the directory of the 's= ystem' derivation." (setenv "TMPDIR" esp) =20 (mkdir-p efi-directory) =2D (unless (zero? (system* "grub-mkstandalone" "-O" (car efi-targets) + (unless (zero? (system* grub-mkstandalone "-O" (car efi-targets) "-o" (string-append efi-directory "/" (cdr efi-targets)) ;; Graft the configuration file onto the image. @@ -349,6 +350,7 @@ SYSTEM-DIRECTORY is the name of the directory of the 's= ystem' derivation." bootcfg bootcfg-location bootloader-installer + (grub-efi #f) (partitions '())) "Initialize DEVICE as a disk containing all the objects list= ed in PARTITIONS, and using BOOTCFG as its bootloader configuration file. @@ -400,7 +402,7 @@ passing it a directory name where it is mounted." configfile /boot/grub/grub.cfg~%"))) =20 (display "creating EFI firmware image...") =2D (install-efi mount-point grub-config) + (install-efi grub-efi mount-point grub-config) (display "done.\n") =20 (delete-file grub-config) diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index e0af90bee..d282ba557 100644 =2D-- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -204,7 +204,7 @@ the image." (guix build utils)) =20 (let ((inputs =2D '#$(append (list qemu parted e2fsprogs dosfstools grub-e= fi) + '#$(append (list qemu parted e2fsprogs dosfstools) (map canonical-package (list sed grep coreutils findutils gawk)) (if register-closures? (list guix) '()))) @@ -248,6 +248,7 @@ the image." (flags '(esp)))))) (initialize-hard-disk "/dev/vda" #:partitions partitions + #:grub-efi #$grub-efi #:bootloader-package #$(bootloader-package bootloader) #:bootcfg #$bootcfg-drv =2D-=20 2.13.0 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAlkdyg8ACgkQoqBt8qM6 VPrkvAgAuenYLoKSDjcX2kaAWLmKSs9hzU3D32oOWC5bHeEma9Oswa+8oCzgBrQ9 cYhXQY4F5j6WNDeLiI9oGH51twIo+HYb1S2uZQx6Ow9XEduWLKY4b7DvH0XuniaF MF+ITaV0nv6gMrLFIHDqFqij/gh8A0HprxeRTIUcw9n8iU33hY1Fm84UTezJRcnK g2Q77tsjP07CDmw/qGWnhBEp2xTniBuHlTuLB4okXwiBoQbSZ49e2RFq01KSbCZ1 Jwl17X2sXKC15g7hsrnWi/8U4eS3CivSImTRdQ0a6CGT4GsPr1G5aZ3OQvDOGPdo 9uMK80SIKdSyL003SYs4riVLscJ5ww== =2CXU -----END PGP SIGNATURE----- --==-=-=--