FreeBSD on MacBook is easy, you just have to follow the above steps.

Table of contents

  1. Needed
  2. Hardware configuration
  3. System installation
  4. FreeBSD use, and detailed setup
    1. Keyboard
    2. Network setup
    3. System update and build
    4. Power management
    5. Ports management
    6. CD / DVD burn, and how-to eject them
    7. Audio
    8. X.org setup
  5. Uninstall FreeBSD
  6. Miscellaneous issues
  7. More info

Needed

Let say you will use a Core Duo MacBook with French azerty keyboard (as I do). If you do use this keyboard, you will have to adapt the following setting to your needs. And if you use a Core 2 Duo MacBook, there are some some settings to change.

  1. Download FreeBSD CD ISO image. At least you'll 6.7 version. There are many available images:
    • disk 1 for system installation
    • disk 2 (optional) for application installation
    • disk 3 (optional) for application installation
    • “livefs” to run FreeBSD from the CD-ROM (useful for repairs)
    • “bootonly” for network installation (only with Ethernet adapter, not WIFI).
  2. Burn on a blank CD-R FreeBSD installation disk.
  3. Install Boot Camp. When it's done, start it up, don't burn driver disk (it's only for Windows, and you want to install FreeBSD). Then create a new partition for FreeBSD. It's size should be about 10 or 15 GB (choose as you want, more or less, you're the boss).

Back to table of contents

Hardware configuration

In order to set up your system, it may be useful to know your hardware configuration. This chapter will evolve each time I will find anything useful..

  • CPU: Intel Core Duo or Core 2 Duo depending on model, with two cores. An SMP kernel with ACPI support is mandatory if you want to use multi-core.
  • Keyboard: French azerty. You'll need to use Belgian azerty in console mode, with some keyboard shortcuts which are not the same than Mac OS X (use <alt> key). With X.org, if you install specific keymap file, you'll get the same keyboard mapping than Mac OS X (see the related chapter).
  • GPU: i945GM (GMA950). Fully supported.
  • Display: 1280x800. Fully supported with X.org 7.3.
  • Mouse: Depend if you use an USB mouse or the trackpad. Device to use is “/dev/umsX” (X will depend of device detection order). If no mouse is plugged in, the trackpad will use “/dev/ums0”, don't works well with X.org. My Logitech MX 1000 (uses “/dev/ums0”, then the trackpad uses “/dev/ums1”), works great (see the related chapter).
  • Audio: Detected as ICH7 High Definition Audio, fully supported, but I didn't test sound recording. (see the related chapter).
  • Webcam: Detected as generic USB device. It's neither supported by SPCA5xx nor PWCBSD.
  • Firewire: Detected as a Lucent FW322/323 device. It works.
  • Bluetooth: The device is not supporter by standard bluetooth driver, “ng_ubt”. FreeBSD just seems to detect “/dev/ukbd1” and “/dev/ums1” devices. Maybe a generic driver for Bluetooth keyboard / mouse controller.
  • Firewire network adapter: Detected as “/dev/net/fwe0” device. Should work.
  • Ethernet network adapter: Detected as a 88E8053 Yukon PCI-E Gigabit Ethernet controller, fully supported. (see the related chapter).
  • WIFI network adapter: On a Core Duo MacBook, it's an Atheros 5424 adapter. Detected as “/dev/net/ath0”, it works (see the related chapter). On a Core 2 Duo MacBook, it's an Atheros AR5008 chipset which lacks a device driver. So you can't use it.
  • DVD burner: Detected as “/dev/acd0” device. With a kernel modification, it's detected as an SCSI pseudo-device “/dev/cd0”. This SCSI pseudo-device is mandatory in order to use “cdrdao”, “cdrtools” and “dvd+rw-tools” tools (see the related chapter).
  • SATA controller: Intel ICHM7, detected and works.
  • USB / USB2 controller: Intel ICH7, detected and works.
  • Battery: Detected, “battery0” device.

Dmesg is (Core Duo MacBook):

Copyright (c) 1992-2008 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
	The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 7.0-RELEASE #0: Sun Feb 24 19:59:52 UTC 2008
    root@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC
Timecounter "i8254" frequency 1193182 Hz quality 0
CPU: Genuine Intel(R) CPU           T2500  @ 2.00GHz (1997.34-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0x6e8  Stepping = 8
  Features=0xbfe9fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
  Features2=0xc1a9<SSE3,MON,VMX,EST,TM2,xTPR,PDCM>
  AMD Features=0x100000<NX>
  Cores per package: 2
real memory  = 2114781184 (2016 MB)
avail memory = 2059812864 (1964 MB)
ACPI APIC Table: <APPLE  Apple00>
FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
 cpu0 (BSP): APIC ID:  0
 cpu1 (AP): APIC ID:  1
ioapic0: Changing APIC ID to 1
ioapic0 <Version 2.0> irqs 0-23 on motherboard
kbd0 at kbdmux0
ath_hal: 0.9.20.3 (AR5210, AR5211, AR5212, RF5111, RF5112, RF2413, RF5413)
hptrr: HPT RocketRAID controller driver v1.1 (Feb 24 2008 19:59:27)
acpi0: <APPLE Apple00> on motherboard
acpi0: [ITHREAD]
acpi_ec0: <Embedded Controller: GPE 0x17, ECDT> port 0x62,0x66 on acpi0
acpi0: Power Button (fixed)
Timecounter "HPET" frequency 14318180 Hz quality 900
Timecounter "ACPI-fast" frequency 3579545 Hz quality 1000
acpi_timer0: <24-bit timer at 3.579545MHz> port 0x408-0x40b on acpi0
cpu0: <ACPI CPU> on acpi0
est0: <Enhanced SpeedStep Frequency Control> on cpu0
p4tcc0: <CPU Frequency Thermal Control> on cpu0
cpu1: <ACPI CPU> on acpi0
est1: <Enhanced SpeedStep Frequency Control> on cpu1
p4tcc1: <CPU Frequency Thermal Control> on cpu1
acpi_acad0: <AC Adapter> on acpi0
acpi_lid0: <Control Method Lid Switch> on acpi0
acpi_button0: <Power Button> on acpi0
acpi_button1: <Sleep Button> on acpi0
pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
pci0: <ACPI PCI bus> on pcib0
vgapci0: <VGA-compatible display> port 0x20f0-0x20f7 mem 0x90380000-0x903fffff,0x80000000-0x8fffffff,0x90400000-0x9043ffff irq 16 at device 2.0 on pci0
agp0: <Intel 82945GM (945GM GMCH) SVGA controller> on vgapci0
agp0: detected 16124k stolen memory
agp0: aperture size is 256M
vgapci1: <VGA-compatible display> mem 0x90300000-0x9037ffff at device 2.1 on pci0
pci0: <dasp> at device 7.0 (no driver attached)
pci0: <multimedia> at device 27.0 (no driver attached)
pcib1: <ACPI PCI-PCI bridge> irq 17 at device 28.0 on pci0
pci1: <ACPI PCI bus> on pcib1
mskc0: <Marvell Yukon 88E8053 Gigabit Ethernet> port 0x1000-0x10ff mem 0x90200000-0x90203fff irq 16 at device 0.0 on pci1
msk0: <Marvell Technology Group Ltd. Yukon EC Id 0xb6 Rev 0x02> on mskc0
msk0: Ethernet address: 00:16:cb:ce:f9:71 
miibus0: <MII bus> on msk0 
e1000phy0: <Marvell 88E1111 Gigabit PHY> PHY 0 on miibus0
e1000phy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseTX-FDX, auto
mskc0: [FILTER]
pcib2: <ACPI PCI-PCI bridge> irq 16 at device 28.1 on pci0
pci2: <ACPI PCI bus> on pcib2
ath0: <Atheros 5424/2424> mem 0x90100000-0x9010ffff irq 17 at device 0.0 on pci2
ath0: [ITHREAD]
ath0: using obsoleted if_watchdog interface
ath0: Ethernet address: 00:16:cb:be:f8:40
ath0: mac 10.3 phy 6.1 radio 10.2
uhci0: <UHCI (generic) USB controller> port 0x20a0-0x20bf irq 21 at device 29.0 on pci0
uhci0: [GIANT-LOCKED]
uhci0: [ITHREAD]
usb0: <UHCI (generic) USB controller> on uhci0
usb0: USB revision 1.0
uhub0: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb0
uhub0: 2 ports with 2 removable, self powered
uhci1: <UHCI (generic) USB controller> port 0x2080-0x209f irq 19 at device 29.1 on pci0
uhci1: [GIANT-LOCKED]
uhci1: [ITHREAD]
usb1: <UHCI (generic) USB controller> on uhci1
usb1: USB revision 1.0
uhub1: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb1
uhub1: 2 ports with 2 removable, self powered
uhci2: <UHCI (generic) USB controller> port 0x2060-0x207f irq 18 at device 29.2 on pci0
uhci2: [GIANT-LOCKED]
uhci2: [ITHREAD]
usb2: <UHCI (generic) USB controller> on uhci2
usb2: USB revision 1.0
uhub2: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb2
uhub2: 2 ports with 2 removable, self powered
uhci3: <UHCI (generic) USB controller> port 0x2040-0x205f irq 16 at device 29.3 on pci0
uhci3: [GIANT-LOCKED]
uhci3: [ITHREAD]
usb3: <UHCI (generic) USB controller> on uhci3
usb3: USB revision 1.0
uhub3: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb3
uhub3: 2 ports with 2 removable, self powered
ehci0: <Intel 82801GB/R (ICH7) USB 2.0 controller> mem 0x90445400-0x904457ff irq 21 at device 29.7 on pci0
ehci0: [GIANT-LOCKED]
ehci0: [ITHREAD]
usb4: EHCI version 1.0
usb4: companion controllers, 2 ports each: usb0 usb1 usb2 usb3
usb4: <Intel 82801GB/R (ICH7) USB 2.0 controller> on ehci0
usb4: USB revision 2.0
uhub4: <Intel EHCI root hub, class 9/0, rev 2.00/1.00, addr 1> on usb4
uhub4: 8 ports with 8 removable, self powered
ugen0: <Micron Built-in iSight, class 255/255, rev 2.00/1.84, addr 2> on uhub4
pcib3: <ACPI PCI-PCI bridge> at device 30.0 on pci0
pci3: <ACPI PCI bus> on pcib3
fwohci0: <Lucent FW322/323> mem 0x90000000-0x90000fff irq 19 at device 3.0 on pci3
fwohci0: [FILTER]
fwohci0: OHCI version 1.0 (ROM=0)
fwohci0: No. of Isochronous channels is 8.
fwohci0: EUI64 00:16:cb:ff:fe:e4:24:ce
fwohci0: Phy 1394a available S400, 3 ports.
fwohci0: Link S400, max_rec 2048 bytes.
firewire0: <IEEE1394(FireWire) bus> on fwohci0
dcons_crom0: <dcons configuration ROM> on firewire0
dcons_crom0: bus_addr 0x13c4000
fwe0: <Ethernet over FireWire> on firewire0
if_fwe0: Fake Ethernet address: 02:16:cb:e4:24:ce
fwe0: Ethernet address: 02:16:cb:e4:24:ce
fwip0: <IP over FireWire> on firewire0
fwip0: Firewire address: 00:16:cb:ff:fe:e4:24:ce @ 0xfffe00000000, S400, maxrec 2048
sbp0: <SBP-2/SCSI over FireWire> on firewire0
fwohci0: Initiate bus reset
fwohci0: BUS reset
fwohci0: node_id=0xc000ffc0, gen=2, CYCLEMASTER mode
isab0: <PCI-ISA bridge> at device 31.0 on pci0
isa0: <ISA bus> on isab0
atapci0: <Intel ICH7 UDMA100 controller> port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0x20c0-0x20cf irq 18 at device 31.1 on pci0
ata0: <ATA channel 0> on atapci0
ata0: [ITHREAD]
ata1: <ATA channel 1> on atapci0
ata1: [ITHREAD]
atapci1: <Intel ICH7M SATA300 controller> port 0x20d8-0x20df,0x20fc-0x20ff,0x20d0-0x20d7,0x20f8-0x20fb,0x2020-0x202f mem 0x90445000-0x904453ff irq 19 at device 31.2 on pci0
atapci1: [ITHREAD]
ata2: <ATA channel 0> on atapci1
ata2: [ITHREAD]
ata3: <ATA channel 1> on atapci1
ata3: [ITHREAD]
pci0: <serial bus, SMBus> at device 31.3 (no driver attached)
battery0: <ACPI Control Method Battery> on acpi0
pmtimer0 on isa0
ppc0: parallel port not found.
sc0: <System console> at flags 0x100 on isa0
sc0: VGA <16 virtual consoles, flags=0x300>
sio0: configured irq 4 not in bitmap of probed irqs 0
sio0: port may not be enabled
sio0: configured irq 4 not in bitmap of probed irqs 0
sio0: port may not be enabled
sio0 at port 0x3f8-0x3ff irq 4 flags 0x10 on isa0
sio0: type 8250 or not responding
sio0: [FILTER]
sio1: configured irq 3 not in bitmap of probed irqs 0
sio1: port may not be enabled
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
ukbd0: <Apple Computer Apple Internal Keyboard / Trackpad, class 0/0, rev 2.00/0.64, addr 2> on uhub0
kbd1 at ukbd0
ums0: <Apple Computer Apple Internal Keyboard / Trackpad, class 0/0, rev 2.00/0.64, addr 2> on uhub0
ums0: 3 buttons.
uhid0: <Apple Computer Apple Internal Keyboard / Trackpad, class 0/0, rev 2.00/0.64, addr 2> on uhub0
uhid1: <Apple Computer, Inc. IR Receiver, class 0/0, rev 2.00/1.10, addr 2> on uhub2
ukbd1: <vendor 0x05ac product 0x1000, class 0/0, rev 2.00/19.65, addr 2> on uhub3
kbd2 at ukbd1
ums1: <vendor 0x05ac product 0x1000, class 0/0, rev 2.00/19.65, addr 2> on uhub3
ums1: 5 buttons.
Timecounters tick every 1.000 msec
hptrr: no controller detected.firewire0: 1 nodes, maxhop <= 0, cable IRM = 0 (me)
firewire0: bus manager 0 (me)

acd0: DVDR <MATSHITADVD-R UJ-857/HBEA> at ata0-master UDMA66
ad5: 57231MB <TOSHIBA MK6034GSX AH105B> at ata2-slave SATA150
GEOM_LABEL: Label for provider ad5p1 is msdosfs/EFI.
WARNING: Expected rawoffset 0, found 84295720
SMP: AP CPU #1 Launched!
Trying to mount root from ufs:/dev/ad5s3a
GEOM_LABEL: Label msdosfs/EFI removed.

Back to table of contents

System installation

When the destination partition created by Boot Camp Assistant, reboot your MacBook, and let <alt> key pressed to get the boot menu. Select CD-ROM (with “Windows” label) to start FreeBSD installation. While installing FreeBSD, you may refer to online handbook, very well documented. In any case, you may follow theses instructions:

  1. At boot menu, choose default startup, validating your choice with <Enter>.
  2. At country selection, choose “France”. This choice will impact default character set for all users on installed system.
  3. At keyboard layout selection, choose “Belgian”. It the closer keyboard layout from French mac azerty layout.
  4. At next menu, choose “Custom Install”.
  5. Choose “Partition” in order to create a slice for FreeBSD.
  6. While creating slice for FreeBSD, you must convert (<T> key) the slice with “FAT” created by Boot Camp to FreeBSD format (number 165), then set it bootable (<S> key). Leave this screen (<Q> key). Then choose a “Standard” boot manager (second choice into the list).
  7. Choose “Label” in order to create mount points. Auto mode (<A> key) should be good. Leave this screen (<Q> key).
  8. Choose “Distributions”, then “Kern-Developer” (system sources will be useful). When the installer asks if you want to install ports tree, answer “Yes”, then “Exit”.
  9. Choose “Media”, then “CD/DVD”.
  10. Finally, choose “Commit” to start FreeBSD installation.

When the files are copied on the hard drive, you will be asked if you want to perform post-installation tasks. You should accept. I follow these steps:

  1. “Root password”: set root password.
  2. “User management”, then “User”: create a user without administration rights. For all users you create, replace shell “/bin/sh” by “/bin/csh”. When all users are created, choose “Exit” to come back to previous menu.
  3. “Time zone”: choose the time zone. You will be asked if the CMOS clock is set to UTC time: choose “Yes”, then your time zone.
  4. “Console” then
    • “Font”: choose “ISO 8859-15”
    • “Repeat”: choose “Fast” (it's repetition speed when you leave a key pressed).
    • “Exit” to go out “Console” menu.
  5. “Networking” then
    • You may choose network services you want into this menu.
    • “Interface”: network interface setting. As only WIFI adapter is detected (“ath0”), and you can't choose network to connect and wireless security mode while installing FreeBSD, this step may be forgotten. But if you want to connect to network through Firewire adapter (“fwe0”), you may set up TCP/IP settings here.
    • “sshd”: if you want to run SSH daemon at machine startup.
    • “Exit” to come back to previous menu.
  6. “Startup” then
    • You may choose various startup settings here.
    • “Quotas”: I disable user quotas setup. You may leave it if you want.
    • “Exit” to go out “Startup” menu.
  7. “Exit” to go out post-installation tasks menu.
  8. “Exit” to come back to initial menu.
  9. “Exit Install” to reboot computer.

Back to table of contents

FreeBSD use, and detailed setup

In order to boot FreeBSD, you have to select startup disk while booting computer. For this, leave <Alt> key pressed. Startup disk has “Windows” label, even is an other exploitation system than Microsoft's one is installed.

When the system is up, serious things begin. Now, log in with “root” user.

Back to table of contents

Keyboard

Belgian layout is the closer layout to mac French azerty layout, but without being identical. Some character are not at the same place, or need keyboard shortcuts.

< : <@>
> : <#>
| : <alt>+<1>
@ : <alt>+<2>
# : <alt>+<3>
{ : <alt>+<9>
} : <alt>+<0>
[ : <alt>+<^>
] : <alt>+<shift>+<$>
` : <alt>+<`>
~ : <alt>+<=>

With X.org, all Mac OS X shortcuts are available if you install some patches described into X.org section.

Back to table of contents

Network setup

Firewire network connection

I could not test, then I don't know if it works. As the adapter is detected, it should works flawlessly. If someone could try, he may leave me comment.

Ethernet network connection (FreeBSD device driver)

You may set up the driver to use DHCP or fixed IP address.

For DHCP, edit file “/etc/rc.conf” and add the following line:

ifconfig_msk0="DHCP"

For fixed IP address, edit file “/etc/rc.conf” and add the following lines:

defaultrouter="<gateway_ip>"
ifconfig_rl0="inet 1<ip_address> netmask <subnet_mask>"

Then, reboot your computer to apply changes.

WIFI network connection (Core Duo models only)

For network settings, let say you will connect to WIFI network, using WPA/WPA2 security settings and DHCP. For other settings, see online handbook.

Then, you must set up FreeBSD to connect to the correct WIFI network, using the correct password. There are two steps. First, modify “/etc/rc.conf” file and add the following line:

ifconfig_ath0="WPA DHCP"

This line is used to use WPA mode, with DHCP IP attribution, on “ath0” adapter.

WPA settings are into “/etc/wpa_supplicant.conf” (create it). You have to add the following lines:

network={
    ssid="your_ssid"
    key_mgmt=WPA-PSK
    psk="your_key"
}

“your_ssid” is the WIFI network name to connect.
“your_cle” is the connection key of this network.

You may now reboot MacBook which will connect to your WIFI network.

Back to table of contents

System update and build

In order to track system updates (better from a security and feature focus), you follow the -STABLE branch of FreeBSD 7.x. This how-to itself consider it's the case. If you don't, some features may be unavailable. For this, you'll have to follow these steps.

First, create a “/opt/” and a “/opt/data/” folder. Into the “/opt/data/”, copy file “/usr/share/examples/cvsup/standard-supfile”. Then apply the following changes to it: replace line “*default host=CHANGE_THIS.FreeBSD.org” by “*default host=cvsup2.fr.FreeBSD.org” (replace “cvsup2.fr.FreeBSD.org” by the nearest mirror), and replace line “*default release=cvs tag=RELENG_7_0” par “*default release=cvs tag=RELENG_7” (it is possible that the first to be slightly different, but the result must be the one given).

Then get the file named “FreeBSD sources update script”, copy it to “/opt/update_src.sh” and give it execution rights.

Then execute this script. It will update system sources.

When the source files are updated, go into folder “/usr/src/sys/i386/conf” and copy the file “GENERIC” to another name, i.e. “MYCOMPUTER” (don't forget this name, it will be used later). Modify this file and replace the line

ident           GENERIC

by

ident           MYCOMPUTER

then add the following lines (at the end of file)

options         CPU_SUSP_HLT                # Enable HLT instruction when the CPU is idle. The laptop will be cooler and use less energy.
options         CPU_UPGRADE_HW_CACHE        # Disable useless cache flush. Performances may be enhanced.
options         DEVICE_POLLING              # Enable compatible network adapter polling. Performances may be enhanced.
options         ZERO_COPY_SOCKETS           # Enable network transfers without useless copies. Performances may be enhanced.
device          drm                         # Enable graphic acceleration (base support).
device          i915drm                     # Enable graphic acceleration (i945GM support).
device          atapicam                    # Enable ATA drives access through an SCSI sub-system.
device          sound                       # Enable sound support (base support).
device          snd_hda                     # Enable Intel ICH7 High Definition Audio support

You must perform the copy and modify step each time you update system sources.

Then modify the file “/etc/make.conf”, and give it the following content

CPUTYPE?=prescott
CFLAGS= -O2 -fno-strict-aliasing -pipe
COPTFLAGS= -O -pipe
NO_PROFILE=true
KERNCONF=MYCOMPUTER

“Prescott” CPUTYPE enable SSE3 support while compiling (“pentium-m” CPUTYPE doesn't have SSE3 support even if closer to Core Duo architecture than “prescott”). If you own a Core 2 Duo MacBook, you should use “nocona” (in order to enable 64 bit support).

Now, create or modify the file “/etc/rc.local” and add the following line:

/sbin/ifconfig ath0 polling

This line enable the polling mode on WIFI adapter. For now, it's not supported but it may be later. So you may add this line now.

If you use FreeBSD Ethernet adapter driver, you may add the following line:

/sbin/ifconfig msk0 polling

If you use the Firewire network, you may add the following line:

/sbin/ifconfig fwe0 polling

Then get to the file named “FreeBSD update script (01)”, copy it to “/opt/build_freebsd_01.sh]” and give it execution rights.

This script will:

  1. Clean “/usr/obj”, which contains all temporary files from previous system compilation.
  2. Modify if necessary configuration files with mergemaster tool.
  3. Build the system
  4. Build the kernel and all modules
  5. Install the kernel and modules

System, kernel and modules build and installation take about 30 minutes on 2 GHz Core Duo MacBook.

Then get to the file named “FreeBSD update script (02)”, copy it to “/opt/build_freebsd_02.sh]” and give it execution rights.

This script will:

  1. Mount filesystems and activate swap
  2. Install the new system
  3. Modify if necessary configuration files with mergemaster tool.
  4. Reboot the computer

In order to build the system, you need to follow these steps:

  1. Update sources with “/opt/update_src.sh”
  2. Execute the installation first part with “/opt/build_freebsd_01.sh”
  3. Reboot computer in single user mode (option #4 at startup menu)
  4. Execute the installation first part with “/opt/build_freebsd_02.sh”

Back to table of contents

Power management

When we use a laptop, we try to get the longest autonomy, and try to keep it cool (in order to keep fans stopped, which use power to run). A first step in this direction is to enable “CPU_SUSP_HLT” option into the kernel. This instruction put the CPU into idle state, where it uses less energy.

Another possible option is to activate “powerd”. This daemon uses ACPI in order to adapt CPU frequency to the needs. On a MacBook 2 GHz, frequency automatically goes from 125 MHz to 2 GHz (of course with many steps between). In order to enable ”powerd”, you must add the following lines into “/etc/rc.conf” file:

powerd_enable="YES"
powerd_flags="-a adaptive -b adaptive"

The reboot the computer or execute “/etc/rc.d/powerd start” in order to apply changes.

You can get the CPU frequency (MHz) with the following command line:

sysctl dev.cpu.0.freq

Other economy saving modes may be possible, i.e. deep sleep when we close the need, but I don't know how to enable it. When I'll have of the needed information, I'll update this chapter

Back to table of contents

Ports management

If you want to install software on FreeBSD, you should use port tree. A “port” is a set of information saying where to download software sources, how to build and install it, then manage all dependencies. In order to easily manage these ports, it's useful to install “portupgrade”. For this, follow these instructions:

Into the “/opt/data/”, copy file “/usr/share/examples/cvsup/ports-supfile”. Then apply the following changes to it: replace line “*default host=CHANGE_THIS.FreeBSD.org” by “*default host=cvsup2.fr.FreeBSD.org” (replace “cvsup2.fr.FreeBSD.org” by the nearest mirror),

Then get the file named “FreeBSD Ports update script”, copy it to “/opt/update_ports.sh” and give it execution rights.

Execute this script. It will update ports tree. The two last commands will fail, but it's not important at the moment (“portsdb” and “portversion” are parts of “portupgrade” which is not installed).

Then go into “/usr/ports/ports-mgmt/portupgrade/”, then execute “make install clean”. The system will install portupgrade and all its dependencies. Execute “rehash” in order to refresh available commands list, nd you're ready to use portupgrade. It has many parts:

  • “portinstall” installs an port and its dependencies. I.e., “portinstall vim” will install “vim”.
  • “portsdb” manage ports database (the one used by portupgrade). “portsdb -F” (used into the above script) update available ports list.
  • “portversion” checks ports versions. “portversion -vl '<'” (used into the above script) list all installed ports and with an available update.
  • “pkg_info“ give information on ports. Without parameter, it list all installed ports. “pkg_info -L a_port” lists all files installed with a port.
  • “portupgrade” upgrade an installed port. “-a” parameter upgrade all ports with an available update.
  • “pkg_deinstall“ uninstall a port.

Of course, man pages will give you all available options.

The above script updates ports tree, available ports database, and display all ports with an available update.

If you want to use configure and build option for ports, you have to available methods:

  1. “/etc/make.conf“: these build options will be available for all ports.
  2. “/usr/local/etc/pkgtools.conf”: these build options may be specified for a given port. This method is only available with portupgrade (and the associated tools).

Back to table of contents

CD / DVD burn, and how-to eject them

CD-R burn

You have two ways to burn CD-R.

  • “burncd”. This tool is a part of base system, and allow you to use ATAPI burners. Each of my attempts was apparently successful, but I was unable to mount the freshly burnt CD-R.
  • “cdrecord”. This tool must be installed via ports tree. As it needs an SCSI burner, you'll have to use “/dev/cd0” device instead of “/dev/acd0”. With this tool, I could successfully burn and mount my CD-R.

If you want more information about CD-R burn, you can find it into the online handbook.

DVD burn

You don't have any choice, you'll have to use “dvd+rw-tools” (install it via port tree) and “/dev/cd0” device. DVD burn and mount where all successful.

If you want more information about DVD burn, you can find it into the online handbook.

This have nothing to do with media burning, but if you want to eject your CD or DVD don't forget to install the port “eject”.

Back to table of contents

Audio

MacBook's audio device is an ICH7 using HDA norm, and not AC97.

While booting the system, you may see the following lines into “dmesg”:

pcm0: <Intel 82801G High Definition Audio Controller> mem 0x90440000-0x90443fff irq 22 at device 27.0 on pci0
pcm0: [ITHREAD]
pcm0: <HDA Codec: Sigmatel STAC9221>
pcm0: <HDA Driver Revision: 20071129_0050>

If you execute “cat /dev/sndstat”, you may get the following line:

FreeBSD Audio Driver (newpcm: 32bit 2007061600/i386)
Installed devices:
pcm0: <Intel 82801G High Definition Audio Controller> at memory 0x90440000 irq 22 kld snd_hda [20071129_0050] [MPSAFE] (1p:1v/1r:1v channels duplex default)

Sound is now available, you may check it with your favorite media player. The only thing I could not test is sound recording. And as I don't have an optical audio cable, I could not test related input and output.

Back to table of contents

X.org setup

Before X.org installation, you must disable “moused”. Modify the file “/etc/rc.conf” and add the following lines:

moused_enable="NO"
moused_nondefault_enable="NO"
moused_ums0_enable="NO"
moused_ums1_enable="NO"
moused_ums2_enable="NO"

then kill all “moused” running process:

killall moused

Install X.org with:

portinstall xorg

You'll have to wait for about one hour. When X.org is installed, you'll have to set it up. Execute “xorgconfig” and answer to many questions.

Mouse setup

You will have to use “Auto” mouse protocol. As the trackpad doesn't work well (instable mouse pointer, absolute positionning between display and trackpad surface), you have to use an USB mouse.
When you're asked if you want to emulate 3 buttons, answer “n”.
When you're asked which device to use, you may have to answer “/dev/ums0”. Adapt to your real needs.

Keyboard setup

Use “MacBook/MacBook Pro (Intl)” (121) layout.
Country is “France” (29).
No layout variant, just validate with “Enter”.
XKB option, answer “n”.

Screen display

Answer “10” to question about horizontal refresh.
Answer “4” to question about vertical refresh.
Identifier should be “MacBook LCD”.

Graphic card setup

When you're asked if you want to parse graphic cards list, answer “y”.
The graphic controller to use is “i810” (16).
Installed memory is “65536K” (9).
Identifier should be “GMA950”.
Leave modes as is (answer “4”).
Default mode will be 24 bits (answer “5”).

When you're asked if you want to write “/etc/X11/xorg.conf” file, answer “y”.

Post-configuration: keyboard setup

Identical keyboard mapping to Mac OS X

Finally, download the file “http://bersace03.free.fr/pub/Linux/xkb-mac/fr.ancien”, and copy it into folder “/usr/local/share/X11/xkb/symbols/macintosh_vndr/” with name “fr” (remove “.ancien” extension).

Now you have a working French azerty keyboard with X.org. But if you reinstall X.org, you may have to repeat the above step.

Nearly identical keyboard mapping to Mac OS X

Another possibility is to have a nearly identical keyboard mapping to Mac OS X: <alt> becomes “Windows” <alt>, <ctrl> key becomes “Windows” <ctrl>, left <cmd> key becomes “Windows” <menu>, and small <enter> key (next the right <cmd> key) becomes “Mac OS X” <alt> key (for special characters keyboard shortcuts).

This mapping is the X.org default one.

Post-configuration: graphic card

We'll add graphic acceleration. It need two things: a kernel driver (which supports i945GM device), and an X.org driver (which supports i945GM device too).

You have to modify the file “/etc/X11/xorg.conf”.
Uncomment the following lines:

Load       "glx"
Load       "dri"
Section "DRI"
    Mode 0666
EndSection

Modify “Screen” section with “GMA950” identifier. Add the following lines:

Option	"DRI"	"True"
Option	"NoAccel"	"False"

After patch installation, I got these results:

Into X.org log file :

(II) [drm] DRM interface version 1.2
(II) [drm] DRM open master succeeded.
(II) intel(0): [drm] Using the DRM lock SAREA also for drawables.
(II) intel(0): [drm] framebuffer handle = 0x80040000
(II) intel(0): [drm] added 1 reserved context for kernel
(II) intel(0): [drm] installed DRM signal handler
(II) intel(0): [drm] Registers = 0x90380000
(II) intel(0): [drm] ring buffer = 0x80000000
(II) intel(0): [drm] init sarea width,height = 1280 x 1280 (pitch 2048)
(II) intel(0): [drm] Mapping front buffer
(II) intel(0): [drm] Front Buffer = 0x80040000
(II) intel(0): [drm] Back Buffer = 0x84000000
(II) intel(0): [drm] Depth Buffer = 0x85000000
(II) intel(0): [drm] textures = 0x88000000
(II) intel(0): [drm] Initialized kernel agp heap manager, 33554432
(II) intel(0): [drm] dma control initialized, using IRQ 16
(II) intel(0): [drm] removed 1 reserved context for kernel
(II) intel(0): [drm] unmapping 8192 bytes of SAREA 0xc7d50000 at 0x287ee000
(II) intel(0): [drm] Closed DRM master.
Issues

X.org does not support the trackpad. “synaptics” device driver only works with PS/2 trackpad (“psm” device driver), then MacBook trackpad is unusable (it's a USB one, then use “ums” device driver).

Back to table of contents

Désinstaller FreeBSD

Issues coming from FreeBSD installation

FreeBSD install modifies partition table format. It's still GPT, but Mac OS X recognize it as an MBR partition table, which give the following issues:

  • When FreeBSD is installed and you don't want to use it anymore, you won't be able to undo Boot Camp changes.
  • You won't be able to install EFI firmware upgrades. the only ways are : boot from an external harddrive using GPT and where Mac OS X is installed, then upgrade your firmware or uninstall FreeBSD.

If you boot a FreeBSD install disk, start “Live Filesystem”, and execute “gpt show /dev/ad5”, you will see the disk uses GPT format. And if you try a “gpt migrate /dev/ad5” it will fail because the disk uses GPT format.

I tried to repair GPT with rEFIt “gptsynch” tools, but data seems to be too inconsistent to be repaired. FreeBSD/i386 sysinstall have to support GPT disks, but for now only FreeBSD/ia64 sysinstall does (Intel Itanium CPU version).

It's possible to uninstall FreeBSD without need to partition again your harddrive and install again Mac OS X, but it's not easy.

First step : FreeBSD partition removal

In order to cleanly remove FreeBSD partition, you need an Ubuntu Live CD, at least version 7.04. Boot from Ubuntu CD, then when desktop is available, open a “Terminal” session, and execute the following command:

sudo parted

When GNU parted is started, follow these steps:

  • execute « print », and look for FreeBSD partition number (it should be “3”).
  • execute « rm <partition_number> », where <partition_number> is the above number.
  • execute « quit ».

Finally, reboot to Mac OS X.

Second step : Mac OS X partition restore

Now, you just have to restore Mac OS X partition to its original state. Start Boot Camp assistant, skip the "Burn a Macintosh Drivers CD" step and split your disk into two volumes as instructed by Boot Camp Assistant. The actual sizes of the volumes don't matter. When the disk is splitted, reboot your laptop.

Start Boot Camp, and choose the "Restore to a single Mac OS partition" option. Reboot, et voilà, FreeBSD is now cleanly uninstalled.

If you use Mac OS X 10.5.x, you may simply extend your system partition with disk utility instead of using Boot Camp.

Back to table of contents

Miscellaneous issues

  • Sometimes after FreeBSD installation, the computer may not be able to find Mac OS X partition. In this case, restart the computer leaving <Alt> key pressed and choose Mac OS X partition. Then, execute “System Preferences”, chose “Startup disk”, then Mac OS X partition. All will the OK for the next reboots.
  • Sometimes you can't reboot or switch off the laptop; the screen goes blank, the the laptop still runs (you can feel harddrive's vibrations if you put on hand to the left of the trackpad). The only way to switch off the laptop is to leave the power button pressed until you can't feel harddrive's vibrations anymore.

Back to table of contents

More info

Some points are not covered by this how-to, but they are on a dedicated wiki : http://wiki.freebsd.org/AppleMacbook. You will find how to use Bluetooth, IR receiver, etc.

Back to table of contents