From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: UEFI support in boot image Date: Wed, 19 Apr 2017 22:26:21 +0200 Message-ID: <87vaq0m9ea.fsf@gnu.org> References: <87wpb7ym78.fsf@gnu.org> <87shlqv4pe.fsf@kirby.i-did-not-set--mail-host-address--so-tickle-me> <87tw65sxvf.fsf@gnu.org> <8760i2lqbf.fsf@fastmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35810) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0wBI-0004mp-HD for guix-devel@gnu.org; Wed, 19 Apr 2017 16:26:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0wBF-0003aW-Bb for guix-devel@gnu.org; Wed, 19 Apr 2017 16:26:28 -0400 In-Reply-To: <8760i2lqbf.fsf@fastmail.com> (Marius Bakke's message of "Mon, 17 Apr 2017 22:41:40 +0200") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Marius Bakke Cc: guix-devel Hi Marius! Marius Bakke skribis: > I've attached a few patches as a humble beginning, but currently the > "format-partition" code in (gnu build vm) needs to learn some > filesystem-specific parameters. So, I don't think it will be ready for > the upcoming release. > > I have also done some reading and don't think we can use isolinux as it > requires an image in ISO 9660 format. Nor does the syslinux utilities > actually support chainloading grub from UEFI as I had hoped. OK. > So I think we'll have to offer UEFI as a standalone image, at least to > begin with. Unfortunately I also believe it needs to be generated from a > UEFI system, but this grub limitation can hopefully be lifted. Providing a separate standalone image is reasonable IMO. Anyway, I=E2=80=99m happy to see this patch set! > From 25b01f9a219338580b6f7a7449bba8ff90c2176c Mon Sep 17 00:00:00 2001 > From: Marius Bakke > Date: Tue, 11 Apr 2017 10:47:38 +0200 > Subject: [PATCH 1/4] vm: Add support for arbitrary partition flags. > > * gnu/build/vm.scm (): Change BOOTABLE? to FLAGS. > (initialize-partition-table): Pass each flag to parted. > (initialize-hard-disk): Search for root partition by "boot" flag. > * gnu/system/vm.scm (qemu-image): Adjust partitions accordingly. [...] > @@ -141,7 +141,7 @@ the #:references-graphs parameter of 'derivation'." > (size partition-size) > (file-system partition-file-system (default "ext4")) > (label partition-label (default #f)) > - (bootable? partition-bootable? (default #f)) > + (flags partition-flags (default '())) > (initializer partition-initializer (default (const #t)))) So =E2=80=98flags=E2=80=99 must be a list of strings, and each string is so= mething Parted recognizes, right? It would be slightly nicer to make it a list of symbols. > + (define (find-root-partition partitions) > + "Return the first partition found with the boot flag set." > + ;; FIXME: This probably does not work. What's the best way to do thi= s? > + (find (match-lambda > + (($ _ _ _ _ flags) > + (member "boot" flags))) > + partitions)) Why wouldn=E2=80=99t it work? LGTM. BTW, in this case, I=E2=80=99d recommend using =E2=80=98partition-flags=E2= =80=99 instead of =E2=80=98match=E2=80=99 with the 4 wildcards; probably safer. :-) That said, it=E2=80=99s probably best to keep (define (partition-bootable? partition) (member "boot" (partition-flags partition))) > (let* ((partitions (initialize-partition-table device partitions)) > - (root (find partition-bootable? partitions)) > + (root (find-root-partition partitions)) =E2=80=A6 and keep this line unchanged (=E2=80=98find-foo=E2=80=99 procedur= es are an anti-pattern in a way.) > From 9db90ea41a94ecbe42bba88de1c2e3ac607d5ea4 Mon Sep 17 00:00:00 2001 > From: Marius Bakke > Date: Tue, 11 Apr 2017 10:55:22 +0200 > Subject: [PATCH 2/4] vm: Unconditionally add a small ESP partition. > > * gnu/system/vm.scm (qemu-image): Append 20MB FAT32 partition. [...] > (partitions (list (partition > (size #$(- disk-image-size > - (* 10 (expt 2 20)))) > + (* 30 (expt 2 20)))) > (label #$file-system-label) > (file-system #$file-system-type) > (flags '("boot")) > - (initializer initialize))))) > + (initializer initialize)) > + (partition > + ;; Append a small FAT32 partition f= or > + ;; use with UEFI bootloaders. > + (size (* 20 (expt 2 20))) > + (label "gnu-esp") > + (file-system "vfat") > + (flags '("esp")))))) Should we do it conditionally, only when targeting UEFI? (BTW, what=E2=80=99s =E2=80=9Cesp=E2=80=9D?) > From 4306bae25d6110ec52b8bbe3ad8b55f2c4c18fca Mon Sep 17 00:00:00 2001 > From: Marius Bakke > Date: Mon, 17 Apr 2017 22:21:28 +0200 > Subject: [PATCH 3/4] gnu: dosfstools: Enable compatibility symlinks. > > * gnu/packages/disk.scm (dosfstools)[arguments]<#:configure-flags>: New > parameter. LGTM. > From d3e733739edebfd42efd70e7cc6335f3862f1ed5 Mon Sep 17 00:00:00 2001 > From: Marius Bakke > Date: Mon, 17 Apr 2017 22:25:43 +0200 > Subject: [PATCH 4/4] gnu: vm: Add FAT32 utilities in base image. > > * gnu/system/vm.scm (qemu-image): Add DOSFSTOOLS to the closure. OK. Thank you for working on it! Ludo=E2=80=99.