# HG changeset patch # User Pascal Bellard # Date 1226652576 0 # Node ID 8c3c67c64f26afcd36a3cd866a0a40bdf5c0c590 # Parent 6db4741ea7a43d4952c14d883cea7ccd6dfa9095 busybox: add rootfssize parameter for tmpfs root switching diff -r 6db4741ea7a4 -r 8c3c67c64f26 busybox/stuff/init --- a/busybox/stuff/init Thu Nov 13 23:45:08 2008 +0000 +++ b/busybox/stuff/init Fri Nov 14 08:49:36 2008 +0000 @@ -1,9 +1,21 @@ #!/bin/sh -echo "switching / to tmpfs..." -/bin/mount -t tmpfs tmpfs /mnt -/bin/mkdir /mnt/mnt -/bin/mv /dev /usr /var /root /etc /sys /tmp /media /proc /home /mnt -/bin/ln -s bin/busybox mnt/init -/bin/cp -a /sbin /bin /lib /mnt -exec /sbin/switch_root mnt /init +echo -n "switching / to tmpfs..." +mount -t proc proc /proc +size="$(grep rootfssize= < /proc/cmdline | \ + sed 's/.*rootfssize=\([0-9]*[kmg%]\).*/-o size=\1/')" +umount /proc +mount -t tmpfs $size tmpfs /mnt +for i in $(ls -a /); do + case "$i" in + .|..|init);; + mnt) mkdir /mnt/mnt;; + *) if ! cp -a /$i /mnt 2> /dev/null; then + echo -e "\\033[70G[ \\033[1;31mFailed\\033[0;39m ]" + umount /mnt + exec /sbin/init + fi;; + esac +done +echo -e "\\033[70G[ \\033[1;33mOK\\033[0;39m ]" +exec /sbin/switch_root mnt /sbin/init