Subject: Building a Dual (or Triple) Boot Cube - How I did it.
To: None <port-macppc@netbsd.org>
From: Andrew White <awhite@arc.corp.mot.com>
List: port-macppc
Date: 04/10/2001 17:01:09
This is a multi-part message in MIME format.
--------------B4CF71ADCEC8627E9E5DBA25
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Here are instructions for building a dual- or triple- (9 and X) boot cube
with 9/X on one set of partitions and NetBSD on another.  I have assumed a
certain version of the distribution CD, which may not work for anyone else.

FWIW, the CD is grey and labelled NetBSD Disk One, 1.5, and comes in a blue
dual CD case.

Anyway, my instructions from start (partitioning the drive) to finish are
attached.  It worked for me.  Use at own risk.

-- 
Andrew White                Andrew.E.White@motorola.com
--------------B4CF71ADCEC8627E9E5DBA25
Content-Type: text/plain; charset=us-ascii;
 name="MyInstallCube.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="MyInstallCube.txt"


Step 1 - Partition your hard drive

I used 2 Mac OS partitions (9.1 and X) and 3 BSD partitions, as follows:

#1: HFS+
#2: BSD Root
#3: HFS+
#4: BSD Swap
#5: BSD User

Note that #1 corresponds to partition 9 on the device, and so on.

To partition, use Drive Setup (eg on the OS 9 / 9.1 install CD).  As an example, I used partition sizes of 4 Mb, 512 Kb, 8 Mb, 1 Mb and the rest (about 6 Mb), respectively.  HFS+ format is the same as Macintosh Extended format.  For the BSD devices, use the various Unix formats.

Before doing a NetBSD install, it's probably worth installing at least OS9, if not OSX also.  It will make copying the files (in step 2) a lot easier.


Step 2 - Install bootstrap file systems

Boot into OS 9 or OS X.

Copy "ofwboot.xcf" and "macppc/installation/boot.fs" from the NetBSD CD to the root of an HFS+ device, preferably the first partition of the first device.

Leave the CD in the drive.


Step 3 - Reboot into Open Firmware

Reboot, holding down Cmd-Opt-O-F as the machine boots.
At the OF prompt ("0 >"), enter "setenv auto-boot? false".
"reset-all" stores this and reboots the machine.  It should automatically enter open firmware.

	0 > setenv auto-boot? false
	0 > reset-all


Step 4 - Boot the install kernel

In open firmware, enter "boot hd:9,ofwboot.xcf hd:9,boot.fs".  This boots the bootloader ("ofwboot.xcf") from hard drive 0, partition 9.  The bootloader then boots the kernel image "boot.fs" from hard drive 0, partition 9.

	0 > boot hd:9,ofwboot.xcf hd:9,boot.fs

Partition 9 is usually the first usable partition of an Apple formatted HD.  If you put it on another partition, you will have to figure out yourself where it went.  The "pdisk" utility under OS X is useful for this.


Step 5 - Installing NetBSD Kernel

The system will present a whole lot of boot data, then prompt for a terminal type (with a default of 'vt100').  'vt100' is fine, so just press 'return'.

The system will then ask you if you wish to "Install", "Shell" or "Halt".  If you select "Install", it will drop you into SysInstall.  Unfortunately, SysInstall will happily clobber your partition map but will not preserve your HFS+ partitions.

Instead, go into the shell.  If you type "disklabel wd0" you will see what NetBSD thinks of your partition map.  Among other things, your NetBSD root partition will be at partition A, your swap partition at B and your user partition somewhere down the list (probably G).

Format partitions A and G:

	# newfs /dev/rwd0a
	# newfs /dev/rwd0g

Ignore the disklabel error messages; they don't matter.

Mount your root partition (to install to) and the cdrom (to install from).  Conveniently, two mount points are provided: /mnt and /mnt2

	# mount /dev/wd0a /mnt
	# mount -t cd9660 /dev/cd0a /mnt2

It is time to install the netbsd distribution files.  Since we want to use
/dev/wd0g as our /usr directory, we will create and mount that before we unarchive everthing.

	# cd /mnt
	# mkdir usr
	# mount /dev/wd0g usr

Now install the various distribution sets.  We will start with the essentials.  Note:  If you don't enjoy looking watching the filename dump scroll past, omit the -v switch.

Make sure you are in the directory /mnt.
	# cd /mnt

Boot kernel (essential)
	# pax -rzv -pe -f /mnt2/macppc/binary/sets/kernel.

NetBSD base commands (essential)
	# pax -rzv -pe -f /mnt2/macppc/binary/sets/base.tgz

Configuration files (essential)
	# pax -rzv -pe -f /mnt2/macppc/binary/sets/etc.tgz

Man and Info pages (recommended)
	# pax -rzv -pe -f /mnt2/macppc/binary/sets/etc.tgz

Text processing utilities (useful)
	# pax -rzv -pe -f /mnt2/macppc/binary/sets/text.tgz

Compilers (useful)
	# pax -rzv -pe -f /mnt2/macppc/binary/sets/comp.tgz

Miscellaneous - more documentation, examples, sendmail (optional)
	# pax -rzv -pe -f /mnt2/macppc/binary/sets/text.tgz

Games (essential) :)
	# pax -rzv -pe -f /mnt2/macppc/binary/sets/games.tgz

If you have a cinema display, don't bother with the X stuff.  The X server doesn't seem to work on a cinema display.

You can't pass more than one archive file at once, which means that you type "/mnt2/macppc/binary/sets/" a lot, but the budding shell programmer can get around this.

	# cd /mnt
	# for i in /mnt2/macppc/binary/sets/[!x]*.tgz
	> do
	> pax -rzv -pe -f $i
	> done

Now go and have dinner while you wait for this to finish.


Step 6 - Device Configuration

Now configure the Devices.  Make the devices and create the file system table (fstab).

Make the devices

	# cd /mnt/dev
	# ./MAKEDEV all

Create fstab

	# cat > /mnt/etc/fstab
	/dev/wd0a / ffs rw 1 1
	/dev/wd0b none swap sw 0 0
	/dev/wd0g /usr ffs rw 1 2
	/kern /kern kernfs rw
	<CTRL-D>
	# mkdir /mnt/kern


Step 7 - Configure the NetBSD system

Unfortunately, rc.conf is very difficult to configure without a reboot.

	# reboot

However, we can at least boot into our NetBSD system.  The system should return you to the open firmware prompt.  This time, boot the NetBSD partiton (partition 10 on my partitioning scheme).

	0 > boot hd:9,ofwboot.xcf hd:10/netbsd

Note:  The use of '/' rather than ',' in hd:10/netbsd is important.

Note #2: On my Cube, the screen driver sometimes fails to work properly when restarting into open firmware, resulting in a blank screen.  If you think this has happened to you, type 'shut-down' and the cube will shut down.  You can then restart it and the screen driver will work again.  Don't be too hasty - open firmware sometimes takes a few seconds to appear.


Watch NetBSD boot.  Eventually, it will stop with an error:

	/etc/rc.conf is not configured.  Multiuser boot aborted.
	Enter pathname of shell or RETURN for sh:

Press return, and you are in NetBSD in single user mode.

Before doing anything else, I would recommend setting "delete" to erase.  This will make typing a lot easier.
	# stty erase ^H

To write rc.conf, we need to mount the drives in read/write mode, starting with the root partition.  Once root is remounted, we can mount the entire file system (as defined by fstab).

	# mount -w -u /
	# mount -a

Now, open rc.conf for editing.  The most important thing is to set "configured=YES".  It's also the time to configure your network settings.  I've included a useful set of defaults below, including DHCP boot out the ethernet port and IP6 autohost mode.

	# export TERM=vt100
	# vi /etc/rc.conf

And inside

	configured=YES

	# IP4 autoconfig
	auto_ifconfig=YES
	dhclient=YES

	# IP6 autohost config
	ip6mode=autohost
	rtsol=YES	rtsol_flags="gm0"

	# Secure shell server
	sshd=YES

You should aslo set your hostname in /etc/myname.

	# cat > /etc/myname
	host.network.net
	<CTRL-D>

And let's add an admin user and set some passwords while we're at it:

	# useradd -m -c "Joe User" -G wheel joe
	# passwd joe
		...
	# passwd root
		...

Your NetBSD box is now configured.  Reboot and enjoy.

	# reboot

	0 > boot hd:9,ofwboot.xcf hd:10/netbsd

--------------B4CF71ADCEC8627E9E5DBA25--