Skip site navigation (1)Skip section navigation (2)
Date:      Thu,  6 Apr 2000 21:39:23 +0200
From:      Adrian Steinmann <ast@marabu.ch>
To:        freebsd-small@FreeBSD.ORG
Cc:        "Jonathan M. Bresler" <jmb@hub.freebsd.org>, jss@subatomix.com, Warner Losh <imp@village.org>
Subject:   Re: Mounting and Corruption Rehashed 
Message-ID:  <200004061939.VAA08298@marabu.marabu.ch>
In-Reply-To: <200004042047.OAA70876@harmony.village.org>
References:  <20000404204324.3155E37B8D6@hub.freebsd.org>   <200004042047.OAA70876@harmony.village.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Hello small free-bsd-ers!

"Jonathan M. Bresler" <jmb@hub.freebsd.org> recently asked:

   : 	how about sending out at how-to on this??


I can't stand lurking anymore, so here goes:

This is my special /etc/rc.conf:
    root_rw_mount=NO
    rootdev=fla0
    diskless_mount=/etc/rc.readonly
    etc_size=1536
    home_size=1024
    var_size=32768

and this is my special /etc/rc.readonly:
    if [ -f /etc/defaults/rc.conf ]; then
	. /etc/defaults/rc.conf
    elif [ -f /etc/rc.conf ]; then
	. /etc/rc.conf
    fi

    echo -n "Making writable mfs filesystems:"

    mount_mfs -s ${var_size:=65536} -T qp120at dummy /var
    while [ -e /var/.readonly ]; do sleep 1; done
    for d in root log run db msgs cron cron/tabs spool spool/mqueue \
	tmp tmp/vi.recover at at/jobs at/spool
    do
	mkdir /var/$d && chmod 755 /var/$d
    done
    chmod 755 /var
    chmod 1777 /var/tmp /var/tmp/vi.recover
    chown daemon /var/at/jobs /var/at/spool
    touch /var/run/utmp && chmod 644 /var/run/utmp
    touch /var/log/wtmp && chmod 664 /var/log/wtmp
    (cd /root && tar cBf - . | (cd /var/root && tar xBf -))
    echo -n " var"

    cp /dev/MAKEDEV /var/tmp
    mount_mfs -s 256 -i 512 -T qp120at dummy /dev
    while [ -f /dev/.readonly ]; do sleep 1; done
    cp /var/tmp/MAKEDEV /dev && rm -f /var/tmp/MAKEDEV
    cd /dev && sh MAKEDEV std ${rootdev} ${rootdev}s1h vty12 pty0 ttyd0 ttyd1
    echo -n " dev"

    for d in etc home
    do
	(cd /$d && tar cBf - .) > /var/tmp/$d.tar
	eval mount_mfs -s \${${d}_size:=1024} -T qp120at dummy /$d
	while [ -e /$d/.readonly ]; do sleep 1; done
	(cd /$d && tar xBf /var/tmp/$d.tar)
	rm -f /var/tmp/$d.tar && echo -n " $d"
    done

    echo

You should see this when you come up:
    $ mount -p
    /dev/fla0s1a    /       ufs ro  1 1
    mfs:28  /var    mfs rw,async    0 0
    mfs:73  /dev    mfs rw,async    0 0
    mfs:816 /etc    mfs rw,async    0 0
    mfs:822 /home   mfs rw,async    0 0


It's not so surprising that by turning just those two knobs we have a
flash system which doesn't gradually self destruct since its mounted
read-only.

When you remount / rread-write to update, just reboot and get on
with it (remounting ro works, but can we trust it?).

Shall we get /etc/rc.readonly and a special /etc/rc.conf section
mentioning "how to" put into the main distribution?

_________________________________________________________________________
Dr. Adrian Steinmann  Steinmann Consulting  Apollostrasse 21  8032 Zurich
   Tel +41 1 380 30 83     Fax +41 1 380 30 85    Mailto:ast@marabu.ch


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-small" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200004061939.VAA08298>