[Pkg-sysvinit-devel] Bug#481546: initscripts: umountfs fails to unmount /var with RAM*

Szymon Juraszczyk szymon at juraszczyk.com
Sun Jan 30 04:35:37 UTC 2011


Hi,

I think Peter is right in that the patch supplied by Jörg is not the
right thing to do. To fix the problem we've got to start right at the
beginning, that is before the code handling RAMLOCK and RAMRUN at system
start-up screws it up for good.

As Jörg aptly pointed, the current scripts mount /var/lock and /var/run
twice. Technically this will be the same tmpfs mounted in the same
directory twice, which looks unbelievable until you take a closer look.
First time the mount happens right at the beginning of the boot process
and then happens again after /var is mounted (if it is). I mean unless
one is lucky enough not to have a separate volume for /var. The first
mount ends up being covered up by /var and makes it tricky to unmount it
later - it would have to be done after unmounting /var and before
unmounting /.

So, here is how we can remediate this. The idea of pre_mountall and
post_mountall functions is pretty clever, but to get it right you need
to unmount /var/run and /var/lock after binding them to /lib/init/rw
(hence their contents will still survive). By the way why not mount
tmpfs in /var/run and /var/lock after all filesystems are mounted? If
RAMLOCK and RAMRUN are not set, whatever is written there before
mounting /var lands up covered by /var anyway. But leaving it as it is
for now, the patch for sysvinit_2.86.ds1-61 (from Lenny) could look like
this (mind you, it won't apply unless you replace some spaces with tabs
- sorry for inconvenience :-D ):

diff -Nrup
sysvinit-2.86.ds1/debian/initscripts/lib/init/mount-functions.sh
sysvinit-2.86.ds1/debian/initscripts/lib/in
--- sysvinit-2.86.ds1/debian/initscripts/lib/init/mount-functions.sh
2011-01-30 02:58:40.000000000 +0100
+++ sysvinit-2.86.ds1/debian/initscripts/lib/init/mount-functions.sh
2011-01-30 04:46:30.986612307 +0100
@@ -131,10 +131,12 @@ pre_mountall ()
        if [ yes = "$RAMRUN" ] ; then
                mkdir /lib/init/rw/var.run
                mount -n --bind /var/run /lib/init/rw/var.run
+               umount -n /var/run
        fi
        if [ yes = "$RAMLOCK" ] ; then
                mkdir /lib/init/rw/var.lock
                mount -n --bind /var/lock /lib/init/rw/var.lock
+               umount -n /var/lock
        fi
 }


And then we come to the conclusion that the whole fuss about RAMRUN and
RAMLOCK in umountfs is useless. To make it right we just need to rip the
code that makes no sense whatsoever:

diff -Nrup sysvinit-2.86.ds1/debian/initscripts/etc/init.d/umountfs
sysvinit-2.86.ds1/debian/initscripts/etc/init.d/umo
--- sysvinit-2.86.ds1/debian/initscripts/etc/init.d/umountfs
2011-01-30 02:58:40.000000000 +0100
+++ sysvinit-2.86.ds1/debian/initscripts/etc/init.d/umountfs
2011-01-30 04:49:12.490612127 +0100
@@ -69,16 +69,6 @@ do_stop () {

/|/proc|/dev|/.dev|/dev/pts|/dev/shm|/dev/.static/dev|/proc/*|/sys|/lib/init/rw)
                        continue
                        ;;
-                 /var/run)
-                       if [ yes = "$RAMRUN" ] ; then
-                               continue
-                       fi
-                       ;;
-                 /var/lock)
-                       if [ yes = "$RAMLOCK" ] ; then
-                               continue
-                       fi
-                       ;;
                esac
                case "$FSTYPE" in
                  proc|procfs|linprocfs|devfs|sysfs|usbfs|usbdevfs|devpts)



After these patches RAMLOCK and RAMRUN will work like a charm and the
filesystems (/var and / in particular) will start to get unmounted again.

-- 
Best regards,
Szymon Juraszczyk, szymon at juraszczyk.com



More information about the Pkg-sysvinit-devel mailing list