3 [ -d /dev ] || mkdir -m 0755 /dev
4 [ -d /root ] || mkdir -m 0700 /root
5 [ -d /sys ] || mkdir /sys
6 [ -d /proc ] || mkdir /proc
7 [ -d /tmp ] || mkdir /tmp
9 mount -t sysfs -o nodev,noexec,nosuid none /sys
10 mount -t proc -o nodev,noexec,nosuid none /proc
12 grep -q '\<quiet\>' /proc/cmdline || echo "Loading, please wait..."
14 # Note that this only becomes /dev on the real filesystem if udev's scripts
15 # are used; which they will be, but it's worth pointing out
16 mount -t tmpfs -o mode=0755 udev /dev
17 [ -e /dev/console ] || mknod -m 0600 /dev/console c 5 1
18 [ -e /dev/null ] || mknod /dev/null c 1 3
19 > /dev/.initramfs-tools
22 # Export the dpkg architecture
27 export MODPROBE_OPTIONS="-qb"
29 # Export relevant variables
36 export init=/sbin/init
45 # Bring in the main config
46 . /conf/initramfs.conf
47 for conf in conf/conf.d/*; do
48 [ -f ${conf} ] && . ${conf}
52 # Parse command line options
53 for x in $(cat /proc/cmdline); do
64 # support / in LABEL= paths (escape to \x2f)
67 if [ -x "$(command -v sed)" ]; then
68 ROOT="$(echo ${ROOT} | sed 's,/,\\x2f,g')"
70 if [ "${ROOT}" != "${ROOT#/}" ]; then
73 if [ "${ROOT}" != "${ROOT%/}" ]; then
79 if [ -z "${newroot}" ]; then
82 newroot="${newroot}\\x2f${s}"
89 ROOT="/dev/disk/by-label/${ROOT}"
92 ROOT="/dev/disk/by-uuid/${ROOT#UUID=}"
95 [ -z "${BOOT}" ] && BOOT=nfs
100 ROOTFLAGS="-o ${x#rootflags=}"
103 ROOTFSTYPE="${x#rootfstype=}"
106 ROOTDELAY="${x#rootdelay=}"
114 RESUMEDELAY="${x#resumedelay=}"
120 LOOPFLAGS="-o ${x#loopflags=}"
123 LOOPFSTYPE="${x#loopfstype=}"
126 cryptopts="${x#cryptopts=}"
129 NFSROOT="${x#nfsroot=}"
132 HTTPFS="${x#httpfs=}"
135 ISCSIFS="${x#iscsifs=}"
138 TARGET="${x#target=}"
141 NETBOOT="${x#netboot=}"
150 RESUME="${x#resume=}"
153 resume_offset="${x#resume_offset=}"
178 exec >/dev/.initramfs/initramfs.debug 2>&1
193 blacklist=${x#blacklist=}
198 if [ -z "${noresume}" ]; then
199 export resume=${RESUME}
207 # export BOOT variable value for compcache,
208 # so we know if we run from casper
211 # Don't do log messages here to avoid confusing usplash
212 run_scripts /scripts/init-top
215 log_begin_msg "Loading essential drivers..."
220 [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-premount"
221 run_scripts /scripts/init-premount
222 [ "$quiet" != "y" ] && log_end_msg
225 log_begin_msg "Mounting root file system..."
227 parse_numeric ${ROOT}
232 [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-bottom"
233 run_scripts /scripts/init-bottom
234 [ "$quiet" != "y" ] && log_end_msg
236 # Move virtual filesystems over to the real filesystem
237 mount -n -o move /sys ${rootmnt}/sys
238 mount -n -o move /proc ${rootmnt}/proc
241 if [ -n "${init}" ] && [ ! -x "${rootmnt}${init}" ]; then
242 echo "Target filesystem doesn't have ${init}."
246 # Search for valid init
247 if [ -z "${init}" ] ; then
248 for init in /sbin/init /etc/init /bin/init /bin/sh; do
249 if [ ! -x "${rootmnt}${init}" ]; then
256 # No init on rootmount
257 if [ ! -x "${rootmnt}${init}" ]; then
258 panic "No init found. Try passing init= bootarg."
261 # Confuses /etc/init.d/rc
262 if [ -n ${debug} ]; then
266 # because of some reasons, I dont understand, resolv.conf is not being set
267 # that is why I am copying this manually into actual filesystem. -- pravin
268 cp /etc/resolv.conf /root/etc/resolv.conf
271 # Chain to real filesystem
273 exec run-init ${rootmnt} ${init} "$@" <${rootmnt}/dev/console >${rootmnt}/dev/console 2>&1
274 panic "Could not execute run-init."