[Pkg-sysvinit-devel] Bug#494001: Bug#494001: Bug#494001: Processed: Re: Bug#494001: debian-installer: /etc/mtab must be a symlink to /proc/mounts with linux >= 2.6.26

Kel Modderman kel at otaku42.de
Mon May 11 19:43:28 UTC 2009


> Does checkroot.sh need to change at all with respect to what it does to
> /etc/mtab?

For example, something like the following, which checks /etc/mtab is a symlink
on Linux and attempts to create one to /proc/mounts if the conditions are
correct. Just in case initscripts postinst maintainer scripts cannot create
the symlink, because possibly the package was upgraded/installed offline and
/proc was not mounted.

Also clear out devfs stuff, which is afaik no longer supported.

Kel.
---
--- a/debian/initscripts/etc/init.d/checkroot.sh                                                
+++ b/debian/initscripts/etc/init.d/checkroot.sh                                                
@@ -39,7 +39,6 @@ do_start () {                                                                 
        #       device node,                                                                    
        # 2) Swap that is on a md device or a file that may be on a md                          
        #       device,                                                                         
-       # 3) The mount parameters for a devfs filesystem.                                       
        #                                                                                       
                                                                                                
        exec 9<&0 </etc/fstab                                                                   
@@ -52,7 +51,6 @@ do_start () {                                                                 
        rootcheck=no                                                                            
        swap_on_lv=no                                                                           
        swap_on_file=no                                                                         
-       devfs=                                                                                  
                                                                                                
        while read DEV MTPT FSTYPE OPTS DUMP PASS JUNK                                          
        do                                                                                      
@@ -75,11 +73,6 @@ do_start () {                                                                
                        [ "$FSTYPE" = "swap" ] && swap_on_file=yes                              
                        ;;                                                                      
                  *)                                                                            
-                       # Devfs definition ?                                                    
-                       if [ "$FSTYPE" = "devfs" ] && [ "$MTPT" = "/dev" ] && mountpoint -q /dev
-                       then                                                                    
-                               devfs="-t $FSTYPE $DEV $MTPT"                                   
-                       fi                                                                      
                        ;;                                                                      
                esac                                                                            
                [ "$MTPT" != "/" ] && continue                                                  
@@ -339,42 +332,17 @@ but requested that the system be restart                                  
        fi                                                                                      
                                                                                                
        #                                                                                       
-       # We only create/modify /etc/mtab if the location where it is                           
-       # stored is writable. If /etc/mtab is a symlink into /proc/                             
-       # then it is not writable.                                                              
-       #                                                                                       
-       INIT_MTAB_FILE=no                                                                       
-       MTAB_PATH="$(readlink -f /etc/mtab || :)"                                               
-       case "$MTAB_PATH" in                                                                    
-         /proc/*)                                                                              
-               ;;                                                                              
-         /*)                                                                                   
-               if touch "$MTAB_PATH" >/dev/null 2>&1                                           
-               then                                                                            
-                       :> "$MTAB_PATH"                                                         
-                       rm -f ${MTAB_PATH}~
-                       INIT_MTAB_FILE=yes
-               fi
-               ;;
-         "")
-               [ -L /etc/mtab ] && MTAB_PATH="$(readlink /etc/mtab)"
-               if [ "$MTAB_PATH" ]
+       # If /etc/mtab is not a symlink, attempt to symlink it to /proc/mounts
+       # on Linux. See #494001
+       #
+       if [ Linux = "$KERNEL" ] && [ ! -L /etc/mtab ] && [ -f /proc/mounts ]
+       then
+               if touch /etc/mtab >/dev/null 2>&1
                then
-                       log_failure_msg "Cannot initialize ${MTAB_PATH}."
+                       rm -f /etc/mtab && ln -s /proc/mounts /etc/mtab
                else
-                       log_failure_msg "Cannot initialize /etc/mtab."
+                       log_warning_msg "cannot symlink /etc/mtab to /proc/mounts"
                fi
-               ;;
-         *)
-               log_failure_msg "Illegal mtab location '${MTAB_PATH}'."
-               ;;
-       esac
-
-       if [ "$INIT_MTAB_FILE" = yes ]
-       then
-               [ "$roottype" != none ] &&
-                       mount -f -o $rootopts -t $roottype $fstabroot /
-               [ "$devfs" ] && mount -f $devfs
        fi

        #
---
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-sysvinit-devel/attachments/20090512/38d238fd/attachment-0003.htm>


More information about the Pkg-sysvinit-devel mailing list