You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
127 lines
3.4 KiB
127 lines
3.4 KiB
18 years ago
|
#!/bin/sh
|
||
|
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
||
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
||
17 years ago
|
#
|
||
18 years ago
|
# Filename: package/.../mkinitrd/initrdinit.sh
|
||
|
# Copyright (C) 2006 The OpenSDE Project
|
||
|
# Copyright (C) 2005 - 2006 The T2 SDE Project
|
||
17 years ago
|
#
|
||
18 years ago
|
# More information can be found in the files COPYING and README.
|
||
17 years ago
|
#
|
||
18 years ago
|
# This program is free software; you can redistribute it and/or modify
|
||
|
# it under the terms of the GNU General Public License as published by
|
||
|
# the Free Software Foundation; version 2 of the License. A copy of the
|
||
|
# GNU General Public License can be found in the file COPYING.
|
||
|
# --- SDE-COPYRIGHT-NOTE-END ---
|
||
|
|
||
|
echo "Entering early userspace ..."
|
||
|
|
||
|
PATH=/sbin:/bin
|
||
|
|
||
|
echo "Mounting /dev, /proc and /sys ..."
|
||
|
mount -t tmpfs none /dev
|
||
|
mount -t proc none /proc
|
||
|
mount -t usbfs none /proc/bus/usb
|
||
|
mount -t sysfs none /sys
|
||
|
ln -s /proc/self/fd /dev/fd
|
||
|
|
||
17 years ago
|
if [ ! -c /dev/console ]; then
|
||
|
mknod /dev/console c 5 1
|
||
|
fi
|
||
|
if [ ! -c /dev/null ]; then
|
||
|
mknod /dev/null c 1 3
|
||
|
fi
|
||
|
if [ ! -c /dev/zero ]; then
|
||
|
mknod /dev/zero c 1 5
|
||
|
fi
|
||
|
|
||
18 years ago
|
echo "Populating /dev (u/dev) ..."
|
||
17 years ago
|
echo "" > /sys/kernel/uevent_helper
|
||
18 years ago
|
udevd --daemon
|
||
|
|
||
17 years ago
|
echo "Triggering coldplug ..."
|
||
|
udevtrigger
|
||
|
udevsettle
|
||
18 years ago
|
|
||
|
echo "Loading additional subsystem and filesystem driver ..."
|
||
|
# hack to be removed
|
||
17 years ago
|
#modprobe sbp2
|
||
18 years ago
|
|
||
|
# well some hardcoded help for now ...
|
||
17 years ago
|
#modprobe ide-generic
|
||
|
#modprobe ide-disk
|
||
|
#modprobe ide-cd
|
||
|
#modprobe sd_mod
|
||
|
#modprobe sr_mod
|
||
|
#modprobe sg
|
||
18 years ago
|
|
||
|
# the modular filesystems ...
|
||
|
for x in /lib/modules/*/kernel/fs/{*/,}*.*o ; do
|
||
|
x=${x##*/} ; x=${x%.*o}
|
||
|
modprobe $x
|
||
|
done
|
||
|
|
||
|
echo "Mounting rootfs ..."
|
||
|
|
||
|
# get the root device and init
|
||
|
root="root= `cat /proc/cmdline`" ; root=${root##*root=} ; root=${root%% *}
|
||
|
init="init= `cat /proc/cmdline`" ; init=${init##*init=} ; init=${init%% *}
|
||
|
|
||
|
# try best match / detected rootfs first, all the others thereafter
|
||
|
filesystems=`disktype $root 2>/dev/null |
|
||
|
sed -e '/file system/!d' -e 's/file system.*//' -e 's/ //g' \
|
||
|
-e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' \
|
||
|
-e 's/fat32/vfat/'
|
||
|
sed '1!G ; $p ; h ; d' /proc/filesystems | sed /^nodev/d`
|
||
|
|
||
|
mkdir /rootfs
|
||
|
|
||
|
if [ "$root" ]; then
|
||
|
i=0
|
||
|
while [ $i -le 9 ]; do
|
||
|
for fs in $filesystems ; do
|
||
|
if mount -t $fs $root /rootfs -o ro 2> /dev/null; then
|
||
|
echo "Successfully mounted rootfs as $fs."
|
||
|
|
||
|
# TODO: later on search other places if we want 100% backward compat.
|
||
|
[ "$init" ] || init=/sbin/init
|
||
|
if [ -f /rootfs/$init ]; then
|
||
|
mount -t none /dev -o move /rootfs/dev
|
||
|
mount -t none /proc -o move /rootfs/proc
|
||
|
mount -t none /sys -o move /rootfs/sys
|
||
|
|
||
17 years ago
|
if [ ! -c /rootfs/dev/console ]; then
|
||
18 years ago
|
mknod /rootfs/dev/console c 5 1
|
||
17 years ago
|
fi
|
||
|
if [ ! -c /rootfs/dev/null ]; then
|
||
18 years ago
|
mknod /rootfs/dev/null c 1 3
|
||
17 years ago
|
fi
|
||
|
if [ ! -c /rootfs/dev/zero ]; then
|
||
18 years ago
|
mknod /rootfs/dev/zero c 1 5
|
||
17 years ago
|
fi
|
||
|
if [ ! -c /rootfs/dev/tty ]; then
|
||
18 years ago
|
mknod /rootfs/dev/tty c 5 0
|
||
|
fi
|
||
|
|
||
|
# Before we switch to the real root
|
||
|
# we have to kill udevd
|
||
|
ls -1l /rootfs/proc/*/exe 2> /dev/null | \
|
||
|
sed -n -e "s,.*/proc/\([0-9]*\)/.*udevd.*,kill \1,p" | \
|
||
|
/bin/sh
|
||
|
|
||
|
# enter the systems root
|
||
|
exec switch_root /rootfs $init $*
|
||
|
else
|
||
|
echo "Specified init ($init) does not exist!"
|
||
|
fi
|
||
|
fi
|
||
|
done
|
||
|
[ $(( i++ )) -eq 0 ] && echo "Waiting for root device to become ready ..."
|
||
|
sleep 1
|
||
|
done
|
||
|
fi
|
||
|
|
||
|
echo "Ouhm - some boot problem, but I do not scream. Debug shell:"
|
||
|
exec /bin/sh
|
||
|
|