4 # This is the initramfs init script
5 ROOTFS_LABEL="cirros-rootfs"
9 mkdir -p /proc /newroot /dev /tmp
11 mount -t devtmpfs /dev /dev
12 mount -t proc /proc /proc
14 echo "6 4 1 7" >/proc/sys/kernel/printk
18 for x in $KC_CONSOLES; do
19 [ "$x" = "$KC_CONSOLE" ] ||
20 echo "further output written to $KC_CONSOLE" > "$x";
22 if [ -n "$KC_PREF_CONSOLE" ]; then
23 exec >"$KC_PREF_CONSOLE" 2>&1 <"$KC_PREF_CONSOLE"
26 read uptime cputime < /proc/uptime
27 iinfo "initramfs: up at $uptime"
29 idebug "loading modules"
30 /etc/init.d/load-modules start
35 if [ "$KC_RAMDISK_ROOT" != "1" ]; then
36 while read maj min blk name other; do
37 [ -n "${maj}" -a "${maj}" != "major" ] || continue
39 mount -o ro "/dev/${name}" "/newroot" >/dev/null 2>&1 &&
40 MOUNTED="$MOUNTED ${name}" && umount=1 &&
41 [ -x /newroot/sbin/init ] && ROOT="/dev/$name" && break
42 [ ${umount} -eq 0 ] || umount /newroot
43 done < /proc/partitions
46 if [ "$KC_DEBUG" = "1" ]; then
47 echo "dropping into initramfs debug shell"
51 if [ -z "$ROOT" -a "$KC_RAMDISK_ROOT" != "1" ] &&
52 blank=$(blkid -l -o device -t LABEL=$ROOTFS_LABEL) &&
54 iinfo "copying initramfs to $blank"
59 /dev|/proc|/newroot) : ;;
60 *) items="$items $x";;
64 mount "$blank" /newroot
65 mkdir -p /newroot/dev /newroot/proc
66 cp -a $items /newroot/
67 cp -a /dev/console /newroot/dev
68 mount -o remount,ro /newroot
72 if [ -n "$ROOT" ]; then
74 mount -o move /dev ./dev
76 iinfo "initramfs loading root from $ROOT"
77 exec switch_root /newroot "$KC_INIT" "$@"
79 while read maj min blk name other; do
80 [ -n "${maj}" -a "${maj}" != "major" ] || continue
82 mount -o ro "/dev/${name}" "/newroot" >/dev/null 2>&1 &&
84 [ -x /newroot/sbin/init ] && ROOT="/dev/$name" && break
85 [ ${umount} -eq 0 ] || umount /newroot
86 done < /proc/partitions
88 [ "$KC_RAMDISK_ROOT" = "0" ] &&
89 iinfo "initramfs did not find root, running as ramdisk" ||
90 iinfo "running in ramdisk mode as requested"
93 failure "badness occurred in ramdisk"