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 NETBOOT="${x#netboot=}"
141 RESUME="${x#resume=}"
144 resume_offset="${x#resume_offset=}"
169 exec >/dev/.initramfs/initramfs.debug 2>&1
184 blacklist=${x#blacklist=}
189 if [ -z "${noresume}" ]; then
190 export resume=${RESUME}
198 # export BOOT variable value for compcache,
199 # so we know if we run from casper
202 # Don't do log messages here to avoid confusing usplash
203 run_scripts /scripts/init-top
206 log_begin_msg "Loading essential drivers..."
211 [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-premount"
212 run_scripts /scripts/init-premount
213 [ "$quiet" != "y" ] && log_end_msg
216 log_begin_msg "Mounting root file system..."
218 parse_numeric ${ROOT}
223 [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-bottom"
224 run_scripts /scripts/init-bottom
225 [ "$quiet" != "y" ] && log_end_msg
227 # Move virtual filesystems over to the real filesystem
228 mount -n -o move /sys ${rootmnt}/sys
229 mount -n -o move /proc ${rootmnt}/proc
232 if [ -n "${init}" ] && [ ! -x "${rootmnt}${init}" ]; then
233 echo "Target filesystem doesn't have ${init}."
237 # Search for valid init
238 if [ -z "${init}" ] ; then
239 for init in /sbin/init /etc/init /bin/init /bin/sh; do
240 if [ ! -x "${rootmnt}${init}" ]; then
247 # No init on rootmount
248 if [ ! -x "${rootmnt}${init}" ]; then
249 panic "No init found. Try passing init= bootarg."
252 # Confuses /etc/init.d/rc
253 if [ -n ${debug} ]; then
257 # Chain to real filesystem
259 exec run-init ${rootmnt} ${init} "$@" <${rootmnt}/dev/console >${rootmnt}/dev/console 2>&1
260 panic "Could not execute run-init."