[EFI] partman-auto: add x86 UEFI support
Hi,
This package includes the biggest changes out of my patchset. Again,
merging some Ubuntu code is the basis of the changes but I've tweaked
a little too. Much of the diff is adding new automatic recipes for
amd64/efi and i386/efi.
Depends on the libdebian-installer patch to add the "efi" subarch.
--
Steve McIntyre, Cambridge, UK. steve@einval.com
Google-bait: http://www.debian.org/CD/free-linux-cd
Debian does NOT ship free CDs. Please do NOT contact the mailing
lists asking us to send them to you.
diff --git a/debian/changelog b/debian/changelog
index 816e0f0..207497c 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/_numbers b/recipes-i386-efi/_numbers
new file mode 100644
index 0000000..341b03f
--- /dev/null
+++ b/recipes-i386-efi/_numbers
@@ -0,0 +1,3 @@
+30 atomic
+50 home
+80 multi
diff --git a/recipes-i386-efi/atomic b/recipes-i386-efi/atomic
new file mode 100644
index 0000000..bfa644b
--- /dev/null
+++ b/recipes-i386-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-i386-efi/home b/recipes-i386-efi/home
new file mode 100644
index 0000000..9ce90d7
--- /dev/null
+++ b/recipes-i386-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-i386-efi/multi b/recipes-i386-efi/multi
new file mode 100644
index 0000000..25e8ac6
--- /dev/null
+++ b/recipes-i386-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/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{ } .
Reply to: