Bug#411940: /etc/init.d/mdadm-raid needs /proc mounted and it might not be

Brad Spencer spencer at jacknife.org
Thu Feb 22 01:09:38 CET 2007


Package: mdadm
Version: 1.9.0-4sarge1
Severity: important
Tags: patch

On a sarge system with RAID1 root, /boot, and swap partitions, I kept
seeing only the root partition assembled and mounted after reboots.  
Since this was after the machine had a misconfigured apt which resulted
in some non-sarge (unstable) packages getting upgraded, I figured the 
init scripts had been messed up, but after a good amount of investigation,
I can't find any evidence of this being the case.

I did see that mdadm-raid presumes that it can test for the existence of
/proc/mdstat after ensuring that the md module is loaded, but there doesn't
seem to be anything in the current sarge initscripts that ensures /proc is
loaded before mdadm (S25mdadm-raid vs S35mountall.sh).

I noticed that other scripts that needed /proc explicitly ensured it was
mounted while they needed it (and then unmounted again, if necessary), so
I copied this logic into mdadm-raid and this resolved the issue.  Even if
"normally", something is supposed to mount /proc earlier, I don't see any
harm in adding this kind of support for ensuring that it is available, so
I figured I'd file this bug.

Tiny patch to /etc/init.d/mdadm-raid:

--- mdadm-raid	2006-07-01 09:39:06.000000000 -0300
+++ /etc/init.d/mdadm-raid	2007-02-21 18:54:25.000000000 -0400
@@ -19,6 +19,14 @@
 case "$1" in
     start)
 	if [ "x$AUTOSTART" = "xtrue" ] ; then
+
+            # First mount /proc if necessary.
+            unmount_proc="no"
+            if [ ! -x /proc/1 ]; then
+              unmount_proc="yes"
+              mount -n /proc
+            fi
+                                                    
             if [ ! -f /proc/mdstat ] && [ -x /sbin/modprobe ] ; then
                 /sbin/modprobe -k md > /dev/null 2>&1  
             fi
@@ -30,6 +38,10 @@
 	        $MDRUN
 	    fi
 	    echo "done."
+
+  	    # unmount /proc if we mounted it
+            [ "$unmount_proc" = "no" ] || umount -n /proc
+            
 	fi
         ;;
     stop|restart|reload|force-reload)


-- System Information:
Debian Release: 3.1
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.8-12-amd64-k8
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages mdadm depends on:
ii  debconf               1.4.30.13          Debian configuration management sy
ii  libc6                 2.3.2.ds1-22sarge4 GNU C Library: Shared libraries an
ii  makedev               2.3.1-77           creates device files in /dev

-- debconf information:
* mdadm/autostart: true
* mdadm/initrdstart: /dev/md2
  mdadm/initrdstart_notinconf: false
  mdadm/initrdstart_msg_errexist:
  mdadm/initrdstart_msg_intro:
  mdadm/initrdstart_msg_errblock:
* mdadm/warning:
* mdadm/start_daemon: true
* mdadm/mail_to: root
  mdadm/initrdstart_msg_errmd:
  mdadm/initrdstart_msg_errconf:
* mdadm/autocheck: true




More information about the pkg-mdadm-devel mailing list