3 echo "T2 live setup (C) 2005 - 2007 Rene Rebe, ExactCODE"
5 mkdir
-p /tmp
; chmod 1777 /tmp
7 livedev
=`sed -n '/[^ ]* \/media\/live/{s/ .*//p; q}' /proc/mounts`
9 if mount
-n $livedev -o remount
,rw
/media
/live
2>/dev
/null
; then
10 echo "Re-mounted /media/live read-write."
13 echo "Unionfs overlay setup ..."
17 for f
in /media
/live
/live-
*.
*; do
22 if mount
-nt auto
-o loop
,noatime
$f /mnt
/$n; then
23 if grep -q "/mnt/$n .* rw" /proc
/mounts
; then
24 echo "Mounted $f read-write."
25 dirs="/mnt/$n=rw:$dirs"
28 echo "Mounted $f read-only."
29 dirs="/mnt/$n=ro:$dirs"
32 echo "Failed to mount $f!"
36 # determine union fs to use, TODO: allow user-overwrite
38 modprobe aufs
2> /dev
/null
39 if grep -q 'aufs$' /proc
/filesystems
; then unionfs
=aufs
40 elif grep -q 'unionfs$' /proc
/filesystems
; then unionfs
=unionfs
43 if [ "$unionfs" ]; then
46 mount
-nt tmpfs none
/mnt
/overlay
47 dirs="/mnt/overlay:$dirs"
50 mount
-nt $unionfs -o noatime
,dirs=$dirs none
/mnt
/live
52 echo "Finalizing setup ..."
53 cat /proc
/mounts
> /etc
/mtab
55 find /tmp
/lib
-type f
-name '*.ko' |
while read f
; do
57 [ -e $f ] ||
mv -f /tmp
/$f $f
61 # convert symlinks to bind mounts
62 for x
in /mnt
/live
/* ; do
65 dev|proc|sys|media|mnt|tmp
) continue ;;
68 # echo "Removing /$x ..."
71 # echo "Binding /mnt/live/$x /$x"
73 /tmp
/bin
/mount
-t none
-o bind /mnt
/live
/$x /$x
76 rm -rf /tmp
/lib
/tmp
/bin
/init
{,2}
78 init
="init= `cat /proc/cmdline`" ; init
=${init##*init=} ; init
=${init%% *}
79 # TODO: later on search other places if we want 100% backward compat.
80 [ "$init" ] || init
=/sbin
/init
85 echo "No init found, giving up. Debug shell:"