#!/bin/sh
echo "init..."
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mdev -s
newroot=`findfs LABEL=ROOT`
cleanmntdir()
{
rm -rf /mnt/*
}
copyroot()
{
FILES=`ls /`
for F in $FILES
do
[ $F != 'mnt' ] && [ $F != 'proc' ] && [ $F != 'sys' ] && cp -a $F /mnt
done
}
if [ "$?" = 0 ]
then
echo "findfs find newroot=$newroot"
mount $newroot /mnt
if [ "$?" = 0 ]
then
echo "mount $newroot on /mnt"
#if [ ! -x "/mnt/linuxrc" ]; then
# echo "No init found. cp rootfs..."
# copyroot
#fi
cleanmntdir
copyroot
umount /proc
umount /sys
echo "switch_root..."
# exec /sbin/switch_root /mnt /linuxrc -c /dev/tty1
exec /bin/sh
fi
fi
echo "no ROOT found! enter factory boot..."
exec /linuxrc