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

partman check to make sure the boot partition is ext2/ext3



Some machines required that the boot partition (either /boot if it
exists, or / otherwise) is ext2 or ext3.  The following partman check
is supposed to check this.  Any comments?

Index: partman-ext3/check.d/ext2_or_ext3_boot
===================================================================
--- partman-ext3/check.d/ext2_or_ext3_boot	(revision 0)
+++ partman-ext3/check.d/ext2_or_ext3_boot	(revision 0)
@@ -0,0 +1,71 @@
+#!/bin/sh
+# Check that the boot partition is the 1st (primary) partition and that
+# it is of type ext2 or ext3.
+
+machine=$(grep "^Hardware" /proc/cpuinfo | sed 's/Hardware\s*:\s*//') || true
+case "$machine" in
+	"Buffalo Linkstation Pro/Live" | "Buffalo/Revogear Kurobox Pro")
+	;;
+	"HP Media Vault mv2120")
+	;;
+	*)
+		exit 0
+	;;
+esac
+
+. /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
+
+# We need an ext2 r ext3 filesystem to boot
+if [ "$boot_fs" != ext2 ] && [ "$boot_fs" != ext3 ]; then
+	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
+
+# The boot file system has to be the first primary partition
+part_num=$(echo "$boot_path" | sed -e 's/.*[^0-9]\+//')
+if [ "$boot_type" != primary ] || [ "$part_num" -ne 1 ]; then
+	db_set partman-ext3/boot_not_first_partition true
+	db_input critical partman-ext3/boot_not_first_partition || true
+	db_go || true
+	db_get partman-ext3/boot_not_first_partition
+	if [ "$RET" = true ]; then
+		exit 1
+	fi
+fi
+

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

Index: partman-ext3/debian/partman-ext3.templates
===================================================================
--- partman-ext3/debian/partman-ext3.templates	(revision 55306)
+++ partman-ext3/debian/partman-ext3.templates	(working copy)
@@ -53,3 +53,28 @@
 # :sl1:
 # Short file system name (untranslatable in many languages)
 _Description: ext3
+
+Template: partman-ext3/boot_not_ext2_or_ext3
+Type: boolean
+# :sl2:
+_Description: Go back to the menu and correct this problem?
+ Your boot partition has not been configured with the ext2 or ext3
+ file system. This is needed by your machine in order to boot. Please go
+ back and use either the ext2 or ext3 file system.
+ .
+ If you do not go back to the partitioning menu and correct this error,
+ the partition will be used as is. This means that you may not be able
+ to boot from your hard disk.
+
+Template: partman-ext3/boot_not_first_partition
+Type: boolean
+# :sl2:
+_Description: Go back to the menu and correct this problem?
+ Your boot partition is not located on the first primary partition of your
+ hard disk.  This is needed by your machine in order to boot.  Please go
+ back and use your first primary partition as a boot partition.
+ .
+ If you do not go back to the partitioning menu and correct this error,
+ the partition will be used as is.  This means that you may not be able
+ to boot from your hard disk.
+

(Note that partman-ext3/boot_not_first_partition has two spaces after
full stops because this template is a copy of
partman-ext2r0/boot_not_first_partition.)

-- 
Martin Michlmayr
http://www.cyrius.com/


Reply to: