blob: e250e3928a7d8c6d53b80330b27700e04493532b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#!/bin/sh
MODULE_DIR=/initrd.d
BOOT_ROOT=
ROOT_DEVICE=
early_setup() {
mkdir /proc
mount -t proc proc /proc
mkdir /mnt
modprobe -q mtdblock
}
dev_setup()
{
echo -n "initramfs: Creating device nodes: "
grep '^ *[0-9]' /proc/partitions | while read major minor blocks dev
do
if [ ! -e /dev/$dev ]; then
echo -n "$dev "
[ -e /dev/$dev ] || mknod /dev/$dev b $major $minor
fi
done
echo
}
read_args() {
[ -z "$CMDLINE" ] && CMDLINE=`cat /proc/cmdline`
for arg in $CMDLINE; do
optarg=`expr "x$arg" : 'x[^=]*=\(.*\)'`
case $arg in
root=*)
ROOT_DEVICE=$optarg ;;
rootfstype=*)
ROOT_FSTYPE=$optarg ;;
rootdelay=*)
rootdelay=$optarg ;;
esac
done
}
load_modules() {
for module in $MODULE_DIR/$1; do
echo "initramfs: Loading $module module"
source $module
done
}
boot_root() {
cd $BOOT_ROOT
exec switch_root -c /dev/console $BOOT_ROOT /sbin/init
}
fatal() {
echo $1
echo
exec sh
}
echo "Starting initramfs boot..."
early_setup
load_modules '0*'
read_args
if [ -n "$rootdelay" ]; then
echo "Waiting $rootdelay seconds for devices to settle..."
sleep $rootdelay
fi
dev_setup
load_modules '[1-9]*'
[ -n "$BOOT_ROOT" ] && boot_root
fatal "No valid root device was specified. Please add root=/dev/something to the kernel command-line and try again."
|