Subject: Re: Latest iBook model support
To: None <"[>
From: dixie <dixieml@imap.cc>
List: port-macppc
Date: 08/07/2005 20:20:15
This is a multi-part message in MIME format.
--------------010605080302030201040304
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

[: wacco :] wrote:

>Hi there guys and girls,
>
>I'm as of wednesday the proud owner of the now one-and-a-half week old
>new model iBook G4 12". You know, the model that isn't included on
>this page yet: http://docs.info.apple.com/article.html?artnum=88039
>
>Some specs for the clueless:
>  Machine Name: iBook G4
>  Machine Model: PowerBook 6,7
>  CPU Type: PowerPC G4 (1.2)
>  CPU Speed: 1.33 GHz
>  L2 Cache: 512 KB
>  Memory: 512 MB
>  Bus Speed: 133 MHz
>  Boot ROM Version: 4.9.3f0
>  HD Size: 40 GB
>  Optical Drive: CD-RW/DVD-ROM
>  Airport, Bluetooth, sudden motion sensor, scrolling touch pad, and
>some more goodies.
>
>Anyway, I'm not familiar with netBSD at all. I've used freeBSD a bit,
>and know a thing or two about kernels but my main focus is cognitive
>Ai programming and research, with custom OS design and embedded
>systems as a side-hobby. Not an expert in the field of BSD kernel
>hacking, to say in the least.
>
>However, I am seriously considering to get 'involved' and I think a
>dual boot would be really fun. Thing is, I'm clueless in where to
>start, especially since this system is so incredibly new and unknown
>to the public. Next to that, support will be sporadic and the
>possibility of damaging the hardware && / || firmware makes me lightly
>paranoid.
>
>I will start looking into how to set up a system like this, but I'd
>like to hear if somebody else can give me some prior info, has the
>same system, or whatever.
>
>I'll keep it short for now, I'll keep you updated if I make any progress.
>
>Cheerio, wacco
>
>  
>
Hi :)
I attach some notes taken down during installation(s) that became sort 
of a small howto.
Hope it'd be of some help.
Reviews (any kind) are welcome :)

Regards

d.

--------------010605080302030201040304
Content-Type: text/plain;
 name="howto.txt"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline;
 filename="howto.txt"

NetBSD/macppc Simple Install And Basic X Configuration Howto
------------------------------------------------------------

Disclaimer
----------
This document applies mainly to [i|Power]Books G4, but it could contain  valid information
for the same operations on preceiding models. (OpenFirmware > 3)
If you do not have a notebook or a too old one (i.e. old world Macs) please take a look at
the support page[1] and refer carefully to the INSTALL notes[2] and read the other related howtos[3].
I have directly experimented this procedure only on a iBook G4 late 2004 model.
The author will NOT take ANY RESPONSABILITY of what you do with your machine or for problems,
lack of performances, data loss and so on. (Try at Apple's remostrances e-mail address HA HA. :|)
This documents comes AS IS, ABSOLUTELY NO WARRANTY is explicitly nor implicitly meant.
I always assume you had take care of your data BAKING UP everithing important you may have on your
hard drive BEFORE start doing anything else.
NetBSD <= 1.6.2 is known to hang up after the boot process on models similar to mine.

Abstract
--------
These pages go through the installation and basic X configuration of the NetBSD 2.0 release on a Apple
iBook G4. (But you already guessed it, didn't you?)
The final goal is to dual boot in the smoothest manner possible Mac OS X and NetBSD.

Getting NetBSD
--------------
You can get NetBSD in various manner but the old plain way consist on downloading the latest iso
image avaiable from an ftp (possibly a mirror[4]) and burn it to a cd using whatever you want.
(No, this howto does not cover burning procedures. RTFineM)
Before starting on blaming me, be sure you checksum the image you downloaded with the MD5 file
located in the same directory of the isos on the ftp.

Boot
----
Usually to boot from cd on Apple's machines you just have to hold down the 'c' key after the boot
chime, but this way is known not to work on all [cases|machines].
Let's try another way, for it is written "TMTOWTDI".
First reach the OpenFirmware prompt (OF from now on) holding down the awful, terribly finger-cracking key
combination: Command-Option-O-F. (Feel free to call someone to help you if it's too difficult, I won't laugh
on you, I promise. Of course, if you are an "emacs" user, you just need one finger)
Now to avoid additional sufference to your fingers change the value stored in the auto-boot
variable using OF's setenv command:

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

so when you power on your machine it will stop at OF's prompt.
If you downloaded an official iso, the following command should work and it should work either if you downloaded
an unofficial iso as well.

O > boot cd:,\ofwboot.xcf netbsd.macppc <CR>

following OF's syntax that prescribes 'boot <boot-device> <kernel>'.
If the kernel starts booting and at the end requires input, call your friend and have a party, the worst
part is over. (You could take a deep breath and go relax anywhere, first)
For any kind of error please refer to the related section of the install notes.

Preparing the Hard Drive
------------------------
Now, you need to create a partition map that is understandable both for OF and NetBSD.
This map is called APM, Apple Partition Map, and unfortunately you could not use the installer since
it uses disklabel(5) that cannot create such kind of map.
Fortunately from 2.0 on pdisk(8) was included in the distribution so you do not need to stole network
access anymore, only to download it while installing.
pdisk(8) is a command line tool that can only partition your hard drive, not create any kind of filesystem
nor install a boot loader.
Apple's 'Books have usually only one hard disk also usually on wd0 so you can start pdisk like this:

# /sbin/pdisk /dev/wd0c

where partition 'c' means "the whole disk".
First of doing this, as you may have experienced, backspace does not what you expected and has to be fixed:

# stty erase '^h'
# stty erase '^?'

where ' is tick.
Once entered in pdisk(8), take a look at the help and familiarize with the basic commands, then decide quickly
the design of your map so you can repent and format your entire hard drive in a week or two.
Assuming as written above that you have BAKED UP everything important on your disc, use 'd'(delete)
and 'C'(uppercase, Create) commands for re-design your own partition map, in a long-term view possibly.
There are two main Rules to follow:

- Apple Partion Map is on partition #1 so do NOT touch it.
- You will need a small HFS (the old HFS) partition for latter pourpose.
  (the lesser you can, install notes said 32Mb and by now I do not know if
  a smaller size is possible)

This is an example of APM:

# /sbin/pdisk wd0c

Edit /dev/wd0c -
Command (? for help): p
Partition map (with 512 byte blocks) on '/dev/wd0c'
 #:                type name      length   base      ( size )
 1: Apple_partition_map Apple         63 @ 1        
 2:           Apple_HFS name       65536 @ 64        ( 32.0M)
 3:           Apple_HFS name    62914560 @ 65600     ( 30.0G)
 4:     Apple_UNIX_SVR2 name      614400 @ 62980160  (300.0M) S0 RUFS k0  /
 5:     Apple_UNIX_SVR2 name     1064960 @ 63594560  (520.0M) S1  SFS k0  (swap)
 6:     Apple_UNIX_SVR2 name    19783680 @ 64659520  (  9.4G) S2  UFS k0  /usr
 7:     Apple_UNIX_SVR2 name    20480000 @ 84443200  (  9.8G) S2  UFS k0
 8:          Apple_Free Extra   12287040 @ 104923200 (  5.9G)

Device block size=512, Number of Blocks=117210240 (55.9G)
DeviceType=0x0, DeviceId=0x0

Command (? for help): 

'name' is left as an exercise for the reader. (As they say, it should be a descriptive text)

In this map there is a root partition, followed by a swap and then by an /usr partition;
these three are quite mandatory, the rest of the map is up to your needs.
If your disk does not have an APM yet use the 'i' command to initialize one.
You can start your partitions at the p-th block, as you prefer.
Well time to start creating some partition, here's an example creation of a small HFS partition:

Command (? for help): C
First block: 2p
Length in blocks: 32m
Name of partition: boot
Type of partition: Apple_HFS
Command (? for help): 

Here is an example creation of a small root partition from where NetBSD can boot off:

Command (? for help): C
First block: 4p
Length in blocks: 200m
Name of partition: root
Type of partition: Apple_UNIX_SVR2
Available partition slices for Apple_UNIX_SVR2:
  a   root partition
  b   swap partition
  c   do not set any bzb bits
  g   user partition
Other lettered values will create user partitions
Select a slice for default bzb values: a
Command (? for help):

the three partition types avaiable are:

Apple_HFS 	-> HFS and HFS+ partitions
Apple_UFS 	-> UFS partitions
Apple_UNIX_SVR2 -> A/UX-style partitions for Unix and Unix-like systems.

Creating Apple_UNIX_SVR2 partitions, a, b, g are mandatory bzb bits, for user-defined partitions 
(all partitions that YOU defined but a, b, g) you could choose whatever bit you want, among [defh-y].

Once you finished designing your map (for further deepening refer to the partitioning howto[5]) you
had to write (w) it to the disk then you can quit (q).
As usual, quitting without saving means lose all your changes. (MS Word docet)

Creating FileSystems
--------------------
Back to the root prompt check your map using disklabel(5) and take a look at the partitons' id
(yes, a, b, g, etcetc) and copy them to a post-itŪ for some frightening latter pourpose.
Now it is the time to pass your fingernails all trough the blackboard. (oh, this is 'latter pourpose' above)
You can barely newfs each partition you have precedently created, in wich case you will use ffs:

# newfs /dev/wd0?

otherwise you can add few flags to improve bare performances and .... your friends:

# newfs -O2 -m%age -o[space|time] /dev/wd0?

that means in order: use UFSv2 (ffs2), the minimum space left in percentage before the system will
give you an error when trying to write, the optimization type that depends on what you entered as
argument of the preceiding flag.
It is not written "newfs's man page won't hurt you"?

Last Steps Before Installation
------------------------------
Mount your root partition to mnt2 and create the appropriate set of directories:

# mount /dev/wd0a /mnt2
# mkdir /mnt2/etc
# mkdir /mnt2/usr

one directory for each partition you have created, place them wherever you want (no, placing your home directory
under /tmp/try/to/find/it/if/you/can/ is not usually a great idea), then write down an fstab
accordingly with what disklabel(5) shows you.

echo /dev/wd0a / ffs rw 1 1 >> /mnt2/etc/fstab
echo /dev/wd0b none swap sw 0 0 >> /mnt2/etc/fstab
echo /dev/wd0g /usr ffs rw 1 2 >> /mnt2/etc/fstab
...

as your disklabel requires.

Installation
------------
Exit the shell then enter sysinst and select "Re-install sets".
Enter the "Utilities" menu and set minor details such as root password and the timezone.
Reboot.

First Boot
----------
Quietly unsurprisingly IT won't boot multiuser as you might have been expecting.
The only thing to do is open your favourite editor an edit /etc/rc.conf changing
the line:

rc_configured=NO

to

rc_configured=YES

but I hope you alredy guessed it.
The only editor avaiable in single user mode is the powerful ed. (Powerful is an euphemism)
If you cannot bear a power like that in your hands, mount your /usr and use your REALLY 
favourite editor. (Define the $EDITOR variable first)
The very-very-basic-first-boot configuration is left as exercise to the reader. (The number of exercises is
incresing isn't it?)

Bringing Up That Wild Beast Called X
------------------------------------
This few intense lines assumes you installed XFree 4.4.0 from the sets on the distribution's cd.
Once launched 'X -configure' X would not go up simply typing [startx|xinit|xinit\ &].
Typing

% X -test -xf86config ~/XF86Config.new

gives no interesting results.
Reading carefully the error it returned you could notice there are some lines to add at your 
~/XF86Config.new before moving it to /etc/X11/XF86Config:

Option "Protocol" "wskbd"
Option "Device" "/dev/wskbd0"

Before doing this you should run xf86config as usual giving these values as Horyzontal sync range:

HorizSync 31 70

Now you could start your X server to experiment a keymap completly screwed up.
You should create /var/db/xkb using '-p' as mkdir flag and chmod it '775'.
This is the solution given in the FAQs but it is known not to resolve the problem
so you should use xmodmap(1) and xev(1) to set every screwed character to work properly,
see the related man pages for further informations.
It is a really fast'n'easy work so you won't mind if it is completly uncovered.

Dual Boot
---------
This section should cover the setting to guarantee the lesser-annoying dual boot possible.
After you have installed Mac OS X you could set proper aliases in OF to semplify the boot sequence
instead of write down an entire Dante's "Divina Commedia" paragraph each time.
Mac OS X can boot simply typing 'bye' to OF's prompt.
-section under construction-

notes and useful links
----------------------
[1] http://www.netbsd.org/Ports/macppc/models.html				full list of supported models.
[2] ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-2.0.2/macppc/INSTALL.html 		INSTALL notes. 
[3] http://www.netbsd.org/Ports/macppc/faq.html					macppc specific FAQ.
    http://www.netbsd.org/Documentation/					General documentation and FAQs.
[4] http://www.netbsd.org/mirrors/						NetBSD mirror list.
[5] http://www.netbsd.org/Ports/macppc/partitioning.html			macppc partitioning howto.

Visit http://www.netbsd.org/Ports/macppc/ for more useful informations.


--------------010605080302030201040304--