[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] warn about boot from ext4 with no bootloader support



Note: untested patch for comments.

This adds a check.d script to partman-target to try and warn
the user if they configure ext4 for the boot device on an architecture
with no bootloaders known to handle it.

Does this seem like the right approach?

	Max
Index: partman-ext3/debian/changelog
===================================================================
--- partman-ext3/debian/changelog	(revision 60823)
+++ partman-ext3/debian/changelog	(working copy)
@@ -1,7 +1,12 @@
 partman-ext3 (59) UNRELEASED; urgency=low
 
+  [ Colin Watson ]
   * Upgrade to debhelper v7.
 
+  [ Max Vozeler ]
+  * Warn user if configured to boot from ext4 on an arch without
+    bootloaders known to support it.
+
  -- Colin Watson <cjwatson@debian.org>  Tue, 01 Sep 2009 02:13:13 +0100
 
 partman-ext3 (58) unstable; urgency=low
Index: partman-ext3/check.d/_numbers
===================================================================
--- partman-ext3/check.d/_numbers	(revision 60823)
+++ partman-ext3/check.d/_numbers	(working copy)
@@ -1,2 +1,3 @@
 09 nomountpoint_ext3
 10 ext2_or_ext3_boot
+11 ext4_bootloader
Index: partman-ext3/check.d/ext4_bootloader
===================================================================
--- partman-ext3/check.d/ext4_bootloader	(revision 0)
+++ partman-ext3/check.d/ext4_bootloader	(revision 0)
@@ -0,0 +1,72 @@
+#!/bin/sh
+# Check that if the user configured to boot from ext4 this
+# arch has a choice of bootloader which can handle it. 
+
+. /lib/partman/lib/base.sh
+
+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
+		[ "$fs" != free ] || continue
+		[ -f $id/method ] || continue
+		[ -f $id/acting_filesystem ] || continue
+		[ -f $id/mountpoint ] || continue
+		mountpoint=$(cat $id/mountpoint)
+		filesystem=$(cat $id/acting_filesystem)
+		if [ "$mountpoint" = / ]; then
+			root_fs=$filesystem
+			root_type=$type
+			root_path=$path
+		elif [ "$mountpoint" = /boot ]; then
+			boot_fs=$filesystem
+			boot_type=$type
+			boot_path=$path
+		fi
+	done
+	close_dialog
+done
+
+# If no separate boot partition exists root acts as boot
+if [ -z "$boot_path" ]; then
+	boot_fs=$root_fs
+	boot_type=$root_type
+	boot_path=$root_path
+fi
+
+# Only make further checks if this is ext4
+if [ "$boot_fs" != ext4 ]; then
+	exit 0
+fi
+
+# Duplicates decisions from the bootloader installers, but
+# we cannot wait until those happen. 
+handles_ext4=
+
+ARCH=$(udpkg --print-architecture)
+case $ARCH in
+	i386|amd64)
+		# Those archs have lilo,grub,grub2 which are fine
+		handles_ext4=true
+		;;
+	powerpc)
+		# May work, but untested
+		handles_ext4=true
+		;;
+	alpha|powerpc|mips|sparc|mips|mipsel|hppa|*)
+		# Archs without bootloaders known to grok ext4
+		;;
+esac
+		
+if [ -z "$handles_ext4" ]; then
+	## XX show warning
+	db_set partman-ext3/boot_not_ext2_or_ext3 true
+	db_input critical partman-ext3/boot_not_ext2_or_ext3 || true
+	db_go || true
+	db_get partman-ext3/boot_not_ext2_or_ext3
+	if [ "$RET" = true ]; then
+		exit 1
+	fi
+fi
+

Property changes on: partman-ext3/check.d/ext4_bootloader
___________________________________________________________________
Added: svn:executable
   + *


Reply to: