From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8XmJ-0006cA-FW for guix-patches@gnu.org; Wed, 10 May 2017 16:00:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8XmF-0004qS-5d for guix-patches@gnu.org; Wed, 10 May 2017 16:00:07 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:34485) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d8XmF-0004qK-29 for guix-patches@gnu.org; Wed, 10 May 2017 16:00:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1d8XmE-0004Up-Qz for guix-patches@gnu.org; Wed, 10 May 2017 16:00:02 -0400 Subject: bug#26815: [PATCH 3/3] vm: Support EFI boot in base image. Resent-Message-ID: From: Marius Bakke In-Reply-To: <87efvzl7w8.fsf@gnu.org> 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> <87efvzl7w8.fsf@gnu.org> Date: Wed, 10 May 2017 21:58:56 +0200 Message-ID: <87inl8lbzz.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: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Ludovic Court=C3=A8s writes: > 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 E= SP 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 Beha= vior": >> + ;; 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=3Droot --label gnu-disk-image~@ >> + configfile /boot/grub/grub.cfg~%"))) >> + (display "creating grub firmware image...\n") >> + (unless (zero? (system* "grub-mkstandalone" "-O" (car efi-targe= t-map) >> + "-o" (string-append efi-payload-directo= ry "/" >> + (cdr efi-target-map= )) >> + ;; Graft the contents of our configurat= ion file >> + ;; into the image. See grub-mkstandalo= ne(1). >> + (string-append "boot/grub/grub.cfg=3D" = grub.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 proced= ure, say > =E2=80=98install-efi=E2=80=99, 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=E2= =80=99s > 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 =E2=80=9Cgnu-esp=E2=80=9D label of this partition used for lookup = anywhere? If > it was, we=E2=80=99d run into problems as soon as we have several partiti= ons > 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 th= e label > is not used for lookup, that=E2=80=99s 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=3D1G is no longer enough after the Guile 2.2 transition!) --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAlkTcQEACgkQoqBt8qM6 VPo9kwf/VDDYYgglFnAMkThrGRvJaHaUb6ztLN6w9icsfmCp4Y6ZaUunCvoR1Uo7 4mdOHw8+mDg4TXOXZknPpP4gISyotbcz2o9v3hlSTjqB2bEOFE9Vadnw55BrMrul Om1BSKKI0fjFRywMmypbWSSPeD7kgNkLx06aOC3Cn4EblGnVJ3G5EOvKVn4V0E/7 FKfyXnfSpIWzR71IYVED4Qa9j7/9fCDn4jTQ3XEmxmi/+iM9B8DUy4xiQb1Tp6jM Dz5Dh5QaxpTEQ8u/xMwa9ELcZbouxnThPXAsX5HJhUmS/OjQ8oO8VmS+0RqQwAoa h+w4v1MKrzjf3XeMZbqiggnO8VuefA== =8JjN -----END PGP SIGNATURE----- --=-=-=--