summaryrefslogtreecommitdiffstats
path: root/init
blob: 723e4ba88bdfcf738480c608a270ecd6c0b890f9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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

# 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