Subject: [HOWTO] Installing on a recent Mac (DRAFT 1)
To: None <port-macppc@netbsd.org>
From: Charles M. Hannum <root@ihack.net>
List: port-macppc
Date: 03/24/2001 08:22:18
A lot of people have recently asked me for information on this, so I
thought I would write something up.  If you have problems with this
(OTHER than your model not being supported yet), please send me mail
so I can adjust the instructions accordingly.

Note that this applies ONLY of OFW3 Macs -- basically, from the iMac
up.  Specifically, this is how I installed a G4 cube, among others.
Note that I'm not redoing this as I write the instructions, so it's
entirely possible I've forgotten something important.  That's why this
is called a DRAFT.

I'm sort of annoyed (not at the users, though) that it's necessary for
me to write this at all, so if parts of this sound harsh, you know
why.


Step 0 -- Forget Everything You Learned
---------------------------------------

Before you do anything else, just delete all the installation
instructions that came with NetBSD.  All they will do is confuse you,
because they're written for older Macs.

No, really.  Don't read them.


Step 1 -- Partitioning (or: Sysinst Sucks)
------------------------------------------

The most important thing to understand is that Apple OFW3 really,
really wants to boot from a file in a file system -- and it doesn't
understand FFS.  What this means to you is that you need a `stub' file
system to put the boot program (ofwboot.elf or ofwboot.xcf) in.
Sysinst doesn't know how to do this, so don't bother trying it.

Since most people probably want to have MacOS around for some purpose
or other, I suggest putting the boot program in a HFS or HFS+
partition.  On a Mac fresh from the factory, you will typically have a
single HFS+ partition filling the entire disk.  The simplest thing to
do is boot the MacOS installation CD and reinstall from scratch,
editing the partition info to give the HFS partition less space.  Make
sure it's still the first partition on the disk, though.

Your other option for installing on the same disk -- e.g. if you
actually have data you don't want to lose -- is to buy a partitioning
tool.  Don't ask me which one, because I don't know.

You can also add a second disk (on some machines; notably not on the
cube) and boot off that.  In this case you don't need to repartition.

On whichever disk you're going to install on, your life will be easier
if you set up the partition table under MacOS (or the MacOS installer)
to have an `A/UX Root' partition.  You'll use this for NetBSD.  If you
want a separate swap partition, create an `A/UX Swap' partition while
you're at it.  Personally, I just use one big partition and a swap
file.


Step 2 -- Installing the Boot Program (or: Sysinst Bites)
---------------------------------------------------------

After you've set up whatever partitioning you like, you need to
install the boot program.  If you're using 1.5 (which, BTW, doesn't
work on a lot of the newer machines past the original G4), use
ofwboot.elf.  If you're using -current, you can probably use
ofwboot.xcf if you want.

In any event, copy this into your HFS+ partition.  You may need to
boot MacOS to do this.  I downloaded it with Internet Abhorer.  You
can also copy it off a CD.

At this point, you can also download a sysinst kernel and put it in
your HFS partition too.  What's that you say?  `Where do I get a
sysinst kernel?  I don't see one on the CD or in the snapshot.'
That's because it isn't there.  That would be too easy, now wouldn't
it?

So, forget that and set up NFS on another machine.  If you've gotten
this far without pulling your hair out and/or screaming in pain,
you're probably clueful enough to do that.  You'll need BOOTP, too.
Set up a whole netboot environment for the Mac.  (Just unpack the tar
files, run MAKEDEV, and export everything by NFS.)

Alternatively, you can burn a CD for the root file system, if that's
easier for you.  Make sure you have a kernel and a populated /dev on
it.


Step 3 -- Booting the Victim (or: Sysinst Blows)
------------------------------------------------

Now, you need to dabble with OpenFirmware a little.  Power on your
machine and hold down Command-Option-O-F.  After some time, you should
get some black text on a white background that says `OpenFirmware blah
blah blah ... > '.  Congratulations, you're 3l33t.

The first thing you want to do is tell the machine not to boot to
MacOS automatically.  Type `setenv auto-boot? false' and then
`reset-all'.  You should see the banner again.  If you don't, you
screwed up, and should start over again at the `power on' stage.

Now, every time your machine comes up, you'll get an OFW prompt.
You're probably thinking a boot selector would be a cool thing, but we
don't have one (yet?).  You're probably also thinking it would be cool
to just boot into NetBSD, but, sadly, many versions of OFW won't
initialize the screen if you set it up this way, and unfortunately the
kernel is too dumb to that itself.  So, forget it for now.

Anyway, at this point, type `setenv boot-device hd:,\ofwboot.elf' (or
ofwboot.xcf, whichever you installed).  That tells the firmware to
look for a file system and read that file out of it.  Make sure you
use the right backslash, or you'll get an obscure and supremely
unhelpful error message.  Type `reset-all' again, because otherwise
you'll lose the change later, and this is where you want to end up
booting from.

Now you need to tell it where to find the kernel.  If you're booting
over the net, type `setenv boot-file enet:netbsd' (or 'net:netbsd'; I
forget, but you can figure it out from the OFW prompt with `dev
/aliases' and `.properties'), and then `reset-all' again.

If you're booting from a CD, then `setenv boot-file cd:netbsd' should
work.  Don't forget the `reset-all'.  (Okay, so it's not really
necessary to do that 3 times, but make sure you do it at least once,
or your OFW settings will get lost.)

Now type `boot'.  After a moment, you should see some gibberish that
starts with `>> NetBSD/macppc OpenFirmware Boot, Revision x.xx'.  This
is good.  If you're lucky, it will then load the kernel and fire it
up.  If you've ever watched a NetBSD system boot, it will be obvious
whether or not this happens.

If you're booting from the net, it will do this by BOOTPing, NFS
mounting the root file system, and then loading the kernel via NFS.
People (including me) always screw up setting up the netboot
environment the first time, so don't be surprised if one or more of
these things fails.  Try again.


Step 4 -- Copying Over the System (or: Sysinst Chews)
-----------------------------------------------------

I know I told you to forget it, but if by some miracle you do have a
sysinst kernel (with the RAM disk and whatnot), booting it in the
previous step might actually allow you to do the this part fairly
painlessly.  Arguably, one should be present in the snapshot.
However, PLEASE DON'T ASK ME FOR ONE; I don't want to be doing that
kind of support.  If you've booted into sysinst, proceed with it and
then skip to step 5 in these instructions.

If not, then you will have to experience a little more pain.

If you set up the MacOS partition table as I told you to in step 1,
then the NetBSD kernel will automatically generate a bullshit^Wfake
disklabel with the `A/UX Root' partition as partition `a' (and the
`A/UX Swap' partition as partition `b', if you made one).  At this
point you should be booted with a populated root, so just type `newfs
/dev/rwd0a' (or /dev/rsd0a if you have SCSI).

Now, mount the file system (`mount /dev/wd0a /mnt') and unpack the tar
files (`pax -C /mnt -zrpe -f /wherever/base.tgz', etc.)  DON'T forget
the `-pe'; you'll regret it, and you'll probably end up sending mail
about why commands like `su' are failing, which we will all snicker
at.

When all the tar files are unpacked, `cd /mnt/dev; sh MAKEDEV all'.
Then `reboot'.  Or at least type `sync' a couple of times.

You might also take the time now to create /etc/fstab and edit rc.conf
-- or you can do it later; your choice.


Step 5 -- Actually Booting the OS (or: Sysinst Spits)
-----------------------------------------------------

Back at the OFW prompt, you'll want to tell it where the file system
disappeared to.  The exact OFW path depends on the MacOS partition
map, which is likely to be a little different on other machines.  On
mine, it's `hd:10/netbsd'; on yours it might be `hd:9/netbsd', etc.
Try `setenv boot-device hd:10/netbsd'.  Try a different one until you
get lucky.  (You could actually figure it out by looking at the
partition map with a more useful tool than Apple provides, but I don't
feel like writing those instructions right now.)  Don't forget to
`reset-all' before booting, because the firmware WILL forget.

Now you should be able to type `boot' and it will boot into NetBSD.


Step 6 -- What Next?
--------------------

After getting NetBSD installed, the first thing I highly recommend is
punting the version of X included with it and installing XF86 4.
Unfortunately, AFAIK there's no snapshot, and the patches necessary
for macppc have not been integrated into our source tree.  So you're
kind of on your own there.  If you do build it, you'll find it's a LOT
faster, and actually supports real screen sizes and depths, though.

If you didn't create a swap partition, you'll also want to create a
swap file (in / is fine) and put it in /etc/fstab.  Make sure you
`chmod go=' it.

Like most platforms, there are a bunch of packages from pkgsrc
prebuilt on the FTP server.  I personally ported and use Mozilla as a
web browser.  We don't have Java for it yet, but it does most
everything else.  (Flash and RealMedia would be nice, but I'll live.)

I don't actually have the USB speaker set that came with the cube, so
if someone could test that and let me know whether or not it works,
that would be cool.  I personally use an Altec Lansing ADA70 speaker
set and a Telex USB Audio Converter dongle, both of which work in
-current.  The Telex dongle won't work in 1.5.


Epilogue
--------

Yes, the installation process should be easier.  Yes, the
documentation sucks.  Yes, sysinst should do the necessary setup
(except maybe shrinking the HFS partition) for us.  Yes, we should
have an X server -- WITH SOURCE -- in the system that actually works
well on Macs.  Don't complain to me, though.

Good luck.