Subject: Howto install NetBSD 1.6.1 stable on an iBook
To: None <port-macppc@netbsd.org>
From: Anselm R. Garbe <anselmg@t-online.de>
List: port-macppc
Date: 01/19/2004 18:54:44
Hi there,

I've written a howto, how I've installed NetBSD 1.6.1 and upgraded
to NetBSD 1.6.2_RC4 this weekend (special thanks to Aaron W. Hsu).

Sorry about the uppercase headings!

---
HOWTO INSTALL NetBSD ON AN iBook
--------------------------------

Software: NetBSD/macppc 1.6.1 stable
Hardware: Apple iBook late 2002 model, 700 Mhz, ATI Radeon M7,
          Apple Airport WLAN, 2xUSB, 1xFireWire

ENGLISH vs GERMAN
-----------------
Well, I write this short howto in English, because there may be lots of
non-german speaking geeks out there interested in installing NetBSD on
their iBook. Sorry for my English :)

WHY THE HELL INSTALLING NetBSD ON AN iBook?
-------------------------------------------
Why not? An OS which works on toasters should also work on iBooks.
Mac OS X is not a good choice for me, if you like UNIX. There's too much
old OS 9 stuff in there, too much (one button) mouse control, curios
NetInfo stuff (instead of good old /etc), curios source tree with different
naming conventions (Java style naming conventions bungled with old clean C
style naming conventions, etc.). To say it in short words: Mac OS X is a
"Eierlegende Wollmilchsau" in my eyes.
Linux/ppc works also good on an iBook, but I prefer a clean UNIX like
NetBSD.
(By the way, I also tried OpenBSD, which works also well on an iBook,
but I prefer NetBSD, because they make no such hype about their OS, as
OpenBSD does.)

WHAT WE ARE GOING TO DO?
------------------------
We are going to install NetBSD 1.6.1 stable on a iBook as stand-alone(!)
OS without another OS besides it and without any Apple tools.

WHAT DO YOU'LL NEED?
--------------------
- Some freetime, I think a weekend.
- An internet connection (also while installation).
- An iBook

STEPS
-----

1. Download and burn the NetBSD/macppc 1.6.1 iso image from
ftp://ftp.netbsd.org/pub/NetBSD/iso/1.6.1/macppccd.iso (or another
mirror)

    Note: Don't download snapshot 1.6Z, it does not work with
    compareable iBooks to mine.

2. Backup all your data on your iBook.

3. Read ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-1.6.1/macppc/INSTALL.html
and http://www.netbsd.org/Ports/macppc/partitioning.html for getting
involved with necessary information about what you're going to do.

4. Now it's time to put one's money where one's mouth is: bash your
burned NetBSD cd into your cdrom drive and reboot.

5. After the Apple boot sound hold down Apple+Alt+O+F to enter
OpenFirmeware.

6. Enter:

    boot cd:,ofwboot.xcf netbsd.macppc

7. Wait until NetBSD wants input. Don't enter the normal installation
routine, because we need to create special partitions first (which
current disklabel isn't capable of), that are readable for OpenFirmware.

8. Configure the integrated gem0 (100baseTX) or wi0 (WLAN) NIC to have
an internet connection to match your local network configuration.
(Utility menu or just exit the installation program and use route and
ifconfig).

9. Exit the installation program.

10. Fetch pdisk (the partition tool we're going to use) from
ftp://ftp.netbsd.org/pub/NetBSD/arch/macppc/netbsd-pdisk/netbsd-pdisk.macppc-1-6
into /sbin, and rename it to pdisk.

11. Now we're going to partition the disk.
Use pdisk /dev/wd0c to enter pdisk. (I hope you've read the partition
howto, see link above, third step)

12. Create a new partition map using i.

13. Create a partition with offset at 2p with size 32m and type Apple_HFS
using the C option. Name is boot.

14. Create a partition with offset at 3p with size 1g and bzb bit a
(root) using the c option. Name is root.

15. Create a partition with offset at 4p with size 1g and bzb bit b
(swap) using the c option. Name is swap.

16. Create a partition with offset at 5p with size 1g and bzb bit e
(tmp) using c option. Name is tmp.

17. Create a partition with offset at 6p with size 1g and bzb bit f
(var) using c option. Name is var.

18. Create a partition with offset at 7p with size 5g and bzb bit g
(usr) using c option. Name is usr.

19. Dump the partition configuration using p.

20. Create a partition with offset at 8p with the size of free blocks
dumped with p in step 19. Use size of the free space column. Use bzb bit
h and name home.

21. Now you've successfully configured the new partition map.
It looks like following:

    1: Apple partition map
    2: 32m HFS boot
    3: 1g Apple_UNIX_SVR2 root /    a
    4: 1g Apple_UNIX_SVR2 swap      b
    5: 1g Apple_UNIX_SVR2 tmp       e
    6: 1g Apple_UNIX_SVR2 var       f
    7: 5g Apple_UNIX_SVR2 usr  /usr g
    8: *g Apple_UNIX_SVR2 home      h

22. Write out the partition map using w.

23. Now newfs all partitions:

    newfs /dev/wd0a
    newfs /dev/wd0e
    newfs /dev/wd0f
    newfs /dev/wd0g
    newfs /dev/wd0f
    newfs /dev/wd0g
    newfs /dev/wd0h

    Note: Don't care about error messages that newfs couldn't touch the
    disklabel - that's right since we've created everything with pdisk.

24. Mount the root partition to mnt2 and create following directories:

    mount /dev/wd0a /mnt2
    mkdir /mnt2/etc
    mkdir /mnt2/tmp
    mkdir /mnt2/usr
    mkdir /mnt2/var

    And create a fstab which matches your wd0 disklabel configuration,
    in my configuration wd0f and wd0g have been swapped for some reason
    I don't know:

    echo    /dev/wd0a / ffs rw 1 1 >> /mnt2/etc/fstab
    echo    /dev/wd0b none swap sw 0 0 >> /mnt2/etc/fstab
    echo    /dev/wd0e /tmp ffs rw 1 2 >> /mnt2/etc/fstab
    echo    /dev/wd0g /var ffs rw 1 2 >> /mnt2/etc/fstab
    echo    /dev/wd0f /usr ffs rw 1 2 >> /mnt2/etc/fstab
    echo    /dev/wd0h /home ffs rw 1 2 >> /mnt2/etc/fstab

25. Now umount /mnt2 again and enter sysinst.

26. In sysinst just use "Re-install sets..." and proceed with
installation. After finishing these steps (equivalent to standard
installation and which will create all device nodes in /dev) you can
configure your Timezone and set a root password through going to the
"Utilities" menu again.

27. Now we're ready for the first boot. Exit install and enter reboot.

29. Enter OpenFirmware holding down Apple+Alt+O+F

30. Let the installation disk in your drive and enter:

    boot cd:,ofwboot.xcf hd:3,/netbsd

31. Wait until netbsd boots into single user mode.

32. Remount / using:

    mount -o rw /dev/wd0a /

33. Cd to /etc and edit your rc.conf:

    rc_configured=YES
    wscons=YES

    Note: You can use vi to edit it, but then you have to mount your
    /usr partition manually (mount /dev/wd0f /usr), vi is located in
    /usr/bin/vi

34. Maybe you've a german iBook, so you wants also edit your
    /etc/wscons.conf

    enconding=de

35. Maybe your network configuration has not been saved by sysinst.
    So do create manually

    /etc/mygate (contains IP address of your gateway)
    /etc/resolv.conf (contains "nameserver <IP address of your DNS server")
    /etc/ifconfig.gem0 

        contains something like this:

        inet 10.0.0.99 netmask 255.255.255.0
        media 100BaseTX

36. The step 35 will configure your network configuration for the next
    boot. Just reboot now.

37. Use the same boot command as described in step 30.

38. Now your network devices are up and configured. Fetch pkgsrc.tar.gz
from ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-current/tar_files/pkgsrc.tar.gz 
and extract it to /usr

39. Install /usr/pkgsrc/sysutils/hfsutils (make install clean)

40. Format your boot partition through:

    hformat /dev/wd0d

41. Place your ofwboot.xcf file of your installation cdrom (mount
    /dev/cd0a /mnt) to that partition:

    hcopy /mnt/ofwboot.xcf :

42. Now your system is ready. X11 configuration will follow. I advice to
upgrade your system to 1.6 stable (currently 1.6.2_RC4) through
following steps:


43. Cd /usr and perform following commands

    cd /usr
    setenv CVS_RSH ssh
    cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot co -r netbsd-1-6 -P src
    (this may take a while)

44. Now upgrade using:

    cd /usr/src
    ./build.sh
    (this may also take a while, around 10h)

45. Afterwards use following kernel configuration file and place it
under /usr/src/sys/arch/macppc/conf/:

---[IBOOK]---
#
# IBOOK machine description file
# by Anselm R. Garbe <anselmg at t-online.de>
#
# Used with a late 2002 iBook 700 (ATI Radeon M7, 2xUSB, 1xFireWire,
# CDROM, ...)
# 

include		"arch/macppc/conf/std.macppc"

options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary

ident 		"IBOOK"

maxusers	32

# Standard system options
#options 	UCONSOLE	# users can use TIOCCONS (for xconsole)
#options 	INSECURE	# disable kernel security levels

options 	RTC_OFFSET=0	# hardware clock is this many mins. west of GMT
#options 	NTP		# NTP phase/frequency locked loop
options 	KTRACE		# system call tracing via ktrace(1)

options 	SYSVMSG		# System V message queues
options 	SYSVSEM		# System V semaphores
#options 	SEMMNI=10	# number of semaphore identifiers
#options 	SEMMNS=60	# number of semaphores in system
#options 	SEMUME=10	# max number of undo entries per process
#options 	SEMMNU=30	# number of undo structures in system
options 	SYSVSHM		# System V shared memory
#options 	SHMMAXPGS=1024	# 1024 pages is the default

options 	LKM		# loadable kernel modules

#options 	USERCONF	# userconf(4) support
#options 	PIPE_SOCKETPAIR	# smaller, but slower pipe(2)

# Diagnostic/debugging support options
#options 	DIAGNOSTIC	# cheap kernel consistency checks
#options 	DEBUG		# expensive debugging checks/support
#options 	DDB		# in-kernel debugger
#options 	DDB_HISTORY_SIZE=512	# enable history editing in DDB
#options 	TRAP_PANICWAIT

#makeoptions 	DEBUG="-g"	# compile full symbol table

# Compatibility options
#options 	COMPAT_09	# NetBSD 0.9,
#options 	COMPAT_10	# NetBSD 1.0,
#options 	COMPAT_11	# NetBSD 1.1,
#options 	COMPAT_12	# NetBSD 1.2,
#options 	COMPAT_13	# NetBSD 1.3,
#options 	COMPAT_14	# NetBSD 1.4,
#options 	COMPAT_43	# and 4.3BSD
#options 	COMPAT_386BSD_MBRPART # recognize old partition ID
#options 	COMPAT_LINUX	# Linux binary compatibility
#options 	TCP_COMPAT_42	# 4.2BSD TCP/IP bug compat. Not recommended.

# File systems
file-system 	FFS		# UFS
#file-system 	EXT2FS		# second extended file system (linux)
file-system 	LFS		# log-structured file system
file-system 	MFS		# memory file system
file-system 	NFS		# Network File System client
file-system 	CD9660		# ISO 9660 + Rock Ridge file system
file-system 	MSDOSFS		# MS-DOS file system
file-system 	FDESC		# /dev/fd
file-system 	KERNFS		# /kern
file-system 	NULLFS		# loopback file system
file-system 	OVERLAY		# overlay file system
file-system 	PORTAL		# portal filesystem (still experimental)
file-system 	PROCFS		# /proc
file-system 	UMAPFS		# NULLFS + uid and gid remapping
file-system 	UNION		# union file system

# File system options
#options 	QUOTA		# UFS quotas
#options 	FFS_EI		# FFS Endian Independant support
options 	SOFTDEP		# FFS soft updates support.
#options 	NFSSERVER	# Network File System server
#options 	EXT2FS_SYSTEM_FLAGS # makes ext2fs file flags (append and
				# immutable) behave as system flags.

#options 	NFS_BOOT_DHCP	# Support DHCP NFS root

# Networking options
#options 	GATEWAY		# packet forwarding
options 	INET		# IP + ICMP + TCP + UDP
options 	INET6		# IPV6
#options 	IPSEC		# IP security
#options 	IPSEC_ESP	# IP security (encryption part; define w/IPSEC)
#options 	IPSEC_DEBUG	# debug for IP security
#options 	MROUTING	# IP multicast routing
#options 	NS		# XNS
#options 	NSIP		# XNS tunneling over IP
#options 	ISO,TPIP	# OSI
#options 	EON		# OSI tunneling over IP
#options 	CCITT,LLC,HDLC	# X.25
options 	NETATALK	# AppleTalk networking protocols
#options 	PPP_BSDCOMP	# BSD-Compress compression support for PPP
#options 	PPP_DEFLATE	# Deflate compression support for PPP
#options 	PPP_FILTER	# Active filter support for PPP (requires bpf)
options 	PFIL_HOOKS	# pfil(9) packet filter hooks
options 	IPFILTER_LOG	# ipmon(8) log support
#options 	IPFILTER_DEFAULT_BLOCK	# block all packets by default
#options 	TCP_DEBUG	# Record last TCP_NDEBUG packets with SO_DEBUG

# These options enable verbose messages for several subsystems.
# Warning, these may compile large string tables into the kernel!
options 	PCIVERBOSE	# verbose PCI device autoconfig messages
options 	MIIVERBOSE	# verbose PHY autoconfig messages
#options 	PCI_CONFIG_DUMP	# verbosely dump PCI config space
#options 	SCSIVERBOSE	# human readable SCSI error messages
options 	USBVERBOSE	# verbose USB device autoconfig messages

# wscons options
#options 	WSEMUL_SUN			# sun terminal emulation
options 	WSEMUL_VT100			# VT100 / VT220 emulation
#options 	WSDISPLAY_COMPAT_RAWKBD		# can get raw scancodes
options 	FONT_SONY8x16

# Kernel root file system and dump configuration.
config		netbsd	root on ? type ?

#
# Device configuration
#

mainbus* at root

cpu*	at mainbus?
bandit*	at mainbus?
grackle* at mainbus?
uninorth* at mainbus?

pci*	at bandit? bus ?
pci*	at grackle? bus ?
pci*	at uninorth? bus ?
pci*	at ppb? bus ?

pchb*	at pci? dev ? function ?	# PCI-Host bridges
ppb*	at pci? dev ? function ?	# PCI-PCI bridges
# XXX 'puc's aren't really bridges, but there's no better place for them here
puc*	at pci? dev ? function ?	# PCI "universal" comm. cards

fpa*	at pci? dev ? function ?	# DEC PCI FDDI (DEFPA) Controller
ofb*	at pci? dev ? function ?	# Generic Open Firmware Framebuffer
options 	OFB_ENABLE_CACHE	# Speed up console
pciide*	at pci? dev ? function ?
wdc*	at pci? dev ? function ?	# Kauai ATA
gem*	at pci? dev ? function ?	# gmac ethernet
obio0	at pci? dev ? function ?
#macofcons0 at pci? dev ? function ?	# OpenFirmware console (for debugging)

bmtphy*	at mii? phy ?			# Broadcom BCM5201/BCM5202 PHYs
ukphy*	at mii? phy ?			# generic unknown PHYs

bm*	at obio?			# bmac ethernet
mc*	at obio?			# MACE ethernet
nvram*	at obio?			# nvram
adb*	at obio?			# Apple Desktop Bus
aed*	at adb?				# ADB Event Device
akbd*	at adb?				# ADB keyboard
ams*	at adb?				# ADB mouse
abtn*	at adb?
zsc*	at obio?
zstty*	at zsc? channel ?
mediabay* at obio?
wdc*	at mediabay? flags 0
# awacs is disabled because on some systems--e.g., a 350MHz G4 GigE--
# it may generate interrupt storms, rendering the machine unusable.
# If you uncomment this, you'll also want to uncomment "audio* at awacs?"
# below.
awacs*	at obio?			# Apple audio device
wi*	at obio?			# AirMac

wsdisplay0 at ofb? console ?
wskbd0	at akbd? console ?
wsmouse0 at ams?

wdc*	at obio? flags 0x1
wd*	at pciide? channel ? drive ?
wd*	at wdc? channel ? drive ? flags 0x0000

atapibus* at pciide? channel ?
atapibus* at wdc? channel ?

cd*	at atapibus? drive ? flags 0x0000	# ATAPI CD-ROM drives
sd*	at atapibus? drive ? flags 0x0000	# ATAPI disk drives
uk*	at atapibus? drive ? flags 0x0000	# ATAPI unknown

# PCI USB controllers
ohci*	at pci? dev ? function ?			# Open Host Controller

usb*	at ohci?					# USB bus support
uhub*	at usb?						# USB Hubs
uhub*	at uhub? port ? configuration ? interface ?

uhidev*	at uhub? port ? configuration ? interface ?	# USB HID device

ums*	at uhidev? reportid ?				# USB Mice
wsmouse* at ums?

ukbd*	at uhidev? reportid ?				# USB Keyboards
wskbd*	at ukbd? console ?

uhid*	at uhidev? reportid ?				# USB Generic HID

ulpt*	at uhub? port ? configuration ? interface ?	# USB Printer

umodem*	at uhub? port ? configuration ?			# USB Modem
ucom*	at umodem?

umass*	at uhub? port ? configuration ? interface ?	# USB Mass Storage
atapibus* at umass? channel ?
scsibus* at umass? channel ?

uaudio*	at uhub? port ? configuration ?			# USB audio

ugen*	at uhub? port ? configuration ? interface ?	# USB Generic driver

# PCI IEEE1394 controllers
fwohci*	at pci? dev ? function ?	# IEEE1394 Open Host Controller
fw*	at fwbus?			# IP over 1394

# IEEE1394 nodes
#fwnode* at fwbus? oui ? devhi ? devlo ?
#scsibus* at fwnode?

# Audio Devices

# PCI audio devices
#clcs*	at pci? dev ? function ?	# Cirrus Logic CS4280
#cmpci*	at pci? dev ? function ?	# C-Media CMI8338/8738
#eap*	at pci? dev ? function ?	# Ensoniq AudioPCI
#eso*	at pci? dev ? function ?	# ESS Solo-1 PCI AudioDrive
#fms*	at pci? dev ? function ?	# Forte Media FM801
#sv*	at pci? dev ? function ?	# S3 SonicVibes

# OPL[23] FM synthesizers
#opl*	at cmpci? flags 1
#opl*	at eso?
#opl*	at fms?

# Audio support
audio* at awacs?
#audio*	at clcs?
#audio*	at cmpci?
#audio*	at eap?
#audio*	at eso?
#audio*	at fms?
#audio*	at sv?
#audio*	at uaudio?

# MPU 401 UARTs
#mpu*	at cmpci?
#mpu*	at eso?
#mpu*	at fms?

# MIDI support
#midi*	at eap?			# 137[01] MIDI port
#midi*	at mpu?			# MPU 401

pseudo-device	vnd		4	# disk-like interface to files
pseudo-device	ccd		4	# concatenated/striped disk devices
#pseudo-device	raid		8	# RAIDframe disk driver
#options 	RAID_AUTOCONFIG		# auto-configuration of RAID components
# Options to enable various other RAIDframe RAID types.
# options 	RF_INCLUDE_EVENODD=1
# options 	RF_INCLUDE_RAID5_RS=1
# options 	RF_INCLUDE_PARITYLOGGING=1
# options 	RF_INCLUDE_CHAINDECLUSTER=1
# options 	RF_INCLUDE_INTERDECLUSTER=1
# options 	RF_INCLUDE_PARITY_DECLUSTERING=1
# options 	RF_INCLUDE_PARITY_DECLUSTERING_DS=1
pseudo-device	md		1	# memory disk device
pseudo-device	loop			# network loopback
pseudo-device	bpfilter	8	# packet filter
pseudo-device	ipfilter		# IP filter (firewall) and NAT
#pseudo-device	ppp		2	# Point-to-Point Protocol
#pseudo-device	pppoe			# PPP over Ethernet (RFC 2516)
#pseudo-device	sl		2	# Serial Line IP
#pseudo-device	tun		4	# network tunneling over tty
#pseudo-device	gre		2	# generic L3 over IP tunnel
pseudo-device	gif		4	# IPv[46] over IPv[46] tunnel (RFC1933)
#pseudo-device	faith		1	# IPv[46] tcp relay translation i/f
#pseudo-device	stf		1	# 6to4 IPv6 over IPv4 encapsulation
pseudo-device	vlan			# IEEE 802.1q encapsulation
pseudo-device	bridge			# simple inter-network bridging
pseudo-device	pty			# pseudo-terminals
pseudo-device	rnd			# /dev/random and in-kernel generator
pseudo-device	openfirm		# /dev/openfirm
pseudo-device	wsmux			# mouse and keyboard multiplexor
pseudo-device	clockctl		# user control of clock subsystem
---[IBOOK]---

46. Build a new kernel:

    cd /usr/src/sys/arch/macppc/conf
    config IBOOK
    cd ../compile/IBOOK/
    make depend
    make
    cp /netbsd /netbsd.old
    cp netbsd /

47. Reboot and enter OpenFirmware and enter following commands:

    eject cd (you don't need the installation disk anymore)

    reset-nvram
    setenv auto-boot? false
    setenv boot-device hd:2,ofwboot.xcf
    setenv boot-file hd:3,/netbsd
    reset-all

    Note: Setting auto-boot to true results on my iBook in a blank
    screen after booting. You can try it. Maybe it works with
    auto-boot=true for you?

48. If auto-boot=false, you've to enter boot at each start of the iBook.

49. I recommend at this time to use the default Xmacppc Server, just
launch X entering startx. In future there'll be XFree 4.3 with ATI
support. I'll have a look at it if there's enough time :)

    See also: http://www.netbsd.org/Ports/macppc/x11.html

50. I hope all these steps helped you. If you know something better, 
let me know! 

---

Regards,
    Anselm

-- 
Anselm R. Garbe  <>  GPG fingerprint: 3977 C88E F5F3 97CA 8AD9
 www.ebrag.de    /\    NetBSD/x86      6DD7 74CE 2A7A 0D73 F361