wok-stable annotate busybox/stuff/init @ rev 1772
busybox: check memory size before tmpfs switch
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Nov 27 16:12:32 2008 +0000 (2008-11-27) |
parents | daea944c82bd |
children | f0cb83ba12fd |
rev | line source |
---|---|
pascal@1703 | 1 #!/bin/sh |
pascal@1703 | 2 |
pascal@1704 | 3 echo -n "switching / to tmpfs..." |
pascal@1704 | 4 mount -t proc proc /proc |
pascal@1704 | 5 size="$(grep rootfssize= < /proc/cmdline | \ |
pascal@1704 | 6 sed 's/.*rootfssize=\([0-9]*[kmg%]\).*/-o size=\1/')" |
pascal@1772 | 7 free=$(busybox free | busybox awk '/Mem:/ { print int(($4*100)/$3) }') |
pascal@1704 | 8 umount /proc |
pascal@1772 | 9 if [ $free -lt 100 ] || ! mount -t tmpfs $size tmpfs /mnt; then |
pascal@1772 | 10 echo -e "\\033[70G[ \\033[1;33mSkipped\\033[0;39m]" |
pascal@1772 | 11 exec /sbin/init |
pascal@1772 | 12 fi |
pascal@1704 | 13 for i in $(ls -a /); do |
pascal@1704 | 14 case "$i" in |
pascal@1705 | 15 .|..) ;; |
pascal@1704 | 16 mnt) mkdir /mnt/mnt;; |
pascal@1704 | 17 *) if ! cp -a /$i /mnt 2> /dev/null; then |
pascal@1704 | 18 echo -e "\\033[70G[ \\033[1;31mFailed\\033[0;39m ]" |
pascal@1704 | 19 umount /mnt |
pascal@1704 | 20 exec /sbin/init |
pascal@1704 | 21 fi;; |
pascal@1704 | 22 esac |
pascal@1704 | 23 done |
pascal@1704 | 24 echo -e "\\033[70G[ \\033[1;33mOK\\033[0;39m ]" |
pascal@1704 | 25 exec /sbin/switch_root mnt /sbin/init |