#!/bin/ash
#
# Remounts root on tmpfs, iff using 2.4.* kernel
# and then starts real init (always).
#
# (C) 2001 Michal Moskal <malekith@pld.org.pl>
#
# This file can be modified and/or redistributed under
# the terms of GPL version 2 (without any options :^).
# 

if uname -r | grep -q '^2.4' ; then
  echo -n "Mounting tmpfs... "
  mkdir -p /.tmpfs
  mount tmpfs /.tmpfs -t tmpfs
  echo done
  
  echo -n "Coping root contest... "
  cd /
  tar cf - * | ( cd /.tmpfs ; tar xf - )
  echo done
  
  echo -n "Changeing root... "
  mkdir /.tmpfs/oldroot
  pivot_root /.tmpfs /.tmpfs/oldroot
  # we need chdir("/") (see pivot_root(2))
  cd /
  
  # mount devfs and proc again...
  mount devfs /dev -t devfs
  mount none /proc -t proc
  
  echo "done"
else
  echo "Won't remount root for `uname -r`"
fi

exec /bin/init "$@"

# vim:ft=sh
