# vim: set ft=sh: -*- sh -*-
# $Id: 00remounttab,v 1.7 2004/02/07 17:41:27 lioka Exp $

INIT_DIR=/etc/rc.d
REMOUNTTAB=/etc/remounttab

cat <<E_O_F >> $REMOUNTTAB
/dev  size=1m,nr_inodes=30000
/etc  size=4m
/home size=4m
/root size=1m
/var/log size=4m
/var/lock size=50k
# /var/lib/dhcp size=100k
/var/lib/klogd size=100k
# /var/lib/nfs size=100k
/var/lib/xkb size=100k
/var/run size=200k
/var/resolv size=400k
E_O_F

cat <<E_O_F>>$INIT_DIR/init.d/functions
# Remount root fs parts via tmpfs
remount_root_readwrite()
{
    REMOUNTTAB=$REMOUNTTAB
    if [ -s \$REMOUNTTAB ]; then
        grep -ve '^\(#\|\$\)' \$REMOUNTTAB |while read mntpt rest; do
            if [ -d \$mntpt ]; then
                [ -z "\$rest" ] || rest="-o \$rest"
                echo -n "Remounting \$mntpt read/write:"
		(cd \$mntpt && tar cp . 2> /dev/null) |\
		(mount -n -ttmpfs \$rest /dev/shm \$mntpt && tar x -m -C \$mntpt/) && echo_success || echo_failure
            fi
        done
    else
	action "Remounting root filesystem in read/write mode:" mount -n -o remount,rw /
    fi
}

E_O_F

subst "s|action \"Remounting root filesystem in read/write mode:\" mount -n -o remount,rw /|remount_root_readwrite|" $INIT_DIR/rc.sysinit
