3 PATH
=/sbin
:/bin
:/usr
/bin
:/usr
/sbin
5 echo "T2 SDE early userspace (c)2005-2021 Rene Rebe, ExactCODE GmbH; Germany."
8 mount
-t none
-o move
{,/mnt
}/dev
9 mount
-t none
-o move
{,/mnt
}/proc
10 mount
-t none
-o move
{,/mnt
}/sys
11 exec switch_root
/mnt
$init $
*
14 echo "Mounting /dev, /proc and /sys"
15 mount
-t devtmpfs
-o mode
=755 none
/dev
16 mount
-t proc none
/proc
17 mount
-t sysfs none
/sys
19 ln -s /proc
/self
/fd
/dev
/fd
21 echo "$(< /proc/sys/kernel/ostype) $(< /proc/sys/kernel/osrelease)," \
27 # get the root device, init, early swap
28 cmdline
="$(< /proc/cmdline)"
29 root
="root= $cmdline" ; root
=${root##*root=} ; root
=${root%% *}
30 init
="init= $cmdline" ; init
=${init##*init=} ; init
=${init%% *}
31 swap
="swap= $cmdline" ; swap
=${swap##*swap=} ; swap
=${swap%% *}
33 [ "${root#UUID=}" != "$root" ] && root
="/dev/disk/by-uuid/${root#UUID=}"
34 [ "${swap#UUID=}" != "$swap" ] && swap
="/dev/disk/by-uuid/${swap#UUID=}"
36 # maybe resume from disk?
37 resume
="$(< /proc/cmdline)"
38 if [[ "$resume" = *resume
* ]] && [[ "$resume" != *noresume
* ]]; then
39 resume
=${resume##*resume=} ; resume
=${resume%% *}
40 resume
=`ls -l $resume |
41 sed 's/[^ ]* *[^ t]* *[^ ]* *[^ ]* *\([0-9]*\), *\([0-9]*\) .*/\1:\2/'`
42 echo "Attempting to resume from disk $resume."
43 echo "$resume" > /sys
/power
/resume
47 echo "Activating swap"
54 # diskless network root?
56 if [ "$addr" != "$root" ]; then
57 mountopt
="$mountopt,nolock,port=2049,mountport=32790,vers=4,addr=$addr"
62 if [ ! -e "$root" ]; then
63 echo "Activating RAID & LVM"
64 [ -e /sbin
/mdadm
] && mdadm
--assemble --scan
65 [ -e /sbin
/lvchange
] && lvchange
-a ay
${root#/dev/}
67 if [ ! -e "$root" ]; then
72 echo "Mounting root $mountopt"
75 while [ $i -le 9 ]; do
76 if [ -e $root -o "$addr" ]; then
77 if [ -z "$addr" ]; then
78 type -p cryptsetup
&& cryptsetup isLuks
$root --disable-locks &&
79 cryptsetup luksOpen
$root root
--disable-locks && root
=/dev
/mapper
/root
81 # try best match / detected root first, all the others thereafter
82 filesystems
=`disktype $root 2>/dev/null |
83 sed -e '/file system/!d' -e 's/file system.*//' -e 's/ //g' \
84 -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' \
86 sed '/^nodev/d' /proc/filesystems | sed '1!G; $p; h; d'`
88 for fs
in $filesystems; do
89 if mount
-t $fs -o $mountopt $root /mnt
2> /dev
/null
; then
90 echo "Successfully mounted root as $fs."
91 # TODO: later on search other places if we want 100% backward compat?
92 init
=${init:-/sbin/init}
93 if [ -f /mnt
$init ]; then
97 echo "Specified init ($init) does not exist!"
103 [ $
(( i
++ )) -eq 0 ] && echo "Waiting for root device to become ready."
110 echo "No root or init, but we do not scream, debug shell:"