#!/bin/sh -e
# This 'init' script does some initial work when ramdisk is loaded
mount -t proc proc proc
mount -t tmpfs tmpfs mnt

# Install modules at bootstrap stage
#modprobe 8139too

umount proc

cp -aR bin dev etc lib sbin usr /mnt
cd mnt
# make more directories that will be used in the new root.
mkdir -p ramdisk proc mnt var/log
pivot_root . ramdisk
mount -t proc proc proc
ln -sf ../bin/busybox sbin/init
# change root to tmpfs, and call the real init program linked to busybox
exec /usr/sbin/chroot . /sbin/init < dev/console > dev/console