wok rev 7844

busybox/init: replace rootuuid= by mount=
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Dec 28 14:29:53 2010 +0100 (2010-12-28)
parents 5c676acf3361
children e33ea4c4b370
files busybox/stuff/init
line diff
     1.1 --- a/busybox/stuff/init	Tue Dec 28 12:31:53 2010 +0100
     1.2 +++ b/busybox/stuff/init	Tue Dec 28 14:29:53 2010 +0100
     1.3 @@ -2,21 +2,20 @@
     1.4  
     1.5  launch_init()
     1.6  {
     1.7 +	umount /proc
     1.8  	echo -e "\\033[70G[ \\033[1;33mOK\\033[0;39m ]"
     1.9 -	subroot=
    1.10 -	grep -q subroot= /proc/cmdline &&
    1.11 -	subroot="/$(sed 's/.*subroot=\([^ ]*\).*/\1/' < /proc/cmdline)"
    1.12  	exec /sbin/switch_root mnt$subroot /sbin/init
    1.13  }
    1.14  
    1.15  failed()
    1.16  {
    1.17 +	umount /proc
    1.18  	echo -e "\\033[70G[ \\033[1;31mFailed\\033[0;39m ]"
    1.19  }
    1.20  
    1.21  try_init()
    1.22  {
    1.23 -	if [ ! -d /mnt/etc ] && grep -q cryptoroot= /proc/cmdline; then
    1.24 +	if [ ! -d /mnt$subroot/etc ] && grep -q cryptoroot= /proc/cmdline; then
    1.25  		modprobe dm-mod
    1.26  		modprobe dm-crypt
    1.27  		modprobe aes-i586
    1.28 @@ -34,12 +33,12 @@
    1.29  		fi
    1.30  		mount /dev/mapper/$dmlabel /mnt
    1.31  	fi
    1.32 -	if [ -d /mnt/etc ]; then
    1.33 +	if [ -d /mnt$subroot/etc ]; then
    1.34  		umount /sys
    1.35  		[ -n "$1" ] && for i in $@ ; do
    1.36 -			cp -a $i /mnt$(dirname $i)
    1.37 +			cp -a $i /mnt$subroot$(dirname $i)
    1.38  		done
    1.39 -		umount /proc
    1.40 +		mount /mnt -o remount,ro
    1.41  		launch_init
    1.42  	fi
    1.43  	failed
    1.44 @@ -104,11 +103,10 @@
    1.45  	echo -n "Switching / to lvm $root..."
    1.46  	mount_mapper
    1.47  fi
    1.48 -if grep -q loopfs= /proc/cmdline; then
    1.49 -	loopfs="$(sed 's/.*loopfs=\([^ ]*\).*/\1/' < /proc/cmdline)"
    1.50 -	dev=${loopfs%,*}
    1.51 -	loopfs=${loopfs#*,}
    1.52 -	echo -n "Switching / to loop $loopfs on $dev..."
    1.53 +if grep -q mount= /proc/cmdline; then
    1.54 +	root="$(sed 's/.*mount=\([^ ]*\).*/\1/' < /proc/cmdline)"
    1.55 +	dev=$(blkid | grep $root | sed 's/:.*//;q')
    1.56 +	echo -n "Mounting $dev ($root) ..."
    1.57  	if ! mount $dev /mnt; then
    1.58  		if echo $dev | grep -q "/dev/sd"; then
    1.59  			delay=`cat /sys/module/usb_storage/parameters/delay_use`
    1.60 @@ -116,28 +114,28 @@
    1.61  			echo -n "sleep for $delay seconds..."
    1.62  			sleep $delay
    1.63  		fi
    1.64 -		mount $dev /mnt || loopfs=""
    1.65 +		mount $dev /mnt
    1.66  	fi
    1.67 -	if [ -n "$loopfs" ]; then
    1.68 -		losetup /dev/loop0 /mnt/$loopfs
    1.69 -		mount /dev/loop0 /mnt 2> /dev/null
    1.70 -	fi
    1.71 -	try_init
    1.72 +fi
    1.73 +if grep -q loopfs= /proc/cmdline; then
    1.74 +	loopfs="$(sed 's/.*loopfs=\([^ ]*\).*/\1/' < /proc/cmdline)"
    1.75 +	echo -n "Switching / to loop $loopfs..."
    1.76 +	losetup /dev/loop0 /mnt/$loopfs
    1.77 +	mount /dev/loop0 /mnt 2> /dev/null
    1.78  fi
    1.79  grep -q cryptoroot= /proc/cmdline && try_init
    1.80 -if grep -q rootuuid= /proc/cmdline; then
    1.81 -	root="$(sed 's/.*rootuuid=\([^ ]*\).*/\1/' < /proc/cmdline)"
    1.82 -	mount $(blkid | grep $root | sed 's/:.*//') /mnt && try_init
    1.83 -fi
    1.84 +grep -q subroot= /proc/cmdline &&
    1.85 +subroot="/$(sed 's/.*subroot=\([^ ]*\).*/\1/' < /proc/cmdline)"
    1.86 +[ -d /mnt$subroot/etc ] && try_init
    1.87  umount /sys
    1.88  echo -n "Switching / to tmpfs..."
    1.89  size="$(grep rootfssize= < /proc/cmdline | \
    1.90  	sed 's/.*rootfssize=\([0-9]*[kmg%]\).*/-o size=\1/')"
    1.91  free=$(busybox free | busybox awk '/Mem:/ { print int(($4*100)/$3) }')
    1.92 -umount /proc
    1.93  [ -n "$size" ] || size="-o size=90%"
    1.94  if [ $free -lt 100 ] || ! mount -t tmpfs $size tmpfs /mnt; then
    1.95  	echo -e "\\033[70G[ \\033[1;33mSkipped\\033[0;39m]"
    1.96 +	umount /proc
    1.97  	exec /sbin/init
    1.98  fi
    1.99  for i in $(ls -a /); do