package: fai
version: 5.2
tags: patch
severity: wishlist

It's impossible to use FAI to install for a platform/system that
requires UEFI because FAI does not currently support setting up a
extended system partition as required by the UEFI spec.
This patch adds code to do that.

I did not update the documentation in this patch, because I'm not that
familiar with all the documentation I'd need to touch.
An example disk_config might look something like:

#
# <type> <mountpoint> <size>   <fs type> <mount options> <misc options>

disk_config disk1 disklabel:gpt bootable:1 esp:1 fstabkey:uuid align-at:1M

primary /boot/efi 300    vfat  defaults
primary /      300-      ext4  rw,barrier=0,noatime,errors=remount-ro 
tuneopts="-c 0 -i 0"


>From 06a30575b8c473da89a031587debd8f6f350ba6b Mon Sep 17 00:00:00 2001
From: Sam Hartman <hartm...@debian.org>
Date: Mon, 7 Nov 2016 16:41:12 -0500
Subject: [PATCH] Add support for ESP partitions

UEFI requires a special vfat partition on which the boot loader and
potentially other UEFI information lives.  Parted represents this with
an esp flag.  Add support for this in setup-storage.
---
 lib/setup-storage/Commands.pm | 2 ++
 lib/setup-storage/Parser.pm   | 8 ++++++++
 2 files changed, 10 insertions(+)

diff --git a/lib/setup-storage/Commands.pm b/lib/setup-storage/Commands.pm
index 31898ca..6190343 100755
--- a/lib/setup-storage/Commands.pm
+++ b/lib/setup-storage/Commands.pm
@@ -1344,6 +1344,8 @@ sub setup_partitions {
       if ($part->{size}->{preserve} || $part->{size}->{resize});
     # set the bootable flag, if requested at all
     $flags .= ",boot" if($FAI::configs{$config}{bootable} == $part_id);
+    # set the ESP flag, if requested at all
+    $flags .= ",esp" if($FAI::configs{$config}{esp} == $part_id);
     # set the bios_grub flag on BIOS compatible GPT tables
     $flags .= ",bios_grub" if($FAI::configs{$config}{disklabel} eq "gpt-bios"
       && $FAI::configs{$config}{gpt_bios_part} == $part_id);
diff --git a/lib/setup-storage/Parser.pm b/lib/setup-storage/Parser.pm
index 943eaa5..d58afe9 100755
--- a/lib/setup-storage/Parser.pm
+++ b/lib/setup-storage/Parser.pm
@@ -144,6 +144,7 @@ sub init_disk_config {
     virtual    => 0,
     disklabel  => "msdos",
     bootable   => -1,
+    esp                => 0,
     fstabkey   => "device",
     preserveparts => 0,
     partitions => {},
@@ -690,6 +691,13 @@ $FAI::Parser = Parse::RecDescent->new(
           ($FAI::device =~ /^PHY_(.+)$/) or
             &FAI::internal_error("unexpected device name");
         }
+        | /^esp:(\d+)/
+        {
+          # specify a partition that should get the ESP flag set
+          $FAI::configs{$FAI::device}{esp} = $1;
+          ($FAI::device =~ /^PHY_(.+)$/) or
+            &FAI::internal_error("unexpected device name");
+        }
         | 'virtual'
         {
           # this is a configuration for a virtual disk
-- 
2.9.3

Reply via email to