2 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
5 # Filename: target/early/initramfs/init.sh
6 # Copyright (C) 2007 - 2008 The OpenSDE Project
8 # More information can be found in the files COPYING and README.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- SDE-COPYRIGHT-NOTE-END ---
16 export PATH
=/usr
/bin
:/usr
/sbin
:/bin
:/sbin
30 # read kernel arguments
31 [ -e /proc
/cmdline
] || mount
-n -t proc none
/proc
32 set -- $
( cat /proc
/cmdline
)
39 modules
=*) modules
=$
( echo "$v" |
tr ',' ' ' ) ;;
40 nocolor
) export NOCOLOR
=yes ;;
41 initrdopt
=*) for y
in $
( echo "$v" |
tr ',' ' ' ); do
43 mdadm
) want_mdadm
=yes ;;
44 mdadm
=*) want_mdadm
="${y#mdadm=}" ;;
46 lvm
=*) want_lvm
="${y#lvm=}" ;;
47 shell
) want_shell
=yes ;;
48 shell
=*) want_shell
="${y#shell=}" ;;
55 .
/etc
/rc.d
/functions.
in
57 banner "Starting Early User Space environment"
59 title
"Mounting /proc and /sys"
60 check mount
-n -t usbfs none
/proc
/bus
/usb
61 check mount
-n -t sysfs none
/sys
64 [ -x /bin
/dmesg
] && /bin
/dmesg
-n 3
66 title
"Preparing /dev"
67 check mount
-n -t tmpfs none
/dev
68 check
cp -a /lib
/udev
/devices
/* /dev
71 title
"Starting udev daemon"
72 echo "" > /sys
/kernel
/uevent_helper
76 if [ -x /sbin
/modprobe
-a -n "$modules" ]; then
77 title
"Preloading requested kernel modules"
85 title
"Triggering coldplug"
92 [ -n "$root" ] ||
echo "No root device defined."
94 if [ ! -e "$root" ]; then
95 if [ "$want_mdadm" = yes ]; then
96 title
"Detecting possible RAID devices"
97 check mdadm
-E --scan > /etc
/mdadm.conf
101 if [ "$want_mdadm" != no
-a -s /etc
/mdadm.conf
]; then
102 # try activating software raids
103 title
"Activating RAID devices"
106 check mdadm
-As --auto=yes
111 if [ ! -e "$root" ]; then
112 if [ "$want_lvm" = yes ]; then
113 title
"Detecting possible LVM devices"
118 if [ "$want_lvm" != no
-a -d /etc
/lvm
/archive
]; then
119 title
"Activating LVM devices"
122 check lvm vgchange
-ay
127 if [ -n "$root" ]; then
130 # give it a second chance to appear (delay 2s)
131 [ -e "$root" ] ||
sleep 2;
133 if [ -e "$root" ]; then
134 /lib
/udev
/vol_id
"$root" > /tmp
/$$.vol_id
138 title
"Mounting $root (${ID_FS_TYPE:-unknown}) "
139 check mount
${ID_FS_TYPE:+-t $ID_FS_TYPE} ${mode:+-o $mode} "$root" /rootfs
142 echo "root device ($root) not found on time."
146 # wait for /sbin/init
147 while [ ! -x "/rootfs$init" ]; do
148 # one shell is enough
150 echo -e "\nPlease mount root device on /rootfs and exit to continue."
154 if [ "$want_shell" = yes ]; then
155 echo -e "\nA last-minute shell was requested, please exit to continue."
161 check mount
-t none
-o move
/dev
/rootfs
/dev
162 check mount
-t none
-o move
/sys
/rootfs
/sys
163 check mount
-t none
-o move
/proc
/rootfs
/proc
166 exec switch_root
/rootfs
"$init" $initargs
167 #FIXME: what if it fails?