EFI patches rollup
Hi folks,
Here's an updated set of patches for d-i packages for EFI support on
x86. Mostly identical to previous versions, but ported forwards to
current head. Bigger changes:
* I've tweaked partman-efi a little after swapping email with Colin
* I've dropped elilo patches, let's just go with grub-efi
Please review and commit, or give me commit access so I can do it
myself! :-)
After this, I'll make some tweaks to the d-i build scripts to make EFI
boot images at build time, using efi-image. At the moment I have this
in debian-cd for easier testing for me, but it really belongs in d-i
to get build-deps as needed. Then I'll merge my debian-cd EFI branch
onto trunk. Then we'll get EFI by default for x86 builds! \o/
--
Steve McIntyre, Cambridge, UK. steve@einval.com
Welcome my son, welcome to the machine.
>From 7ef6a8af1997e5fcf5415abc6040995b61c63094 Mon Sep 17 00:00:00 2001
From: Steve McIntyre <steve@einval.com>
Date: Wed, 19 Sep 2012 18:26:31 +0100
Subject: [PATCH] Build on amd64 and i386 as well as ia64
---
debian/changelog | 8 ++++++++
debian/control | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/debian/changelog b/debian/changelog
index 2650718..05944df 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+efi-reader (0.11) unstable; urgency=low
+
+ [ Steve McIntyre ]
+ * Build on amd64 and i386 as well as ia64, now we have EFI support there
+ too. Closes: #512348.
+
+ -- Steve McIntyre <93sam@debian.org> Wed, 08 Aug 2012 18:29:59 +0100
+
efi-reader (0.10) unstable; urgency=low
[ Frans Pop ]
diff --git a/debian/control b/debian/control
index a0e68a9..5537848 100644
--- a/debian/control
+++ b/debian/control
@@ -8,7 +8,7 @@ Vcs-Browser: http://git.debian.org/?p=d-i/efi-reader.git
Vcs-Git: git://git.debian.org/d-i/efi-reader.git
Package: efi-reader
-Architecture: ia64
+Architecture: ia64 amd64 i386
Depends: ${shlibs:Depends}
Description: Select default values from EFI configuration.
XC-Package-Type: udeb
--
1.7.10.4
>From 546b70b375e47a5e720aa9210f4053de814a87cf Mon Sep 17 00:00:00 2001
From: Steve McIntyre <steve@einval.com>
Date: Wed, 19 Sep 2012 18:56:55 +0100
Subject: [PATCH] Add support for EFI on amd64 and i386
* Allow grub for amd64/efi and i386/efi, installing grub-efi instead of
grub-pc.
* Make sure that we have /sys and /proc mounted in /target in the
postinst, so that efibootmgr will work ok.
---
debian/changelog | 10 ++++++++++
debian/postinst | 6 ++++++
grub-installer | 20 ++++++++++++++------
3 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index e8c6cc6..944c2c3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,13 @@
+grub-installer (1.79) unstable; urgency=low
+
+ [ Steve McIntyre ]
+ * Allow grub for amd64/efi and i386/efi, installing grub-efi instead of
+ grub-pc.
+ * Make sure that we have /sys and /proc mounted in /target in the
+ postinst, so that efibootmgr will work ok.
+
+ -- Steve McIntyre <93sam@debian.org> Sat, 01 Sep 2012 23:27:54 +0100
+
grub-installer (1.78) unstable; urgency=low
[ Updated translations ]
diff --git a/debian/postinst b/debian/postinst
index b32a1d0..5e001f1 100755
--- a/debian/postinst
+++ b/debian/postinst
@@ -1,2 +1,8 @@
#! /bin/sh -e
+
+# If we're installing grub-efi, it wants /sys mounted in the
+# target. Maybe /proc too?
+mount -t sysfs sys /target/sys || true
+mount -t proc procfs /target/proc || true
+
grub-installer /target
diff --git a/grub-installer b/grub-installer
index a0a4d8c..e9f350e 100755
--- a/grub-installer
+++ b/grub-installer
@@ -312,11 +312,16 @@ case $ARCH in
if [ -d /sys/firmware/efi ]; then
# This point can't be reached (yet). See debian/isinstallable.
grub_package="grub-efi"
- experimental_arch
else
grub_package="grub-pc"
fi
;;
+ i386/efi|amd64/efi)
+ grub_package="grub-efi"
+ ;;
+ i386/*|amd64/*)
+ grub_package="grub-pc"
+ ;;
powerpc/*)
grub_package="grub-ieee1275"
experimental_arch
@@ -409,10 +414,13 @@ db_progress INFO grub-installer/progress/step_install
# to grub legacy, or vice-versa
case "$grub_package" in
grub)
- log-output -t grub-installer $chroot $ROOT dpkg -P grub-pc-bin grub-pc
+ log-output -t grub-installer $chroot $ROOT dpkg -P grub-pc-bin grub-pc grub-efi grub-efi-amd64-bin grub-efi-amd64 grub-efi-ia32-bin grub-efi-ia32 grub-gfxpayload-lists
;;
grub-pc)
- log-output -t grub-installer $chroot $ROOT dpkg -P grub grub-legacy
+ log-output -t grub-installer $chroot $ROOT dpkg -P grub grub-legacy grub-efi grub-efi-amd64-bin grub-efi-amd64 grub-efi-ia32-bin grub-efi-ia32
+ ;;
+ grub-efi)
+ log-output -t grub-installer $chroot $ROOT dpkg -P grub grub-legacy grub-pc-bin grub-pc grub-gfxpayload-lists
;;
esac
@@ -662,7 +670,7 @@ if [ -z "$frdisk" ]; then
CODE=0
case $ARCH:$grub_package in
- *:grub|*:grub-pc|sparc:grub-ieee1275)
+ *:grub|*:grub-pc|*:grub-efi|sparc:grub-ieee1275)
info "Running $chroot $ROOT grub-install $grub_install_params \"$bootdev\""
log-output -t grub-installer $chroot $ROOT grub-install $grub_install_params "$bootdev" || CODE=$?
;;
@@ -675,7 +683,7 @@ if [ -z "$frdisk" ]; then
info "grub-install ran successfully"
else
case $ARCH:$grub_package in
- *:grub|*:grub-pc|sparc:grub-ieee1275)
+ *:grub|*:grub-pc|*:grub-efi|sparc:grub-ieee1275)
error "Running 'grub-install $grub_install_params \"$bootdev\"' failed."
;;
*)
@@ -962,7 +970,7 @@ if [ "$serial" ] ; then
) >$ROOT/boot/grub/$menu_file.new
mv $ROOT/boot/grub/$menu_file.new $ROOT/boot/grub/$menu_file
;;
- grub-pc)
+ grub-pc|grub-efi)
if grep -q "^GRUB_TERMINAL=" $ROOT/etc/default/grub; then
sed -i $ROOT/etc/default/grub -e "s/^\(GRUB_TERMINAL\)=.*/\1=serial/g"
else
--
1.7.10.4
>From 7479488017fd905ae86ee4632b28d392e84a6d99 Mon Sep 17 00:00:00 2001
From: Steve McIntyre <steve@einval.com>
Date: Wed, 22 Aug 2012 19:34:50 +0100
Subject: [PATCH] Add "efi" as a subarch for amd64 and i386
---
debian/changelog | 7 +++++++
src/system/subarch-x86-linux.c | 16 ++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index d48c86a..1250fdb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+libdebian-installer (0.84) UNRELEASED; urgency=low
+
+ [ Steve McIntyre ]
+ * Add "efi" as a subarch for amd64 and i386
+
+ -- Steve McIntyre <93sam@debian.org> Wed, 22 Aug 2012 19:24:48 +0100
+
libdebian-installer (0.83) unstable; urgency=low
* Re-upload without files from git checkout.
diff --git a/src/system/subarch-x86-linux.c b/src/system/subarch-x86-linux.c
index 567d3c2..1e903b3 100644
--- a/src/system/subarch-x86-linux.c
+++ b/src/system/subarch-x86-linux.c
@@ -250,6 +250,17 @@ static char *dmi_system_manufacturer(void)
return ret;
}
+/* Are we on an EFI system? Check to see if /sys/firmware/efi
+ * exists */
+static int is_efi(void)
+{
+ int ret = access("/sys/firmware/efi", R_OK);
+ if (ret == 0)
+ return 1;
+ else
+ return 0;
+}
+
struct map {
const char *entry;
const char *ret;
@@ -267,6 +278,11 @@ const char *di_system_subarch_analyze(void)
const char *ret = "generic";
int i;
+ /* Look for generic EFI first; this will be over-ridden by the mac
+ * detection next if we're on a mac. */
+ if (is_efi())
+ ret = "efi";
+
if (manufacturer)
{
for (i = 0; map_manufacturer[i].entry; i++)
--
1.7.10.4
>From 3ccb94b048acd1542db94179b2b565c84dfe915e Mon Sep 17 00:00:00 2001
From: Steve McIntyre <steve@einval.com>
Date: Wed, 19 Sep 2012 19:01:47 +0100
Subject: [PATCH] Don't use lilo for */efi
---
debian/changelog | 7 +++++++
debian/isinstallable | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 98699fa..3088581 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+lilo-installer (1.39) unstable; urgency=low
+
+ [ Steve McIntyre]
+ * Don't use lilo for */efi
+
+ -- Steve McIntyre <93sam@debian.org> Sat, 01 Sep 2012 23:35:13 +0100
+
lilo-installer (1.38) unstable; urgency=low
* Fix detection of initrd.img when generating lilo.conf.
diff --git a/debian/isinstallable b/debian/isinstallable
index 829ca29..e3f9708 100755
--- a/debian/isinstallable
+++ b/debian/isinstallable
@@ -7,12 +7,12 @@ log() {
ARCH="$(archdetect)"
case $ARCH in
- i386/mac|amd64/mac)
+ i386/mac|amd64/mac|i386/efi|amd64/efi)
# LILO stands a better chance of working in BIOS compatibility mode,
# where /sys/firmware/efi doesn't exist.
# Note: depends on partman-efi to load the efivars module!
if [ -d /sys/firmware/efi ]; then
- log "LILO not usable on Intel-based Macs without BIOS compatibility; use elilo"
+ log "LILO not usable on EFI PCs without BIOS compatibility; use grub-efi"
exit 1
fi
;;
--
1.7.10.4
>From 3a01c68539c012c69a088d104b18b0222b646dc7 Mon Sep 17 00:00:00 2001
From: Steve McIntyre <steve@einval.com>
Date: Wed, 19 Sep 2012 19:13:29 +0100
Subject: [PATCH] Add x86 UEFI support, merging some code from Ubuntu to help
* Add extra recipe method "reusemethod" to help us reuse existing EFI
system partitions
* Clone the ia64 recipes for {amd64,i386}-efi and tweak. Merge
across some of the Ubuntu settings for these new recipes, including
use of reusemethod.
* Make the EFI system partition large by default to meet fat32
recommendations
---
debian/changelog | 14 +++++++
lib/recipes.sh | 90 +++++++++++++++++++++++++++++++++-----------
perform_recipe | 2 +
recipes-amd64-efi/_numbers | 3 ++
recipes-amd64-efi/atomic | 29 ++++++++++++++
recipes-amd64-efi/home | 38 +++++++++++++++++++
recipes-amd64-efi/multi | 62 ++++++++++++++++++++++++++++++
recipes-i386-efi | 1 +
recipes/atomic | 4 +-
recipes/home | 4 +-
recipes/multi | 4 +-
11 files changed, 223 insertions(+), 28 deletions(-)
create mode 100644 recipes-amd64-efi/_numbers
create mode 100644 recipes-amd64-efi/atomic
create mode 100644 recipes-amd64-efi/home
create mode 100644 recipes-amd64-efi/multi
create mode 120000 recipes-i386-efi
diff --git a/debian/changelog b/debian/changelog
index f557f50..22fa554 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,17 @@
+partman-auto (104) unstable; urgency=low
+
+ [ Steve McIntyre ]
+ * Add x86 UEFI support, merging some code from Ubuntu to help:
+ + Add extra recipe method "reusemethod" to help us reuse existing EFI
+ system partitions
+ + Clone the ia64 recipes for {amd64,i386}-efi and tweak. Merge
+ across some of the Ubuntu settings for these new recipes, including
+ use of reusemethod.
+ + Make the EFI system partition large by default to meet fat32
+ recommendations
+
+ -- Steve McIntyre <93sam@debian.org> Tue, 21 Aug 2012 23:19:23 +0100
+
partman-auto (103) unstable; urgency=low
[ Milan Kupcevic ]
diff --git a/lib/recipes.sh b/lib/recipes.sh
index ed3e6ea..a399013 100644
--- a/lib/recipes.sh
+++ b/lib/recipes.sh
@@ -24,10 +24,26 @@ autopartitioning_failed () {
exit 1
}
+find_method () {
+ local num id size type fs path name method found
+ found=
+ open_dialog PARTITIONS
+ while { read_line num id size type fs path name; [ "$id" ]; }; do
+ [ -f $id/method-old ] || continue
+ method="$(cat $id/method-old)"
+ if [ "$method" = "$1" ]; then
+ found="$id"
+ fi
+ done
+ close_dialog
+ echo "$found"
+}
+
unnamed=0
decode_recipe () {
local ignore ram line word min factor max fs iflabel label map map_end -
+ local reusemethod method id
ignore="${2:+${2}ignore}"
unnamed=$(($unnamed + 1))
ram=
@@ -121,30 +137,44 @@ decode_recipe () {
# Exclude partitions that have ...ignore set
if [ "$ignore" ] && [ "$(echo $line | grep "$ignore")" ]; then
- :
- else
- # Exclude partitions that are only for a
- # different disk label. The $PWD check
- # avoids problems when running from older
- # versions of partman-auto-lvm, where we
- # weren't in a subdirectory of $DEVICES
- # while decoding the recipe; we preserve it
- # in case of custom code with the same
- # problem.
- iflabel="$(echo $line | sed -n 's/.*\$iflabel{ \([^}]*\) }.*/\1/p')"
- if [ "$iflabel" ]; then
- if [ "${PWD#$DEVICES/}" != "$PWD" ]; then
- open_dialog GET_LABEL_TYPE
- read_line label
- close_dialog
- if [ "$iflabel" = "$label" ]; then
- scheme="${scheme:+$scheme$NL}$line"
- fi
+ line=
+ continue
+ fi
+
+ # Exclude partitions that are only for a different
+ # disk label. The $PWD check avoids problems when
+ # running from older versions of partman-auto-lvm,
+ # where we weren't in a subdirectory of $DEVICES
+ # while decoding the recipe; we preserve it in case
+ # of custom code with the same problem.
+ iflabel="$(echo $line | sed -n 's/.*\$iflabel{ \([^}]*\) }.*/\1/p')"
+ if [ "$iflabel" ]; then
+ if [ "${PWD#$DEVICES/}" = "$PWD" ]; then
+ line=''
+ continue
+ fi
+
+ open_dialog GET_LABEL_TYPE
+ read_line label
+ close_dialog
+ if [ "$iflabel" != "$label" ]; then
+ line=''
+ continue
+ fi
+ fi
+
+ # Check if we can reuse an existing partition.
+ if echo "$line" | grep -q '\$reusemethod{'; then
+ if [ "${PWD#$DEVICES/}" != "$PWD" ]; then
+ method="$(echo "$line" | sed -n 's/.* method{ \([^}]*\) }.*/\1/p')"
+ id="$(find_method "$method")"
+ if [ "$id" ]; then
+ line="$(echo "$line" | sed 's/\$reusemethod{[^}]*}/$reuse{ '"$id"' }/')"
fi
- else
- scheme="${scheme:+$scheme$NL}$line"
fi
fi
+
+ scheme="${scheme:+$scheme$NL}$line"
line=''
;;
*)
@@ -378,6 +408,21 @@ choose_recipe () {
}
expand_scheme() {
+ # Filter out reused partitions first, as we don't want to take
+ # account of their size.
+ scheme_reused=$(
+ foreach_partition '
+ if echo "$*" | grep -q '\''\$reuse{'\''; then
+ echo "$*"
+ fi'
+ )
+ scheme=$(
+ foreach_partition '
+ if ! echo "$*" | grep -q '\''\$reuse{'\''; then
+ echo "$*"
+ fi'
+ )
+
# Make factors small numbers so we can multiply on them.
# Also ensure that fact, max and fs are valid
# (Ofcourse in valid recipes they must be valid.)
@@ -444,7 +489,8 @@ clean_method() {
cd $device
open_dialog PARTITIONS
while { read_line num id size type fs path name; [ "$id" ]; }; do
- rm -f $id/method
+ [ -e $id/method ] || continue
+ mv $id/method $id/method-old
done
close_dialog
done
diff --git a/perform_recipe b/perform_recipe
index b48c739..89b09e1 100755
--- a/perform_recipe
+++ b/perform_recipe
@@ -35,6 +35,8 @@ expand_scheme
ensure_primary
+reuse_partitions
+
db_progress STEP 1
create_primary_partitions
diff --git a/recipes-amd64-efi/_numbers b/recipes-amd64-efi/_numbers
new file mode 100644
index 0000000..341b03f
--- /dev/null
+++ b/recipes-amd64-efi/_numbers
@@ -0,0 +1,3 @@
+30 atomic
+50 home
+80 multi
diff --git a/recipes-amd64-efi/atomic b/recipes-amd64-efi/atomic
new file mode 100644
index 0000000..bfa644b
--- /dev/null
+++ b/recipes-amd64-efi/atomic
@@ -0,0 +1,29 @@
+partman-auto/text/atomic_scheme ::
+
+512 512 1024 free
+ $iflabel{ gpt }
+ $reusemethod{ }
+ method{ efi }
+ format{ } .
+
+128 512 256 ext2
+ $defaultignore{ }
+ method{ format }
+ format{ }
+ use_filesystem{ }
+ filesystem{ ext2 }
+ mountpoint{ /boot } .
+
+500 10000 -1 $default_filesystem
+ $lvmok{ }
+ method{ format }
+ format{ }
+ use_filesystem{ }
+ $default_filesystem{ }
+ mountpoint{ / } .
+
+100% 512 200% linux-swap
+ $lvmok{ }
+ $reusemethod{ }
+ method{ swap }
+ format{ } .
diff --git a/recipes-amd64-efi/home b/recipes-amd64-efi/home
new file mode 100644
index 0000000..9ce90d7
--- /dev/null
+++ b/recipes-amd64-efi/home
@@ -0,0 +1,38 @@
+partman-auto/text/home_scheme ::
+
+512 512 1024 free
+ $iflabel{ gpt }
+ $reusemethod{ }
+ method{ efi }
+ format{ } .
+
+128 512 256 ext2
+ $defaultignore{ }
+ method{ format }
+ format{ }
+ use_filesystem{ }
+ filesystem{ ext2 }
+ mountpoint{ /boot } .
+
+500 5000 10000 $default_filesystem
+ $lvmok{ }
+ method{ format }
+ format{ }
+ use_filesystem{ }
+ $default_filesystem{ }
+ mountpoint{ / } .
+
+96 512 200% linux-swap
+ $lvmok{ }
+ $reusemethod{ }
+ method{ swap }
+ format{ } .
+
+100 10000 -1 $default_filesystem
+ $lvmok{ }
+ method{ format }
+ format{ }
+ use_filesystem{ }
+ $default_filesystem{ }
+ mountpoint{ /home } .
+
diff --git a/recipes-amd64-efi/multi b/recipes-amd64-efi/multi
new file mode 100644
index 0000000..25e8ac6
--- /dev/null
+++ b/recipes-amd64-efi/multi
@@ -0,0 +1,62 @@
+partman-auto/text/multi_scheme ::
+
+512 512 1024 free
+ $iflabel{ gpt }
+ $reusemethod{ }
+ method{ efi }
+ format{ } .
+
+128 512 256 ext2
+ $defaultignore{ }
+ method{ format }
+ format{ }
+ use_filesystem{ }
+ filesystem{ ext2 }
+ mountpoint{ /boot } .
+
+100 800 500 $default_filesystem
+ $lvmok{ }
+ method{ format }
+ format{ }
+ use_filesystem{ }
+ $default_filesystem{ }
+ mountpoint{ / } .
+
+700 7000 7000 $default_filesystem
+ $lvmok{ }
+ method{ format }
+ format{ }
+ use_filesystem{ }
+ $default_filesystem{ }
+ mountpoint{ /usr } .
+
+60 1500 3000 $default_filesystem
+ $lvmok{ }
+ method{ format }
+ format{ }
+ use_filesystem{ }
+ $default_filesystem{ }
+ mountpoint{ /var } .
+
+96 512 200% linux-swap
+ $lvmok{ }
+ $reusemethod{ }
+ method{ swap }
+ format{ } .
+
+50 300 400 $default_filesystem
+ $lvmok{ }
+ method{ format }
+ format{ }
+ use_filesystem{ }
+ $default_filesystem{ }
+ mountpoint{ /tmp } .
+
+300 3000 -1 $default_filesystem
+ $lvmok{ }
+ method{ format }
+ format{ }
+ use_filesystem{ }
+ $default_filesystem{ }
+ mountpoint{ /home } .
+
diff --git a/recipes-i386-efi b/recipes-i386-efi
new file mode 120000
index 0000000..d383b93
--- /dev/null
+++ b/recipes-i386-efi
@@ -0,0 +1 @@
+recipes-amd64-efi
\ No newline at end of file
diff --git a/recipes/atomic b/recipes/atomic
index 88e97b7..4b50b0f 100644
--- a/recipes/atomic
+++ b/recipes/atomic
@@ -2,11 +2,11 @@ partman-auto/text/atomic_scheme ::
1 1 1 free
$iflabel{ gpt }
+ $reusemethod{ }
method{ biosgrub } .
128 512 256 ext2
$defaultignore{ }
- $bootable{ }
method{ format }
format{ }
use_filesystem{ }
@@ -15,7 +15,6 @@ partman-auto/text/atomic_scheme ::
900 10000 -1 $default_filesystem
$lvmok{ }
- $bootable{ }
method{ format }
format{ }
use_filesystem{ }
@@ -24,5 +23,6 @@ partman-auto/text/atomic_scheme ::
96 512 200% linux-swap
$lvmok{ }
+ $reusemethod{ }
method{ swap }
format{ } .
diff --git a/recipes/home b/recipes/home
index f52dfa2..fd2a042 100644
--- a/recipes/home
+++ b/recipes/home
@@ -2,11 +2,11 @@ partman-auto/text/home_scheme ::
1 1 1 free
$iflabel{ gpt }
+ $reusemethod{ }
method{ biosgrub } .
128 512 256 ext2
$defaultignore{ }
- $bootable{ }
method{ format }
format{ }
use_filesystem{ }
@@ -15,7 +15,6 @@ partman-auto/text/home_scheme ::
900 4000 10000 $default_filesystem
$lvmok{ }
- $bootable{ }
method{ format }
format{ }
use_filesystem{ }
@@ -24,6 +23,7 @@ partman-auto/text/home_scheme ::
96 512 200% linux-swap
$lvmok{ }
+ $reusemethod{ }
method{ swap }
format{ } .
diff --git a/recipes/multi b/recipes/multi
index 59f3983..708e788 100644
--- a/recipes/multi
+++ b/recipes/multi
@@ -2,11 +2,11 @@ partman-auto/text/multi_scheme ::
1 1 1 free
$iflabel{ gpt }
+ $reusemethod{ }
method{ biosgrub } .
128 512 256 ext2
$defaultignore{ }
- $bootable{ }
method{ format }
format{ }
use_filesystem{ }
@@ -15,7 +15,6 @@ partman-auto/text/multi_scheme ::
300 800 350 $default_filesystem
$lvmok{ }
- $bootable{ }
method{ format }
format{ }
use_filesystem{ }
@@ -40,6 +39,7 @@ partman-auto/text/multi_scheme ::
96 512 200% linux-swap
$lvmok{ }
+ $reusemethod{ }
method{ swap }
format{ } .
--
1.7.10.4
>From b790ff8f0dc1b3049297f1ab825ca4d3edc6c016 Mon Sep 17 00:00:00 2001
From: Steve McIntyre <steve@einval.com>
Date: Wed, 19 Sep 2012 19:22:55 +0100
Subject: [PATCH] EFI development work, merging code from Ubuntu
* format EFI system partition using fat32 on x86/efi, leave fat16 on
ia64
* label appropriately
* check that the EFI system partition is big enough at creation time
* Don't format things that look like existing EFI system partitions,
reuse them instead
* fixed a bug in shell variable expansion in lib/partman/lib/base.sh
---
check.d/efi | 26 +++++++++++++++++++++++---
choose_method/efi/do_option | 9 ++++++++-
commit.d/format_efi | 21 +++++++++++++++++++--
debian/changelog | 13 +++++++++++++
debian/install | 1 +
debian/partman-efi.templates | 7 ++++++-
fstab.d/efi | 30 ++++++++++++++++++++++++++++++
init.d/efi | 36 ++++++++++++++++++++++++++++++++----
update.d/efi_sync_flag | 15 +++++++++++++++
9 files changed, 147 insertions(+), 11 deletions(-)
create mode 100755 fstab.d/efi
diff --git a/check.d/efi b/check.d/efi
index cf6f26f..395688d 100755
--- a/check.d/efi
+++ b/check.d/efi
@@ -7,6 +7,7 @@ fi
. /lib/partman/lib/base.sh
have_efi=no
+new_efi_size=
# Is there at least one efi-partition?
for dev in $DEVICES/*; do
@@ -16,17 +17,22 @@ for dev in $DEVICES/*; do
open_dialog PARTITIONS
while { read_line num id size type fs path name; [ "$id" ]; }; do
[ "$fs" != free ] || continue
- partitions="$partitions $id,$num"
+ partitions="$partitions $id,$num,$size"
done
close_dialog
for part in $partitions; do
- id=${part%,*}
- num=${part#*,}
+ id=${part%%,*}
+ part=${part##*,}
+ num=${part%%,*}
+ size=${part#*,}
[ -f $id/method ] || continue
method=$(cat $id/method)
if [ "$method" = efi ] && [ -f $id/bootable ]; then
have_efi=yes
+ if [ -f $id/format ] && [ -z "$new_efi_size" ]; then
+ new_efi_size="$size"
+ fi
fi
done
done
@@ -40,4 +46,18 @@ if [ $have_efi = no ]; then
fi
fi
+ARCH="$(archdetect)"
+
+# Experimentally-verified minimum size for a FAT32 filesystem created using
+# libparted.
+case $ARCH in
+ i386/*|amd64/*)
+ if [ "$new_efi_size" ] && longint_le "$new_efi_size" 34091007; then
+ db_input critical partman-efi/too_small_efi || true
+ db_go || true
+ exit 1
+ fi
+ ;;
+esac
+
exit 0
diff --git a/choose_method/efi/do_option b/choose_method/efi/do_option
index c3b799a..2f5a663 100755
--- a/choose_method/efi/do_option
+++ b/choose_method/efi/do_option
@@ -6,11 +6,18 @@ id=$3
mkdir -p $dev/$id
echo efi >$dev/$id/method
->$dev/$id/format
+# See comment in commit.d/format_efi. We check again here to make the
+# confirm-changes screen less scary.
+if [ -f $dev/$id/detected_filesystem ]; then
+ rm -f $dev/$id/format
+else
+ >$dev/$id/format
+fi
>$dev/$id/bootable
>$dev/$id/efi_bootable
rm -f $dev/$id/use_filesystem
rm -f $dev/$id/filesystem
+rm -f $dev/$id/mountpoint
exit 0
diff --git a/commit.d/format_efi b/commit.d/format_efi
index 20075f2..b93ba4b 100755
--- a/commit.d/format_efi
+++ b/commit.d/format_efi
@@ -2,6 +2,16 @@
. /lib/partman/lib/base.sh
+ARCH="$(archdetect)"
+case $ARCH in
+ i386/*|amd64/*)
+ new_efi_fs=fat32
+ ;;
+ *)
+ new_efi_fs=fat16
+ ;;
+esac
+
enable_swap
for dev in $DEVICES/*; do
[ -d "$dev" ] || continue
@@ -18,13 +28,20 @@ for dev in $DEVICES/*; do
id=${part%,*}
num=${part#*,}
[ -f $id/method -a -f $id/format ] || continue
+ # Formatting an EFI System Partition that already has a
+ # filesystem on it is dangerous
+ # (https://bugs.launchpad.net/bugs/769669). The least bad
+ # option seems to be to skip such partitions entirely.
+ if [ -f $id/detected_filesystem ]; then
+ continue
+ fi
method=$(cat $id/method)
if [ "$method" = efi ]; then
if [ -f $id/formatted ] && \
[ $id/formatted -nt $id/method ]; then
continue
fi
- log "Try to format EFI fat16 fs in $dev/$id"
+ log "Try to format EFI $new_efi_fs fs in $dev/$id"
template=partman-basicfilesystems/progress_formatting
open_dialog PARTITION_INFO $id
read_line x1 x2 x3 x4 x5 device x6
@@ -37,7 +54,7 @@ for dev in $DEVICES/*; do
db_subst $template PARTITION "$num"
db_subst $template DEVICE $(humandev $(cat device))
name_progress_bar $template
- open_dialog CREATE_FILE_SYSTEM $id fat16
+ open_dialog CREATE_FILE_SYSTEM $id $new_efi_fs
read_line status
close_dialog
sync
diff --git a/debian/changelog b/debian/changelog
index 30667a4..ec395cf 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,16 @@
+partman-efi (27) unstable; urgency=low
+
+ * EFI development work, merging code from Ubuntu
+ + format EFI system partition using fat32 on x86/efi, leave fat16 on
+ ia64
+ + label appropriately
+ + check that the EFI system partition is big enough at creation time
+ + Don't format things that look like existing EFI system partitions,
+ reuse them instead
+ + fixed a bug in shell variable expansion in lib/partman/lib/base.sh
+
+ -- Steve McIntyre <93sam@debian.org> Tue, 21 Aug 2012 23:22:01 +0100
+
partman-efi (26) unstable; urgency=low
* Team upload
diff --git a/debian/install b/debian/install
index e273175..7cd2a58 100644
--- a/debian/install
+++ b/debian/install
@@ -1 +1,2 @@
parted_names lib/partman
+fstab.d lib/partman
diff --git a/debian/partman-efi.templates b/debian/partman-efi.templates
index d6bc63a..e48c997 100644
--- a/debian/partman-efi.templates
+++ b/debian/partman-efi.templates
@@ -35,4 +35,9 @@ Type: text
# :sl5:
_Description: EFI-fat16
-
+Template: partman-efi/too_small_efi
+Type: error
+# :sl5:
+_Description: EFI partition too small
+ EFI boot partitions on this architecture cannot be created with a size less
+ than 35 MB. Please make the EFI boot partition larger.
diff --git a/fstab.d/efi b/fstab.d/efi
new file mode 100755
index 0000000..f253bcb
--- /dev/null
+++ b/fstab.d/efi
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+. /lib/partman/lib/base.sh
+
+ARCH="$(archdetect)"
+case $ARCH in
+ i386/mac|amd64/mac)
+ # Not yet sure what to do on Intel Macs. Mounting the EFI System
+ # Partition on /boot/efi will change the behaviour of grub-install,
+ # so it seems best to avoid it for the moment.
+ exit 0
+ ;;
+esac
+
+seen_efi=
+for dev in $DEVICES/*; do
+ [ -d $dev ] || continue
+ cd $dev
+ open_dialog PARTITIONS
+ while { read_line num id size type fs path name; [ "$id" ]; }; do
+ [ -z "$seen_efi" ] || continue
+ [ $fs != free ] || continue
+ [ -f "$id/method" ] || continue
+ method=$(cat $id/method)
+ [ "$method" = efi ] || continue
+ echo "$path" /boot/efi vfat defaults 0 1
+ seen_efi=1
+ done
+ close_dialog
+done
diff --git a/init.d/efi b/init.d/efi
index 6af77ce..3c5a7d2 100755
--- a/init.d/efi
+++ b/init.d/efi
@@ -1,25 +1,53 @@
#!/bin/sh
-# This script sets method "efi" for all fat16 partitions that have the boot
-# flag set.
+# This script sets method "efi" for all fat16/fat32 partitions that
+# have the bootable flag set.
# Give the kernel a chance to create /proc/efi if appropriate.
modprobe efivars >/dev/null 2>&1 || true
-if [ ! -d /proc/efi ] && [ ! -d /sys/firmware/efi ]; then
- exit 0
+if [ -d /proc/efi ] || [ -d /sys/firmware/efi ]; then
+ > /var/lib/partman/efi
+else
+ ARCH="$(archdetect)"
+ case $ARCH in
+ i386/mac|amd64/mac)
+ # Intel Macs have an EFI partition, regardless of
+ # whether we're currently booted using BIOS
+ # compatibility or not (if we are, we won't be able to
+ # talk to EFI directly).
+ > /var/lib/partman/efi
+ ;;
+ *)
+ rm -f /var/lib/partman/efi
+ exit 0
+ ;;
+ esac
fi
. /lib/partman/lib/base.sh
+gpt_efi_type=c12a7328-f81f-11d2-ba4b-00a0c93ec93b
+
for dev in /var/lib/partman/devices/*; do
[ -d "$dev" ] || continue
cd $dev
+
+ open_dialog GET_LABEL_TYPE
+ read_line label_type
+ close_dialog
+
partitions=
open_dialog PARTITIONS
while { read_line num id size type fs path name; [ "$id" ]; }; do
if [ "$fs" = fat16 ]; then
partitions="$partitions $id"
+ elif [ "$fs" = fat32 ] && echo "$name" |
+ grep -i "^EFI System Partition" >/dev/null; then
+ partitions="$partitions $id"
+ elif [ "$label_type" = gpt ] && \
+ [ "$(blkid -o value -s PART_ENTRY_TYPE -p "$path" 2>/dev/null)" = "$gpt_efi_type" ]; then
+ partitions="$partitions $id"
fi
done
close_dialog
diff --git a/update.d/efi_sync_flag b/update.d/efi_sync_flag
index 53d73f6..149c64a 100755
--- a/update.d/efi_sync_flag
+++ b/update.d/efi_sync_flag
@@ -16,6 +16,8 @@ size=$4
type=$5
fs=$6
path=$7
+shift; shift; shift; shift; shift; shift; shift
+name=$*
cd $dev
@@ -37,6 +39,10 @@ while { read_line flag; [ "$flag" ]; }; do
done
close_dialog
+open_dialog USES_NAMES
+read_line uses_names
+close_dialog
+
if [ "$method" = efi ] && [ ! -f $id/bootable ]; then
open_dialog SET_FLAGS $id
write_line "$flags"
@@ -45,6 +51,10 @@ if [ "$method" = efi ] && [ ! -f $id/bootable ]; then
close_dialog
>$id/bootable
>$id/efi_bootable
+ if [ "$uses_names" = yes ] && [ "$fs" = fat32 ]; then
+ open_dialog SET_NAME $id "EFI System Partition"
+ close_dialog
+ fi
RET=''
elif [ "$method" != efi ] && [ -f $id/bootable ] && \
[ -f $id/efi_bootable ]; then
@@ -54,4 +64,9 @@ elif [ "$method" != efi ] && [ -f $id/bootable ] && \
close_dialog
rm $id/bootable
rm $id/efi_bootable
+ if [ "$uses_names" = yes ] && [ "$fs" = fat32 ] && \
+ [ "$name" = "EFI System Partition" ]; then
+ open_dialog SET_NAME ""
+ close_dialog
+ fi
fi
--
1.7.10.4
>From 255e8994ecb89517014da366469c761232bbb0ed Mon Sep 17 00:00:00 2001
From: Steve McIntyre <steve@einval.com>
Date: Wed, 19 Sep 2012 19:27:00 +0100
Subject: [PATCH] On x86 machines booted in EFI mode, use gpt disk label by
default
---
debian/changelog | 6 ++++++
lib/disk-label.sh | 11 ++---------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index b5a529c..97e74aa 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+partman-partitioning (88) unstable; urgency=low
+
+ * On x86 machines booted in EFI mode, use gpt disk label by default.
+
+ -- Steve McIntyre <93sam@debian.org> Tue, 21 Aug 2012 20:22:32 +0100
+
partman-partitioning (87) unstable; urgency=low
* Team upload
diff --git a/lib/disk-label.sh b/lib/disk-label.sh
index c981cd9..f424fc9 100644
--- a/lib/disk-label.sh
+++ b/lib/disk-label.sh
@@ -20,9 +20,9 @@ default_disk_label () {
fi;;
arm|armeb|armel|armhf)
echo msdos;;
- amd64|kfreebsd-amd64)
+ amd64|kfreebsd-amd64|i386|kfreebsd-i386|hurd-i386)
case "$sub" in
- mac)
+ mac|efi)
echo gpt;;
*)
echo msdos;;
@@ -31,13 +31,6 @@ default_disk_label () {
echo msdos;;
ia64)
echo gpt;;
- i386|kfreebsd-i386|hurd-i386)
- case "$sub" in
- mac)
- echo gpt;;
- *)
- echo msdos;;
- esac;;
m68k)
case "$sub" in
amiga)
--
1.7.10.4
Reply to: