Comment 23 for bug 431040

Revision history for this message
Luke (lukekuhn) wrote : In case the attached script didn't get through, here it is again

  Here it is as cut and pasted text:

#!/bin/bash
# As re-edited by Luke
#
#WARNING: little error handling, some fs not supported!
#
#For Linux mounting / read-only, /proc, and /sys from the initramfs ONLY!
#
# Faster-running replacement for the binary mountall(which is still new code, slow running right now).

usplash_write "TEXT Mounting virtual filesystems..."

#mount_remotes() { :; }

#trap 'mount_remotes' USR1
# Second, mount the rest of our virtual filesystems.
# Since these probably won't be in /etc/fstab, mount them by hand.
#REMOVED LINE: /sys/fs/fuse/connections fusectl defaults
#REMOVED LINE /spu spufs gid=spu
#REMOVED LINE /sys sysfs nodev,noexec,nosuid

echo "/proc/sys/fs/binfmt_misc binfmt_misc defaults
/sys/kernel/debug debugfs defaults
/sys/kernel/security securityfs defaults
/dev tmpfs mode=0755
/dev/shm tmpfs nosuid,nodev
/dev/pts devpts noexec,nosuid,gid=tty,mode=0620
/var/run tmpfs mode=0755,nosuid
/var/lock tmpfs nodev,noexec,nosuid
/lib/init/rw tmpfs mode=0755,nosuid" |while read mntpt fs opts rest; do
    # if this virtual filesystem type is not supported, skip it.
    grep -q "$fs" /proc/filesystems || continue
    # if the filesystem is already mounted, don't mount it again
        grep -q " $mntpt " /proc/mounts && continue
    # if the directory does not exist, try to make it.
    [[ -d $mntpt ]] || mkdir -p "$mntpt" || exit 3
    mount -t $fs -o $opts none $mntpt || exit 3
done
# exit if something failed mounting virtual filesystems
ret=$?; (($ret > 1)) && exit $ret
# let the world know our virtual filesystems are mounted.
initctl emit virtual-filesystems
usplash_write "SUCCESS OK"

# by now udev should have kicked off. Wait for it to detect all our devices.
udevadm settle

#Check filesystems

usplash_write "TEXT Checking Filesystems..."

#find rootdev

IDTYPE=$(cat /proc/cmdline | tail -c +6 | head -c 4)
if test $IDTYPE = UUID; then
        CMDLINE=$(tail -c +6 /proc/cmdline | head -c +41)
else
        CMDLINE=$(tail -c +6 /proc/cmdline |head -c 9)
fi

#find mount count

COUNT=$(tune2fs -l $CMDLINE | grep "Mount count" | tail -c +27)

#find maximum number of mounts of root filesystem-WARNING:will not indicate on forced check of any other fs!

MAXCOUNT=$(tune2fs -l $CMDLINE | grep "Maximum mount count" | tail -c +28)

if test $COUNT -ge $MAXCOUNT; then

   usplash_write "TEXT fsck: maximum mount count reached, check forced..."

   usplash_write "SUCCESS WAIT"

fi

   fsck -aA > /lib/init/rw/checkall
   ret=$?
usplash_write "SUCCESS DONE"

if test $ret -ge 2 ; then
               echo "a filesystem failed fsck"
               usplash_write "FAILURE FAIL"
               usplash_write "TEXT ctl-alt-F8 for console to repair and continue"
               sleep 2
               usplash_write "QUIT"
               exec </dev/console >/dev/console 2>/dev/console
               cat /lib/init/rw/checkall
               echo "A maintenance shell will now be started."
               echo "fsck failed filesystem by hand"
               echo "CONTROL-D will terminate this shell and proceed to mounting filesystems"
   /sbin/sulogin

fi

#mount the root filesystem for real

usplash_write "TEXT remounting root filesystem writable"
mount -o remount rw /
usplash_write "SUCCESS OK"

cp /lib/init/rw/checkall /var/log/fsck/checkall

# activate our swap devices
usplash_write "TEXT Activating Swap Device..."
swapon -a
usplash_write "SUCCESS OK"
initctl emit all-swaps

# mount local filesystems
usplash_write "TEXT Mounting Local Filesystems..."
#needed for detection bug
mount -t ext* -a
mount -a
usplash_write "SUCCESS OK"
initctl emit local-filesystems

# we don't even bother trying to mount _netdev or network filesystems.
# Feel free to add support if you want them.
# Instead, we lie and say we have.
initctl emit remote-filesystems
initctl emit all-filesystems
initctl emit filesystem

_________________________________________________________________
Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
http://clk.atdmt.com/GBL/go/171222985/direct/01/