From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41805) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d7k17-0002zZ-C8 for guix-patches@gnu.org; Mon, 08 May 2017 10:52:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d7k14-0000u1-PL for guix-patches@gnu.org; Mon, 08 May 2017 10:52:05 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:36319) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d7k14-0000tv-Lf for guix-patches@gnu.org; Mon, 08 May 2017 10:52:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1d7k14-00008k-Cr for guix-patches@gnu.org; Mon, 08 May 2017 10:52:02 -0400 Subject: bug#26815: [PATCH 3/3] vm: Support EFI boot in base image. Resent-Message-ID: From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <20170507143647.21036-1-mbakke@fastmail.com> <20170507143647.21036-3-mbakke@fastmail.com> <20170507171814.555ec8b3@scratchpost.org> <87r300xyqq.fsf@fastmail.com> <87d1bjyay3.fsf@fastmail.com> Date: Mon, 08 May 2017 16:50:47 +0200 In-Reply-To: <87d1bjyay3.fsf@fastmail.com> (Marius Bakke's message of "Mon, 08 May 2017 11:06:28 +0200") Message-ID: <87efvzl7w8.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: > From 9555239cfc9362a15cc3f255040c410395d49e04 Mon Sep 17 00:00:00 2001 > From: Marius Bakke > 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 ES= P 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/B= OOT")) > + ;; Map the grub targets to the boot file names expected by > + ;; UEFI compliant firmware. See "Removable Media Boot Behav= ior": > + ;; http://www.uefi.org/sites/default/files/resources/UEFI%2= 0Spec%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 w= here > + ;; to find the real thing. > + (with-output-to-file grub.cfg > + (lambda _ > + (format #t > + "insmod part_msdos~@ > + search --set=3Droot --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-director= y "/" > + (cdr efi-target-map)) > + ;; Graft the contents of our configurati= on file > + ;; into the image. See grub-mkstandalon= e(1). > + (string-append "boot/grub/grub.cfg=3D" g= rub.cfg))) > + (error "failed to create grub EFI image")) > + > + (delete-file grub.cfg) > + (umount efi-directory))) Could you move the body hi of =E2=80=98when=E2=80=99 to a separate procedur= e, say =E2=80=98install-efi=E2=80=99, such that this reduces to something like: (when esp (install-efi esp grub.cfg)) > + (partition > + ;; Append a small FAT32 partition f= or > + ;; 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=E2=80= =99s OK. Is the =E2=80=9Cgnu-esp=E2=80=9D label of this partition used for lookup an= ywhere? If it was, we=E2=80=99d 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=E2=80=99s plugged in.) If the = label is not used for lookup, that=E2=80=99s OK. Apart from that LGTM, thank you! Ludo=E2=80=99.