From 3b8ad1593a12bef4e3e2d9ab240b0fba16093199 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Sat, 1 Jan 2011 23:00:49 +0100 Subject: initial version --- init | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 init (limited to 'init') 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 -- cgit v1.2.3