[Pkg-sysvinit-devel] Bug#386347: initscripts: BOOT FAILURE: checkroot.sh can't fsck /dev/shm/root because /dev/shm is mounted nodev

Petter Reinholdtsen pere at hungry.com
Thu Sep 7 14:30:17 UTC 2006


[Petter Reinholdtsen]
> An option might be to mount a private tmpfs (aka mounting it, chdir
> into it and umounting it, thus making it available only to the process
> running within it), but this will not make the life of mtab.sh easier.

Here is a draft patch for the private tmpfs approach.  It is untested,
as I am unsure how to provoke the test environment to actually try to
do fsck like that.  Can you test it?

It mounts on /tmp/ (randomly picked, it is not supposed to be writable
nor mounted at this point in the boot, so I believe it should be safe
to mount on top of it.  Next, it move into /tmp/, and finally umounts
/tmp/, removing all traces of the file system for all processes except
the running checkroot script.  After that, it behaves as before, with
the slight exception that it chdir out of the private temp directory
when it is no longer used by checkroot.  The path give to fsck need to
ve relative, as it only work as long as the current working directory
is the private tmpfs partition.

Index: debian/initscripts/etc/init.d/checkroot.sh
===================================================================
--- debian/initscripts/etc/init.d/checkroot.sh	(revisjon 855)
+++ debian/initscripts/etc/init.d/checkroot.sh	(arbeidskopi)
@@ -144,12 +144,15 @@
 			then
 				rootdev=/dev/root
 			else
+			# Using lazy umount, only available from kernel 2.4.11
 				if \
-					rm -f /dev/shm/root \
-					&& mknod -m 600 /dev/shm/root b ${rdev%:*} ${rdev#*:} \
-					&& [ -e /dev/shm/root ]
+					mount -n -t tmpfs tmpfs /tmp \
+					&& cd /tmp \
+					&& umount -l /tmp \
+					&& mknod -m 600 rootdev b ${rdev%:*} ${rdev#*:} \
+					&& [ -e rootdev ]
 				then
-					rootdev=/dev/shm/root
+					rootdev=rootdev
 				else
 					rootfatal=yes
 				fi
@@ -162,6 +165,7 @@
 	#
 	if [ "$rootfatal" = yes ]
 	then
+		cd / # Get out of the private tmpfs system if we moved in there
 		log_failure_msg "The device node $rootdev for the root filesystem is missing or incorrect 
 or there is no entry for the root filesystem listed in /etc/fstab. 
 The system is also unable to create a temporary node in /dev/shm. 
@@ -275,6 +279,7 @@
 			log_end_msg $FSCKCODE
 		fi
 	fi
+	cd / # Get out of the private tmpfs system if we moved in there
 
 	#
 	# If there was a failure, drop into single-user mode.





More information about the Pkg-sysvinit-devel mailing list