Skip to content

Instantly share code, notes, and snippets.

@ocxo
Forked from jcs/gist:5573685
Created June 15, 2013 14:06
Show Gist options
  • Save ocxo/5788263 to your computer and use it in GitHub Desktop.
Save ocxo/5788263 to your computer and use it in GitHub Desktop.

OpenBSD -current works pretty well on my Mid-2011 Macbook Air (A1370, SandyBridge). The new KMS code brings up the MBA's eDP display in 1366x768 with backlight control. ACPI works as expected for battery/AC status, CPU throttling, and full suspend/resume support. The Broadcom wireless card does not work, so for now I am using this tiny USB adapter (urtwn) which is rather unobtrusive when plugged in.

Dual-booting with Mac OS X is fairly easy, but once FileVault is enabled for full-disk encryption of Mac OS, it clobbers the path to boot back into OpenBSD. Here's how to get both OSes working, each with its own disk encryption, without having to use rEFIt or anything else.

###Mac OS X Configuration

  1. If FileVault is already enabled, turn it off and decrypt the SSD.

  2. Use Boot Camp Assistant to partition the hard drive, slicing off a portion of the end of the drive for OpenBSD (I used 30Gb on a 256Gb SSD). If BCA just pukes up an error that it couldn't repartition the drive, reboot into the recovery partition, run Disk Utility, and use Repair Disk on the SSD. My drive had some hard-link errors that were fixable but were probably preventing BCA's automated verify+repartition process from working. Some defragmenting may also be required to move blocks around to clear up space at the end of the drive (I'm not sure if BCA does this, but I have a copy of iDefrag that I used). Also, BCA will probably complain that there is no Windows DVD, so I had a Windows 7 DVD mounted (from my isostick) so BCA would think it's installing Windows 7.

  3. After BCA repartitions and reboots, it will try to boot to the Windows 7 DVD. Bail on that and boot to an OpenBSD CD (again, I used my isostick).

###OpenBSD Installation

  1. When OpenBSD boots, choose (S)hell, run fdisk -e wd0 and there should be an MSDOS partition already sliced out from BCA. Change its type to A6 and quit. disklabel -E wd0, create a new slice taking the defaults for the new OpenBSD partition, and use RAID as the type. Write/quit.

  2. bioctl -cC -l /dev/wd0a softraid0 to create a new softraid encrypted disk from the just-added RAID partition, and enter a passphrase. sd1 should show up (my isostick's USB drive takes sd0).

  3. install to get back to the installer, use sd1 as the root disk, proceed as normal.

  4. Reboot and it should boot to the OpenBSD bootloader as usual, prompting for the encryption passphrase. If it boots back to Mac OS X, reboot and hold down the Alt/Option key at the startup chime and it should let you arrow over to choose the "Windows" disk (which is OpenBSD).

  5. Verify that things are working. Wireless won't, but otherwise everything else should.

###Mac OS X Encryption

  1. Once OpenBSD is installed and working, reboot back into Mac OS X (using Alt/Option if it doesn't default back to Mac OS).

  2. Enable FileVault, which will require a reboot. The previous Windows/Bootcamp boot option is now gone, but it's just temporary.

  3. Let FileVault start encrypting, and run gdisk /dev/disk0 from xterm/terminal. If you don't already have gdisk, download it, it's a lifesaver.

  4. In gdisk, first run p to see the partition table. You should have an EFI partition, an AF05 Mac partition, an AB00 recovery partition, and your OpenBSD/Bootcamp partition (which may have a type of FFFF).

  5. Use t to change the type of your Bootcamp partition to 0700 (a FAT partition). Enter r to enter recovery menu, then h to build a Hybrid MBR. You will get a face full of warnings and then asked to enter a list of partitions. Enter 2 3 4 to add your 3 real partitions, and answer y to adding the first EFI partition.

  6. Confirm the defaults for partitions 2 and 3, but change partition 4's type to A6 for OpenBSD. Flag it to be bootable. w to write and quit.

  7. When you reboot again (you can do it while FileVault is still encrypting, it'll resume itself at next boot) and hold down Alt/Option at the startup chime, you should now see the Windows disk again as a boot option. Confirm that it boots back to the OpenBSD bootloader, then make sure you can boot back into Mac OS.

  8. Boot back into Mac OS and let FileVault finish encrypting.

  9. To permanently set OpenBSD as the default boot partition, run /usr/sbin/bless --device /dev/disk0s4 --setBoot --legacy. Now booting into Mac OS will require holding down Alt.

  10. Boot back into OpenBSD and get some work done.

###TODO

  • Apply the backed-out AHCI diff to take the controller out of IDE mode so the SSD uses sd instead of wd.

  • Disable uvideo0 and other crap.

  • Figure out how to disable startup chime from OpenBSD (StartupSound doesn't seem to work on Mountain Lion anymore, what is it doing anyway? Writing something to NVRAM?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment