How to install NetBSD on an Apple Macbook w/core2duo

From NetBSD Wiki

Jump to: navigation, search

Contents

[edit] Things you DO NOT want to do

  • Do NOT try using i386 NetBSD. 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 (haven't tried yet with 4.0 - please update if it works for you).
  • 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.
  • 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.
  • 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.
  • 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.

[edit] What works and what doesn't

This stuff all seems to work fine:

  • SATA disk drivers
  • Core2Duo processor (it still crashes, but the amd64 much less often than the i386 port)
  • i810 Graphics (Intel 945GM chip) and the LCD panel (with some help from the "915resolution" application)
  • Keyboard
  • Touchpad (but no synaptic extensions, so it sucks)
  • IEEE1394 interface (shows up, but I've never used it)
  • USB 2.0/1.0
  • CDRW/DVDRW
  • Marvell Gigabit Ethernet
  • Automatic (ACPI?) fan control (ie.. you won't fry your macbook installing NetBSD)

What Doesn't work

  • Apple iSight Camera (Might work someday - it's USB)
  • Internal Atheros 802.11g interface (it's too new - no driver yet)
  • The internal accelerometer.
  • The infrared remote control
  • The external DVI (might work, with newer Xorg but broken at the moment)
  • Sound (audio0 shows up but you can't really use it typical netbsd azalia problems).

[edit] Gathering What you'll need

Before you get started, let's get straight what you have and what you'll need.

  • 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.
  • 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 ftp://ftp.netbsd.org/pub/NetBSD-daily/HEAD/. I've noticed that netbsd-4 beta snapshots seem to work fine, as well (as long as they are amd64 architechture).
  • 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.
  • A working, ethernet-based connection to the Internet (or localnet with cached install sets) or a known-good USB-based wifi adapter.
  • A copy of rEFIt to use as a primary bootloader. Get it at http://refit.sourceforge.net 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.

[edit] Installing rEFIt

First grab a copy of rEFIt from http://refit.sourceforge.net 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). I had a small problem when I first installed rEFIt. I used the DMG OSX-based installer, but then afterwards the same tired old MacOS X bootloader (the grey apple logo) came up instead of the flashier rEFIt interface. As it turns out, the installer had only put the files on my machine but didn't install rEFIt onto the boot partition. While in OSX I had to open a terminal and do "cd /efi/refit/ ; ./enable.sh". Afterwards rEFIt came up before the Apple boot loader and I had 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.

[edit] Creating a new partition for NetBSD

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 http://www.apple.com/macosx/bootcamp/ 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.

Here is how:

First do this to get a list of your current partitions diskutil list

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.

(assuming you have an 80Gb disk and you want )

sudo diskutil resizeVolume disk0s2 32G "Linux" <name of NetBSD volume> 21G "MS-DOS FAT32" <name of windows volume> 21G

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.

[edit] Installing NetBSD -current

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: ftp://ftp.netbsd.org/pub/NetBSD-daily/HEAD/200705170002Z . 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.

[edit] Getting X to work

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/xorg.conf.new 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:


  1. Download the pkgsrc2007Q1 or newer tarball
  2. Unpack it into /usr (ie.. cd /usr ; tar xzvf /tmp/pkgsrc-2007Q1.tar.gz)
  3. Set your X11 server type to be Xorg. (ie.. echo "X11_TYPE=xorg" >>/etc/mk.conf" as root)
  4. Set your server build options so you get the i810 driver even though this is an x86_x64 machine. Ie.. export PKG_DEFAULT_OPTIONS=xorg-server-i810
  5. Allow the xorg-server-i810 to be built by editing /usr/pkgsrc/x11/xorg-server/options.mk and adding xorg-server-i810 to the end of the _COMMONCARDDRIVERS list and removing it from the _NOTX86_64CARDDRIVERS list.
  6. Build xorg (ie.. cd /usr/pkgsrc/meta-pkgs/xorg ; make install)
  7. Move the old XFree86 tree out of the way and link xorg in it's place (ie.. cd /usr/ ; mv X11R6 xfree86.X11R6 ; ln -s /usr/pkg/xorg /usr/X11R6
  8. Create a skeleton xorg.conf file (ie.. as root X -configure)
  9. Copy the skeleton file into place and edit it (ie... cp /root/xorg.conf.new /etc/X11/xorg.conf ; vi /etc/X11/xorg.conf)
  10. During your editing / customization make sure to add the following lines:
    1. Add HorizSync 28-64 and VertRefresh 43-60 to the *Monitor* section. These are keywords, not Options; so add them just as shown.
    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.
    3. Add the DefaultDepth 24 line to the Screen section just below the line that says Monitor "Monitor0"
    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"
  11. Install the 915resolution tool from pkgsrc. (ie.. cd /usr/pkgsrc/sysutils/915resolution ; make install)
  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.
    1. List all the available modes 915resolution -l
    2. Pick a mode and replace it: 915resolution 4d 1280 800 32
  13. Test the X server startx
  14. Now add the 915resolution

[edit] See also

Personal tools