[Pkg-sysvinit-devel] Bug#529498: flexible fsck the conservative approach

Ralph Ulrich eulenreich at gmx.de
Wed May 20 17:48:24 UTC 2009


Here is a patch to flexible fsck in a conservative manner in the sense 
of doing fsck at boot time as ever.

- You will see free mounts until automatic fsck.
- You can force fsck at boot time in which case Mountcount is reseted.

Edit the root entries of resulting /boot/grub/menu.lst to your needs:

--- a/boot/grub/menu.lst	2009-05-20 18:33:48.000000000 +0200
+++ a/boot/grub/menu.lst	2009-05-20 19:01:53.000000000 +0200
@@ -135,3 +135,8 @@

  ### END DEBIAN AUTOMAGIC KERNELS LIST

+
+title		forcefsck and forceshutdown Debian - mounts until fsck 26
+root		(hd0,5)
+kernel		/boot/vmlinuz root=LABEL=debian ro nosplash forcefsck 
forceshutdown 2
+initrd		/boot/initrd.img
--- a/etc/rc.local	2009-01-14 18:48:25.000000000 +0100
+++ a/etc/rc.local	2009-05-20 18:25:37.000000000 +0200
@@ -1,14 +1,25 @@
  #!/bin/sh -e
  #
  # rc.local
  #
  # This script is executed at the end of each multiuser runlevel.
  # Make sure that the script will "exit 0" on success or any other
  # value on error.
  #
  # In order to enable or disable this script just change the execution
  # bits.
  #
  # By default this script does nothing.
+RDEV=$(mount | grep ' / ' |  sed -e 's/ on.*//')
+MAXM=$( /sbin/tune2fs -l $RDEV | grep 'Maximum mount count'|sed -e 
's/Maximum mount count:[ ]*//' )
+ACTU=$( /sbin/tune2fs -l $RDEV | grep 'Mount count'|sed -e 's/Mount 
count:[ ]*//' )
+DIFF=$(( $MAXM - $ACTU ))
+MENU=/boot/grub/menu.lst
+sed -i -e "sXmounts until fsck.*Xmounts until fsck ${DIFF}X" $MENU
+if grep -wiq "forceshutdown" /proc/cmdline ; then
+    if grep -wiq "forcefsck" /proc/cmdline ; then
+       shutdown -h now
+    fi
+fi

  exit 0
--- a/etc/init.d/checkfs.sh	2008-08-12 14:50:47.000000000 +0200
+++ a/etc/init.d/checkfs.sh	2009-05-19 20:11:59.000000000 +0200
@@ -41,6 +41,9 @@
  		if [ -f /forcefsck ]
  		then
  			force="-f"
+		elif grep -wiq "forcefsck" /proc/cmdline
+		then
+			force="-f"
  		else
  			force=""
  		fi
--- a/etc/init.d/checkroot.sh	2008-07-27 16:03:16.000000000 +0200
+++ a/etc/init.d/checkroot.sh	2009-05-19 20:09:54.000000000 +0200
@@ -245,6 +245,9 @@
  		if [ -f /forcefsck ]
  		then
  			force="-f"
+		elif grep -wiq "forcefsck" /proc/cmdline
+		then
+			force="-f"
  		else
  			force=""
  		fi
---







More information about the Pkg-sysvinit-devel mailing list