File:  [NetBSD Developer Wiki] / wikisrc / tutorials / how_to_install_netbsd_on_an_apple_macbook_with_core2duo.mdwn
Revision 1.10: download - view: text, annotated - select for diffs
Thu Feb 15 01:55:26 2018 UTC (3 years, 11 months ago) by sevan
Branches: MAIN
CVS tags: HEAD
swap leading tab with spaces as originally set. fight up markdown

    1: [[!meta title="How to install NetBSD on an Apple Macbook with Core 2 Duo"]]
    3: **Contents**
    5: [[!toc]]
    7: #Things you DO NOT want to do
    9: * Do **not** try using i386 NetBSD before 4.0. It'll install, but the minute you put any kind of load on the machine (like compiling stuff from pkgsrc) the machine will die with a kernel panic. Most of what has been tried in this howto was done using the amd64 release 4.0. 
   10: * Do **not** try installing the amd64 port for the 3.1 release. The drivers are too old for this machine and you'll be lucky to get through the installation before it crashes. 
   11: * Do **not** install the NetBSD bootselect code when you are doing the installation. Answer "NO" to that question during installation. Otherwise you could wipe out the rEFIt loader along with any way to boot the machine. You'll either end up reloading OS X from scratch or trying to recover with a lot of black magic on the EFI shell. 
   12: * Do **not** try using LFS on a partition that has even a moderate amount of I/O going on it. Your machine will panic until your remove the LFS venom from it's veins. Stick with UFS1 + softdep at least until 4.0 comes out. (UFS2 + log should work on 5.0 and -current). 
   13: * Do **not** just compile the meta package for xorg without first setting your options in such a way that you'll get the i810 server installed properly or you'll waste a bunch of time recompiling later. UPDATE: this maybe fixed in pkgsrc-2008Q4 so maybe you can just set "X11_TYPE=modular" in /etc/mk.conf and compile all the meta xorg packages from pkgsrc/meta-pkgs/xorg-* . For recent versions of current, try setting X11FLAVOUR=Xorg and X11_TYPE=modular in /etc/mk.conf to get both native and package (modular) Xorg. 
   14: * Do **not** try to use XFree86 -- it will probably fail. 
   16: # What works and what doesn't
   18: ## Known to work
   20: * SATA disk drivers
   21: * Core2Duo processor (it still crashes, but the amd64 much less often than the i386 port)
   22: * i810 Graphics (Intel 945GM chip) and the LCD panel (with some help from the "915resolution" application)
   23: * NVIDIA GeForce graphics (with resent Xorg).
   24: * Keyboard
   25: * Touchpad (but no synaptic extensions, so it sucks)
   26: * IEEE1394 interface (shows up, but I've never used it)
   27: * USB 2.0/1.0
   28: * CDRW/DVDRW
   29: * Marvell Gigabit Ethernet
   30: * Automatic (ACPI?) fan control (ie.. you won't fry your macbook installing NetBSD) 
   32: ## Known not to work
   34: * Apple iSight Camera (Should work in 5.0 and -current post Nov 1. 2008). For now it's simply "not configured"
   35: * Internal Atheros 802.11g interface. Might work in 5.0
   36: * Internal Broadcom BCM43xx 802.11b/g interface (found in some models). Should work in a near future -- it is supported by DragonflyBSD and OpenBSD.
   37: * The internal accelerometer.
   38: * The infrared remote control (actually it might work via "xev" and a window manager like fluxbox)
   39: * The external DVI (might work, with newer Xorg but broken at the moment)
   40: * Sound (audio0 shows up but you can't really use it due typical netbsd azalia problems). ** UPDATE sound kind of works in 4.0 and probably fully in 5.0/-current however you'll need to jack with all the values you see from "mixerctl -a" before you'll hear anything. Start by Unmuting everything and maxing out all the values, then turn it down from there. 
   42: # Gathering What you'll need 
   44: Before you get started, let's get straight what you have and what you'll need.
   46: * A MacBook with a Core2Dual CPU (use i386 for the older CoreDuo Macbooks) (non-pro - I don't know if any of this works with the Pro model). I am totally unsure about the Macbook Pro. There wasn't one available to test as this document was assembled. UPDATE: Macbook Pro should work fine, but some of the hardware, for example graphics cards and internal 802.11 interfaces, might be completely different.
   47: * Mac Mini's also seem to work with largely this advice.
   48: * A -current version of NetBSD for the "amd64" architechture (i386 versions will crash under a small bit of load on the Macbook). I used 200705170002Z from I've noticed that netbsd-4 beta snapshots seem to work fine, as well (as long as they are amd64 architechture).
   49: * A CDRW or CDR with the "boot.iso" file burned on it from the NetBSD distribution mentioned above. I used an FTP based install, so there was no need to burn the whole distribution onto my CDRW. It helps to have a local FTP, NFS, or HTTP server with the binary sets on them if you want a fast install process.
   50: * A working, ethernet-based connection to the Internet (or localnet with cached install sets) or a known-good USB-based wifi adapter.
   51: * A copy of rEFIt to use as a primary bootloader. Get it at If you already have MacOS X installed, I'd suggest getting the disk image (dmg) version. It has a GUI-based installer that works with MacOS. 
   53: # Boot Loaders
   54: A (U)EFI boot loader is required to transfer control to a target operating system at boot time.  As of this writing, there are two boot loaders in use for NetBSD and Linux setups on Macintosh computer's: rEFIt, and a more recent fork of rEFIt named rEFInd.
   56: ## Using rEFIt
   58: First grab a copy of rEFIt from <> and install it. The DMG-based installer is one good option but you can also create a bootable CDROM that'll assist in installing it if for some reason you don't have OSX anymore. If you choose the CDROM installation method, you'll need to download the ISO image instead of the DMG from the refit site The rEFIt program is basically like an EFI-based GRUB or LILO which gives you a slick-looking bootloader that'll allow you to choose between your various Mac partitions and the OS's that live on them. It's still necessary to install a secondary bootloader for each individual OS. Because of limitations on ancient MSDOS partition tables you'll only be able to have 3 OS's on your machine (the EFI firmware takes up a partition, too).
   60: While in OSX, open a terminal and do:
   62:     cd /efi/refit/ ; ./
   64: You may also wish to edit /efi/refit/refit.conf to uncomment the Legacy section in case you want NetBSD to boot automatically. You might also choose to change the rEFIt timeout to something less than 20 seconds.
   66: Afterwards rEFIt comes up before the Apple boot loader and you have a nice set of colorful icons representing my partitions. Before I made space for NetBSD, I could see my OS X and Windows partitions and use rEFIt to boot either one. rEFIt must do some kind of BIOS emulation, because any kind of bootable CDROM also shows up in the rEFIt menu if it's in the drive as the system is powered on. You can boot any PC operating system, but very very few are going to get very far on this newfangled hardware. Fortunately, NetBSD -current amd64 can boot just fine.
   68: ## Using rEFInd
   69: TBD
   71: # Creating a new partition for NetBSD
   73: There are two ways to do this. The GUI way and the CLI way. The GUI way is probably easier for beginners, but I'm guessing that if you want to install NetBSD -current on your MacBook you aren't a beginner. If you want to use the GUI, then you'll need to install bootcamp. For Mac OS X (10.4) you can download a beta-version of bootcamp for free from Apple's site. It's usually found here <> but it's in beta, so it could go away any time. If you haven't already ran the "boot camp assistant" you can use this tool to resize your OSX partition and split it up ala PartitionMagic. If you already have a Windows partition you've created with boot-camp, you won't be able to use Boot Camp Assistant again. You'll have to do it from a terminal.
   75: Here is how:
   77: First do this to get a list of your current partitions **diskutil list**
   79: Now decide which partition you want to be your NetBSD parition, and do **not** pick the EFI partition (you need that). I choose to use partition 4 on my macbook since 1==EFI, 2==OSX, and 3==WinXP.
   81: (assuming you have an 80Gb disk and you want )
   83:     sudo diskutil resizeVolume disk0s2 32G "Linux" <name of NetBSD volume> 21G "MS-DOS FAT32" <name of windows volume> 21G
   85: This operation only changes your partition layout to include a 32GB OS X partition, 21GB Linux one and 21GB Windows partition. We'll change the Linux tag to NetBSD once we get into the NetBSD installer. The diskutil command above was shameless lifted from the Gentoo Linux wiki on installing their distro on the MacBook, but it works.
   87: # Installing NetBSD -current
   89: As mentioned above you'll need a -current release of NetBSD for the AMD64 architecture (Intel licensed the AMD64 instructions and re-named them to hide their shame at having the Itanic rejected by Microsoft). If you use the i386 port, you can expect to have major problems; so don't say you weren't warned. I guess if you have a CoreDuo Macbook (not the Core2Duo) you might want to give i386 a shot, but that's not what this document intends to cover. Once you have the "boot.iso" from "amd64/installation/cdrom' properly burned onto a CDR then put it into your system's drive and restart. rEFIt will detect the bootable disk and there will be an icon with a little CD picture on it showing you the disk as a boot option. Go ahead and select it, then let it boot up. Do the installation as usual but remember do not **install the mbr bootselect code!**. NetBSD will automatically install it's stage2 loader on the partition you select and rEFIt will transfer control to that paritition when you select it from the menu (it'll show up automatically as rEFIt probes your partitions prior to showing the initial menu). Once you reboot there is more fun on the way. If you use the boot.iso file to create your CDROM and didn't put any of the tarball "sets" on the CDROM, you'll have to get them over the network via http or ftp. One option is to go to another, working, machine and write down the full path on the FTP site to the directory right before the 'amd64' directory. For example: <> . Your milage my vary. Refer to the regular NetBSD handbook if you need help with the installation. There is nothing too special about it other than a little extra hassle if you use the network.
   91: # Installing on dk(4) wedges
   93: If the install kernel (or the installed kernel, with different symptoms) was compiled with dk(4) support (and gpt-autodetection) -- that is if the kernel configuration included
   95:     options DKWEDGE_AUTODISCOVER
   96:     options DKWEDGE_METHOD_GPT
   98: as the recent install kernels do, and you plan to have both OS X and NetBSD on the same disk, you have to do the installation by hand. Since you need GPT partitions for rEFIt and OS X, dk(4} wedges will be added for them. Since the disk can only be accessed via wedges once at least one wedge has been added, and sysinst(8) does not know about wedges, the installation will fail with a `device busy' when sysinst tries to newfs(8) the NetBSD partition(s).
  100: Fortunately, it is not hard to do the installation by hand. The following example assumes that you are installing from a cd, that you want to have just OS X and NetBSD on the disk (a NetBSD-only installation is easy; other installation media or a third operating system work analogously), that you are installing amd64, and that OS X is already installed on an HFS+ partition. The example uses a 200GB disk, with roughly half for the EFI and HFS+ partitions for rEFIt and OS X, and roughly half for the NetBSD partitions. Please make sure that you understand the starting sectors and sizes in the examples below before you try to mimic them.
  102: * Install rEFIt as described above.
  103: * Decrease the size of the HFS+ partition using the graphical Disk Utility or the command-line diskutil(8) from OS X (the graphical interface is found from Applications -> Utilities -> Disk Utility in recent versions of OS X). It is easiest to leave empty space for NetBSD and not create a partition at this stage.
  104: * Boot the installation cd. Exit sysinst (or choose `run /bin/sh').
  105: * Create the drvctl(4) device and enough [r]dk(4) devices: 
  107:         cd /dev && sh MAKEDEV drvctl dk7
  109: * Mount a memory-mapped file system, untar at least the base set on it, and add the relevant directories to your paths: 
  111:         mount_mfs -s512m swap /mnt
  112:         mount -r -t cd9660 /dev/cd0a /mnt2
  113:         cd /mnt && tar xzpf /mnt2/amd64/binary/sets/base.tgz
  114:         cd /dev ; tar cf - . | (cd /mnt/dev ; tar xvpf - )
  115:         chroot /mnt
  117: * Use gpt(8) (/sbin/gpt) to edit the GPT partition table. Assuming your disk is wd0, 
  119:         gpt show wd0
  121:     should show something like
  123:                       start      size   index  contents
  124:                           0         1          MBR
  125:                           1         1          Pri GPT header
  126:                           2        32          Pri GPT table
  127:                          40    409600       1  GPT part - EFI System
  128:                      409640 195360984       2  GPT part - Apple HFS
  129:                         ... 
  130:                   390721935        32          Sec GPT table
  131:                   390721967         1          Sec GPT header
  133: * Add an FFS partition and a 4GB swap partition by: 
  135:         gpt add -b 195770624 -i 3 -s 186562702 -t ffs wd0
  136:         gpt add -b 382333327 -i 4 -s 8388608 -t swap wd0
  137:         gpt label -i 3 -l "NetBSD-root" wd0
  138:         gpt label -i 4 -l "NetBSD-swap" wd0
  140: * Dynamically add the relevant wedges using dkctl(8). The output of gpt add should show you the needed parameters (you can use ffs and swap, respectively, for the types). 
  142:         dkctl wd0 delwedge dk2
  143:         dkctl wd0 addwedge NetBSD-root 195770624 186562702 -t ufs
  144:         dkctl wd0 addwedge NetBSD-swap 382333327 8388608 -t swap
  146:     Alternatively, you can reboot the installation cd, since the GPT partitions will be detected automatically.
  147: * Edit the MBR table using fdisk(8) (fdisk -u wd0). Once you are done, the MBR table should look something like 
  149:         0: GPT Protective MBR (sysid 238) ...
  150:         1: Apple HFS (sysid 175) ...
  151:         2: NetBSD (sysid 169) ...
  152:         3: NetBSD (sysid 169 ) ...
  154:     with the same starting sections and sizes as in the GPT table.
  156: * Edit the disklabel (disklabel -i wd0). One you are done, it should look something like (as long as the start, size and type are correct, the rest is quite arbitrary) 
  158:         a: 186562703 195770624    4.2BSD      0    0     0 
  159:         b:   8388608 382333327    swap             
  160:         c: 186562703 195770624    unused      0    0        
  161:         d: 390721968         0    unused      0    0     
  162:         e:    409639         1    unknown 
  163:         f: 1 95360984   409640    HFS  
  165:     (the rEFIt EFI partition is left unknown, since we do not want to risk messing it up).
  166: * newfs(8) the FFS filesystem (make sure you use the correct /dev/rdk<n>) and mount it (the log option is, of course, optional):
  168:         umount /mnt
  169:         newfs -O2 /dev/rdk2
  170:         mount -o log /dev/dk2 /mnt
  172: * untar(1) the sets (SETS is the list of sets you want to install -- at least base.tgz and kern-GENERIC.tgz): 
  174:         cd /mnt2/amd64/binary/sets
  175:         for F in $SETS; do (cd /mnt && tar xzpf - ) < $F; done
  177: * Edit /mnt/etc/fstab (to use vi, add /mnt/[usr/]bin and relevant libraries to your [ld] path, and export TERM=vt100). Make sure that you at least have
  179:         /dev/dk2        /               ffs     rw              1 1 
  180:         /dev/dk3        none            none    sw              0 0 
  181:         ptyfs           /dev/pts        ptyfs   rw              0 0 
  182:         kernfs          /kern           kernfs  rw,noauto       0 0 
  183:         procfs          /proc           procfs  rw,noauto       0 0 
  185: * Install the bootcode: 
  187:         cp -p /mnt/usr/mdec/boot /mnt/usr/mdec/boot.cfg /mnt
  188:         installboot -v /dev/rdk2 /mnt/usr/mdec/bootxx_ffsv2
  190: * Edit /mnt/boot.cfg if needed
  191: * Create the devices: 
  193:         cd /mnt/dev && sh MAKEDEV all dk7
  195: * Reboot, and proceed with configuration. 
  197: #Getting X to work
  199: **Note:** The following description applies to older versions of --current (pre November 2008, pre 5.0). For resent versions, try setting X11FLAVOUR=Xorg in /etc/mk.conf when building a release, and try setting X11_TYPE=modular in /etc/mk.conf for building packages. The startup scripts (notably /etc/rc.d/xdm) look for X in /usr/X11R6, while Xorg resides under /usr/X11R7. To get xdm(1) working, add
  201:     command="/usr/X11R7/bin/xdm"
  203: to /etc/rc.conf.d/xdm.
  205: Getting X working on your Macbook is something of a non-trivial task. First of all, the default XFree86 code that comes with the -current distribution won't even recognize the PCI-ID of the video card (an Intel GMA950). You'll have to install the Xorg server. I did this by setting **X11_TYPE=xorg** in /etc/mk.conf and installing it from **/usr/pkgsrc/meta-pkgs/xorg** (you _did_ install NetBSD's pkgsrc right?). One small problem is that the i810 driver does not build by default on the x86_64 (amd64) architecture. You need to set the **PKG_DEFAULT_OPTIONS** to include the **xorg-server-i810** string. This can be done by simply typing **export PKG_DEFAULT_OPTIONS=xorg-server-i810** before you do the **make install** command from the **/usr/pkgsrc/meta-pkgs/xorg** directory. Once you have Xorg installed (which will take a while to compile), you can go ahead and set it up. One method is to do an **X -configure** then copy the **/root/** file into /etc/X11 and edit it to your taste. You'll need to manually set the **HorizSync** and **VertRefresh** in the display section. The see the example **xorg.conf** for reference. Just for a review, let's enumerate the steps needed here:
  207: For 5.0 (and -current 5.99.1 and later), you can instead set "X11FLAVOUR=Xorg" and build a release/distribution to get a working X server.
  209: 1. Download the pkgsrc2007Q1 or newer tarball
  210: 2. Unpack it into /usr, e.g.:
  212:         cd /usr ; tar xzvf /tmp/pkgsrc-2007Q1.tar.gz
  214: 3. Set your X11 server type to be Xorg, e.g., as root::
  216:         echo "X11_TYPE=xorg" >>/etc/mk.conf"
  218: 4. Set your server build options so you get the i810 driver even though this is an x86_x64 machine.  E.g.:
  220:         export PKG_DEFAULT_OPTIONS=xorg-server-i810
  222: 5. Allow the xorg-server-i810 to be built by editing **/usr/pkgsrc/x11/xorg-server/** and adding **xorg-server-i810** to the end of the **_COMMONCARDDRIVERS** list and removing it from the **_NOTX86_64CARDDRIVERS** list.
  223: 6. Build xorg, e.g.:
  225:         cd /usr/pkgsrc/meta-pkgs/xorg ; make install
  227: 7. Move the old XFree86 tree out of the way and link xorg in it's place, e.g.:
  229:         cd /usr/ ; mv X11R6 xfree86.X11R6 ; ln -s /usr/pkg/xorg /usr/X11R6
  231: 8. Create a skeleton xorg.conf file, e.g. as root:
  233:         X --configure
  235: 9. Copy the skeleton file into place and edit it, e.g.:
  237:         cp /root/ /etc/X11/xorg.conf
  238:         vi /etc/X11/xorg.conf
  240: 10. During your editing / customization make sure to add the following lines:
  242: 	1. Add **HorizSync 28-64** and **VertRefresh 43-60** to the *Monitor* section. These are keywords, not **Options**; so add them just as shown.
  243: 	2. Change the mouse ZAxisMapping option to **"4 5"** instead of **"4 5 6 7"** or any USB mice you plug in will behave badly.
  244: 	3. Add the **DefaultDepth 24** line to the **Screen** section just below the line that says **Monitor "Monitor0"**
  245: 	4. In the **Screen** you'll find the subsection for the 24-bit display. Just below the line that says **Depth 24** add a line that says **Modes "1280x800"** 
  247: 11. Install the **915resolution** tool from pkgsrc. (ie.. **cd /usr/pkgsrc/sysutils/915resolution ; make install**)
  249: 12. Replace a mode you know you'll never use with the 32-bit mode for 1280x800. If you don't do this, you won't be able to use the native (1280x800) video mode.
  250: 	1. List all the available modes **915resolution -l**
  251: 	2. Pick a mode and replace it: **915resolution 4d 1280 800 32** 
  253: 13. Test the X server **startx**
  255: 14. Now add the 915resolution 
  257: #See also
  258: * [rEFInd Website](
  260: # Changelog
  261: * 2015-11-01: General formatting.  Fixed code blocks so they are more readable.  Expanded boot loader section (rEFInd section still needs to be written; it is a placeholder for now).

CVSweb for NetBSD wikisrc <> software: FreeBSD-CVSweb