summaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
Diffstat (limited to 'init')
-rwxr-xr-xinit47
1 files changed, 47 insertions, 0 deletions
diff --git a/init b/init
new file mode 100755
index 0000000..1bbb6df
--- /dev/null
+++ b/init
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+# make dirs
+/bin/busybox mkdir -p /dev /proc /sys /newroot
+
+# mount needed filesystems
+mount -t proc none /proc
+mount -t sysfs none /sys
+
+busybox --install -s
+mdev -s
+
+# lvm stuff
+vgscan
+vgchange -a y lvm
+
+# process command line options
+init="/sbin/init"
+root="/dev/lvm/root"
+
+CMDLINE=$(cat /proc/cmdline)
+
+for i in ${CMDLINE}; do
+ case $i in
+ root\=*)
+ root=$(echo "$i" | cut -d "=" -f 2)
+ ;;
+ init\=*)
+ init=$(echo "$i" | cut -d "=" -f 2)
+ ;;
+ esac
+done
+
+# switch to new root or fallback to sh
+mount -r ${root} /newroot
+if [ -x "/newroot/${init}" ]; then
+ umount /sys
+ umount /proc
+ exec /bin/busybox switch_root /newroot ${init} ${CMDLINE}
+else
+ echo "Something went wrong..."
+ echo "After fixing it you may want to execute:"
+ echo "exec /bin/busybox switch_root /newroot ${init} ${CMDLINE}"
+
+ loadkmap < /etc/kmap-de
+ exec /bin/sh
+fi