Three Time’s Not a Charm: (an attempt at) installing a BSD on an iMac

What I Wanted

Hardware

I have a 27-inch, 5K Apple iMac from mid-2015 that’s out of support from the modern macOS releases. Specs are very 2015-y:

  • 1 TB SSD (upgraded from the standard 1 TB, 7200 RPM HDD)
  • 4-Core Intel Core i5 “Haswell” @ 3.33 GHz
  • 12 GB DDR3 RAM @ 1600 MHz
  • AMD Radeon R9 M290 with 2 GB GDDR5 VRAM
  • 4xUSB 3 ports
  • SDXC card slot
  • Broadcom BCM57766 Gigabit Ethernet Controller
  • Broadcom BCM4360 802.11ac Wireless Network Adapter

The idea was pretty straightforward: having an installed Operating System that can leverage the hardware included in the Mac.

For this experiment, having to install third-party, proprietary software or firmware wasn’t considered a problem. Neither was having to exit the installer, drop to a shell and perform extra steps for configuring the hardware, as long as the system booted and recognized everything I wanted.

But, leaving the installer and booting to a system without working:

  • Sound
  • Video
  • Wireless Networking
  • USB

was considered a failure.

Software

As you may know, I am pretty familiar with GNU/Linux systems. But for this little experiment, I wanted to give BSDs a chance on real hardware.

I’ve been playing with FreeBSD in virtual machines in the past, and I tried it on a 2009 Mac mini and on this MacBook Air. The installation was pretty simple, and having WiFi working on the MacBook Air was as simple as installing the Broadcom microcode kernel modules and loading the if_bwn driver at boot.

Try. Fail. Repeat.

FreeBSD: so close


FreeBSD is an operating system for a variety of platforms which focuses on features, speed, and stability. It is derived from BSD, the version of UNIX® developed at the University of California, Berkeley. It is developed and maintained by a large community.

— FreeBSD.org, About FreeBSD

I know, I know: the WiFi chip isn’t compatible with if_bwn, a simple Google search made it pretty clear. But that doesn’t mean FreeBSD didn’t deserve a fair chance.

Making a USB drive with the installer was just downloading the image and:

# dd if=/path/to/FreeBSD-13.2-RELEASE-amd64-dvd1.iso of=/dev/rdiskX bs=4M && sync

Installation went smoothly, I ended up partitioning the SSD with different UFS partitions (excluding ESP and swap) for the corresponding mount points:

  • /
  • /var
  • /tmp
  • /var/tmp
  • /usr
  • /etc

[That’s an habit I got from playing with UNIX-based systems: divide the system onto different partitions and harden them with mount options like nosuid, nodev, noexec. The foundations for extra security layers above the filesystems.]

The first boot, however, didn’t go as smoothly.

Interestingly, FreeBSD’s own loader.efi failed at locating the partition containing the kernel. I had to issue the following loader commands (with X being the partition number containing the kernel file):

set currdev=disk0pX
boot

And boom, the kernel was loaded and the system booted.

Reviewing the output of dmesg, most of the hardware got attached to a kernel driver: Ethernet, USB,… except WiFi.

OpenBSD: USB is the Devil in Disguise


“The OpenBSD project produces a FREE, multi-platform 4.4BSD-based UNIX-like operating system. Our efforts emphasize portability, standardization, correctness, proactive security and integrated cryptography.”

— OpenBSD.org, OpenBSD

Upon further googling, I found this man page. Hurray, did I scream.

Could OpenBSD be more compatible than FreeBSD?

Making a USB drive with the installer was just downloading the dedicated USB image and:

# dd if=/path/to/install73.img of=/dev/rdiskX bs=1M && sync

The iMac agreed to boot off the USB drive, and I was greeted with the spartiate OpenBSD installer, running from a Ramdisk.

I’ve let the installer choose the options for me, as a newcomer to OpenBSD. But when it was time to locate the file sets, things got complicated.

As the OpenBSD installer was bootstrapped form a USB drive, and the image was supposed to contain those sets, I was surprised when the program said it couldn’t find any. After exiting the installer and dropping to a shell, it appeared that the USB drive’s dev node was nowhere to be found. The First Drama™️.

The environment running from a Ramdisk, I tried to turn it off and on again unplug and replug the drive. Leading to The Second Drama™️.

A few seconds after plugging the drive, this message appeared on the console:

uhub0: device problem, disabling port 1

“Uh-oh”, I whispered. “That’s doesn’t sound good”.

I tried to plug the drive on all the USB ports, always leading to the same error (the port number was different each time. No surprise). Since the keyboard as also attached via USB, I tried different combinations of the USB drive with and without the USB keyboard on different ports. Always the same.

For the sake of testing, I plugged on old USB 1.1 drive. It worked. But didn’t have enough space.

“Don’t let those USB shenanigans bamboozle you”, I told myself. “Just try with a good old SD card!”. And that was the Final Drama™️.

After dd‘ing the image onto an SD card, booting the Mac from it and redoing the installer’s steps, the same happened: no file sets.

Again, dropping off to a shell, the SD card wasn’t seen by the kernel. Again, by unplugging and plugging, a message appeared to the console, this time saying that there wasn’t enough power for the sdmmc0 device. But by doing so multiple times, the SD card was finally there. But still, the installer didn’t find the sets.

After issuing:

/dev/MAKEDEV.sh sd1
disklabel sd1

There was just… nothing. The SD card was seen, attached to the right kernel driver, had a dev node, but it wasn’t possible to see the partitions, and de facto mount anything.

I poured myself a glass of wine and gave up. End of The Drama Arc™️.

NetBSD: easily triggered by AMD


“NetBSD is a free, fast, secure, and highly portable Unix-like Open Source operating system. It is available for a wide range of platforms, from large-scale servers and powerful desktop systems to handheld and embedded devices.”

— NetBSD.org, The NetBSD Project

After just a bit more googling, I found that the bwfm driver had been ported to NetBSD.

Making a USB drive with the installer was just downloading the image and:

# dd if=/path/to/NetBSD-9.3-amd64-install.img of=/dev/rdiskX bs=4M && sync

The iMac happily started booting… until:

drm: initializing kernel modesetting
drm: register mmio base: [hex]
drm: register mmio size: [int]
drm: doorbell mmio base: [hex]
drm: doorbell mmio size: [int]
DRM error in radeon_get_bios: Unable to locate a BIOS ROM
: error: fatal error during GPU init
radeon0: unable to attach drm: 22

I nervously laughed, finished the bottle of wine, turned off the iMac and went outside to touch some grass.

Final Word

I hugely respect the work of the various BSD teams and developers. GNU/Linux gets most of, if not all, the attention of the Open Source community and companies, letting the BSDs little room to be, evolve and grow.

We collectively owe much to the BSDs. They serve us. They secure us. They entertain us. And they go to space. Many vendors used at least a component from a BSD, giving their permissive license.

Seeing that none of them was able to run as I wanted them to on a end-user computer with some kinda outdated hardware is painful.

By Pierre Blazquez

I mess with computers, drink too much coffee and listen to music at max volume.