wok-current rev 1704

busybox: add rootfssize parameter for tmpfs root switching
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Nov 14 08:49:36 2008 +0000 (2008-11-14)
parents 6db4741ea7a4
children daea944c82bd
files busybox/stuff/init
line diff
     1.1 --- a/busybox/stuff/init	Thu Nov 13 23:45:08 2008 +0000
     1.2 +++ b/busybox/stuff/init	Fri Nov 14 08:49:36 2008 +0000
     1.3 @@ -1,9 +1,21 @@
     1.4  #!/bin/sh
     1.5  
     1.6 -echo "switching / to tmpfs..."
     1.7 -/bin/mount -t tmpfs tmpfs /mnt
     1.8 -/bin/mkdir /mnt/mnt
     1.9 -/bin/mv /dev /usr /var /root /etc /sys /tmp /media /proc /home /mnt
    1.10 -/bin/ln -s bin/busybox mnt/init
    1.11 -/bin/cp -a /sbin /bin /lib /mnt
    1.12 -exec /sbin/switch_root mnt /init
    1.13 +echo -n "switching / to tmpfs..."
    1.14 +mount -t proc proc /proc
    1.15 +size="$(grep rootfssize= < /proc/cmdline | \
    1.16 +	sed 's/.*rootfssize=\([0-9]*[kmg%]\).*/-o size=\1/')"
    1.17 +umount /proc
    1.18 +mount -t tmpfs $size tmpfs /mnt
    1.19 +for i in $(ls -a /); do
    1.20 +	case "$i" in
    1.21 +	.|..|init);;
    1.22 +	mnt)	mkdir /mnt/mnt;;
    1.23 +	*)	if ! cp -a /$i /mnt 2> /dev/null; then
    1.24 +			echo -e "\\033[70G[ \\033[1;31mFailed\\033[0;39m ]"
    1.25 +			umount /mnt
    1.26 +			exec /sbin/init
    1.27 +		fi;;
    1.28 +	esac
    1.29 +done
    1.30 +echo -e "\\033[70G[ \\033[1;33mOK\\033[0;39m ]"
    1.31 +exec /sbin/switch_root mnt /sbin/init