Subject: Re: live cd
To: None <netbsd-users@NetBSD.org>
From: M.Negovanovic <milosn@xtra.co.nz>
List: netbsd-users
Date: 02/10/2004 10:30:48
On Mon, Feb 09, 2004 at 12:30:13PM -0800, Jeremy C. Reed wrote:
> On Tue, 10 Feb 2004, M.Negovanovic wrote:
> 
> > I have managed to eliminate the need of mounting mfs-s with union option
> 
> Please share an example on how you do this.

STEP1

The idea is very simple. 3 important dirs (/etc, /dev, /var) contain
only stuff relevant for successful multiuser boot burned on the CD
itself, all other stuff is extracted from /etc/rc:



*** console output ***

root@sisyphus testlivecd # ls etc/*
etc/rc       etc/rc.conf  etc/rc.subr

etc/defaults:
rc.conf

root@sisyphus testlivecd # ls var/*
ls: var/*: No such file or directory

root@sisyphus testlivecd # ls dev/*
dev/console

*** console output ***



File /etc/rc has this addition:

echo "**********************************"
echo "*** LiveCD setup part 1 start! ***"
echo "**********************************"
echo "Creating memory filesystems ..."
echo "/var 30m"
mount_mfs -s 30m -o noatime,rw swap /var
echo "/etc 10m"
mount_mfs -s 10m -o noatime,rw swap /etc
echo "/dev 10m"
mount_mfs -s 10m -o noatime,rw swap /dev
echo "Memory filesystems created!"
echo "Extracting /dev ..."
cd /dev && tar zxpf /.cdstuff/dev.tgz
echo "Extracting /etc ..."
cd /etc && tar zxpf /.cdstuff/etc.tgz
echo "Extracting /var ..."
cd /var && tar zxpf /.cdstuff/var.tgz
echo "********************************"
echo "*** LiveCD setup part 1 end! ***"
echo "********************************"

As u can see there is no union option :). U simply mount over existing
dirs (they contain only the bare minimal of conf files anyway) and then
u extract pre-made *.tgz which have full set of devices, conf files and
var directory structure.




STEP2

Here we mount and extract /tmp, /home and /root. Relevant files are
/etc/fstab and /etc/rc.d/lextract:


/etc/fstab looks like this:

/dev/cd0a / cd9660 ro 0 0
swap /tmp mfs rw,nodev,noexec,nosuid,noatime,-s=10m 0 0
swap /root mfs rw,noatime,-s=10m 0 0
swap /home mfs rw,noatime,-s=10m 0 0


/etc/rc.d/lextract looks like this:

#!/bin/sh
#
# $NetBSD: ipfilter,v 1.10 2001/02/28 17:03:50 lukem Exp $
#

# REQUIRE: mountall

. /etc/rc.subr

name="lextract"
rcvar=$name
start_cmd="lextract_start"
stop_cmd="lextract_stop"

lextract_start()
{
	echo "**********************************"
	echo "*** LiveCD setup part 2 start! ***"
	echo "**********************************"
	echo "Extracting /home ..."
	cd /home && tar zxpf /.cdstuff/home.tgz
	echo "Extracting /root ..."
	cd /root && tar zxpf /.cdstuff/root.tgz
	echo "********************************"
	echo "*** LiveCD setup part 2 end! ***"
	echo "********************************"
}

lextract_stop()
{
	echo "Stoping LiveCD setup part 2 ... nothing to be done! Bye!"
}

load_rc_config $name
run_rc_command "$1"


You need "lextract=YES" in your /etc/rc.conf. Thats all.

Hmm all this might look complicated but it gives you all relevant file
systems with correct permissions, readable and writable.



> I assume "your" is referring to me. I found my webpage which has very old
my bad, i was not clear. yes i was referring to your web page.


Regards
Milos