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

Partman hook for various checks on sparc



Hi,

I've cooked up a little patch, implementing a finish.d hook for partman, which makes sure that the chosen partitioning scheme is sane enough for SILO to work properly. The script (finish.d/silo_check) identifies the partition where kernel is going to be installed (/boot, if it is present, otherwise /) and checks that a) it has a filesystem supported by SILO (ext[23] or ufs) and b) it fits entirely within the first gigabyte from the beginning of the disk on older machines. Older machines are the ones which have the OpenPROM version below 3.x and, therefore, are prone to the infamous 1 GB magic boundary bug. The PROM version is extracted from /proc/cpuinfo. If either of the checks fail, a message is displayed, explaining the situation and giving user a chance to go back to partitioning.

The patch is against today's SVN version of partman-target, which seemed like a right place to put it in (it contains some generic checks already). I've run quite a few tests with it on both my machines and it handled correctly all the situations I could throw at it. Hopefully, it will be found worthy of committing.

Best regards,

Jurij Smakov                                        jurij@wooyd.org
Key: http://www.wooyd.org/pgpkey/                   KeyID: C99E03CC
diff -aurN -x .svn partman-target_orig/debian/templates partman-target/debian/templates
--- partman-target_orig/debian/templates	2004-12-18 15:59:12.000000000 -0500
+++ partman-target/debian/templates	2004-12-18 16:03:26.000000000 -0500
@@ -88,3 +88,26 @@
 Type: text
 _Description: Help on partitioning
 
+Template: partman-target/silo_bad_fs
+Type: note
+_Description: Warning: unsupported boot filesystem type!
+ In order to be successfully loaded by SILO (Sparc Linux Loader), the
+ kernel must reside on an ext2, ext3 or ufs formatted partition. In
+ the current partitioning scheme the kernel is going to be installed
+ on the ${SILO_PART} partition of type ${SILO_TYPE}. It is strongly
+ recommended that you go back to partitioning and correct this
+ problem. Keeping the current configuration may result in an
+ unbootable system.
+
+Template: partman-target/silo_too_far
+Type: note
+_Description: Warning: boot partition may cause problems with SILO!
+ This machine is likely to suffer from a firmware bug, which makes it
+ impossible for SILO (Sparc Linux Loader) to boot a kernel placed
+ farther than 1 GB from the beginning of the disk. To avoid problems
+ it is strongly recommended to install the kernel into a partition
+ which fits entirely within the first GB of the disk (by creating a
+ small /boot partition in the beginning of the disk, for example). In
+ the current partitioning scheme it is going to be installed onto the
+ ${SILO_PART} partition which extends up to ${SILO_OFF} mark. Keeping
+ this configuration may result in an unbootable system.
diff -aurN -x .svn partman-target_orig/finish.d/_numbers partman-target/finish.d/_numbers
--- partman-target_orig/finish.d/_numbers	2004-12-18 15:59:12.000000000 -0500
+++ partman-target/finish.d/_numbers	2004-12-18 16:03:38.000000000 -0500
@@ -1,4 +1,5 @@
 05 proper_mountpoints
+06 silo_check
 20 mount_partitions
 39 create_fstab_header
 40 fstab_hd_entries
diff -aurN -x .svn partman-target_orig/finish.d/silo_check partman-target/finish.d/silo_check
--- partman-target_orig/finish.d/silo_check	1969-12-31 19:00:00.000000000 -0500
+++ partman-target/finish.d/silo_check	2004-12-18 16:05:38.000000000 -0500
@@ -0,0 +1,80 @@
+#!/bin/sh
+#
+# SILO can only boot from ext[23] or ufs filesystem. Also, if the old
+# PROM version is used (major version <= 2), the complete partition where
+# kernel is installed must fit within 1GB from the beginning of the disk.
+#
+# -- Jurij Smakov <jurij@wooyd.org>  Sat, 18 Dec 2004 16:05:16 -0500
+
+. /lib/partman/definitions.sh
+
+check_sparc()
+{
+  arch=$(archdetect 2>/dev/null) || exit 0
+  cpu="${arch%%/*}"
+  [ "${cpu}" = "sparc" ] || exit 0
+}
+  
+prom_major_version()
+{
+  [ -f /proc/cpuinfo ] || exit 0
+  prom="$(grep '^prom' /proc/cpuinfo | grep -v '^promlib')"
+  prom_version="${prom##*: }"
+  prom_major="${prom_version%%.*}"
+  echo "prom_major=${prom_major}"
+}
+
+boot_part_params()
+{
+  result=''
+  startdir="$(pwd)"
+  for dev in $DEVICES/*; do
+    [ -d "$dev" ] || continue
+    cd $dev
+    partitions=''
+    open_dialog PARTITIONS
+    while { read_line num id size type fs path name; [ "$id" ]; }; do
+	[ -f "${id}/mountpoint" ] || continue
+	mp=$(cat ${id}/mountpoint)
+	[ "${mp}" = /boot ] && \
+          result="boot_name=${mp} boot_fs=${fs} boot_last=${id##*-}"
+	[ "${mp}" = / ] && [ -z "${result}" ] && \
+          result="boot_name=${mp} boot_fs=${fs} boot_last=${id##*-}"
+    done
+    close_dialog
+done
+cd "${startdir}"
+echo "${result}"
+}
+
+silo_limit_check()
+{
+  if ! longint_le "${boot_last}" 1073741824 ; then
+      db_subst partman-target/silo_too_far SILO_PART "${boot_name}"
+      db_subst partman-target/silo_too_far SILO_OFF "$(longint2human ${boot_last})"
+      db_input critical partman-target/silo_too_far || true
+      db_go || exit 1
+  fi
+}
+
+silo_boot_fs_check()
+{
+  case "${boot_fs}" in
+      ext2|ext3|ufs)
+	  ;;
+      *)
+	  db_subst partman-target/silo_bad_fs SILO_PART "${boot_name}"
+	  db_subst partman-target/silo_bad_fs SILO_TYPE "${boot_fs}"
+	  db_input critical partman-target/silo_bad_fs || true
+	  db_go || exit 1
+	  ;;
+  esac
+}
+
+check_sparc
+eval "$(boot_part_params)"
+silo_boot_fs_check
+eval "$(prom_major_version)"
+[ -n "${prom_major}" ] || exit 0
+[ "${prom_major}" -le 2 ] || exit 0
+silo_limit_check

Reply to: