Published: January 03, 2022

Installing FreeBSD on a 2013 Mac Pro

In 2021 I decided to go all-in on a 2013 (trashcan) Mac Pro I saw listed on Craigslist. Some might have considered this to be a “bad move” from the start, but I thought the 2013 Mac Pro was simply the most amazing computer ever made and $950 seemed like an absolute steal. I was wrong.

my-mac-pro.jpg
Figure 1: My 2013 Mac Pro

Little did I know, the 2013 Mac Pro suffered from severe thermal issues and I soon became one of the thousands of unhappy users experiencing spontaneous freezing and crashes thought to be caused by Apple’s proprietary dual AMD FirePro GPUs.

If I was in the market for a new Mac, the right thing to do would have been to get an M1 Mac mini. Not only are the M1 Macs faster, they are also cheaper and consume significantly less energy.1 However, I wasn’t really in the market for a Mac, what I wanted was a server.

As it turns out, my 2013 Mac Pro is a very compelling server. It is extremely quiet, compact, and rocks a 12-core Intel Xeon E5 with 64GB of ECC memory.2 Unfortunately, I wasn’t expecting the thermal issues and kernel panics, which made me skeptical of this machine’s viability as a reliable home server, so mostly it sat on the shelf.

Eventually, I decided to see if I could install Linux or maybe even FreeBSD alongside macOS. My hope was that by running on a minimal “headless” environment, I could avoid any stability issues due to the GPUs. Furthermore, I’ve been interested in trying out FreeBSD for a while because of two very compelling features: ZFS and the base system.3

While ZFS has been available on Linux for several years now, I consider that to be more “piece of mind” than anything else. I doubt the Linux community will ever adopt ZFS as their primary filesystem. Meanwhile, FreeBSD has proudly supported ZFS since 2008.

Besides ZFS, I really like the unified deployment model of the FreeBSD base system. This provides a level of consistency and correctness in the operating system that Linux deeply struggles with.

FreeBSD Installation Notes

This was going to be my first time installing FreeBSD, so luckily I had my T470 lying around to experiment with. I wasn’t expecting the installation on the Mac Pro to go smoothly, so having a computer that was known to be compatible with FreeBSD was really convenient. I was able to run though several installations to get a sense of how things will go on the Mac.

The very first thing I did was disable disk encryption (FireVault) on the Mac Pro. I’m not sure it would have been a problem, but I didn’t feel like finding out. I didn’t have any issues turning FireVault back on after completing the FreeBSD installation process.

One of the biggest drawbacks to FreeBSD is that there is much less content online to help troubleshoot issues or answer all the random questions you might have. Fortunately, between the FreeBSD, Hackintosh, and Linux communities, I was able to cobble together enough information to get a successful multi-booting environment setup on the Mac Pro.

After testing my bootable FreeBSD USB drive on my ThinkPad, I tried to boot into it from the Mac by holding down the Option (Alt) key during startup. I didn’t want to waste my time if I couldn’t get FreeBSD to boot on the Mac.

live-boot-1.jpg
Figure 2: Holding Option (Alt) to boot with my FreeBSD USB drive
live-boot-2.jpg
Figure 3: Nice! This might actually work

I was pretty excited after seeing the FreeBSD boot menu show up. I wasn’t sure what to expect because the Xeon E5 doesn’t have integrated graphics and I wasn’t sure the AMD FirePro’s were going to work. Although my enthusiasm didn’t last long, only a few seconds into the boot process later and it was game over. The console was endlessly streaming the text pcib8: Power Fault Detected and became completely unresponsive.

power-fault-detected.jpg
Figure 4: Oh NO! pcib8: Power Fault Detected. We’re stuck.

Somehow, I was able to dig up an old forum post by someone with this exact issue but unfortunately it went unresolved. However, it gave me hope a solution was out there.

I spent about half an hour playing around in the boot menu trying to figure out if I could get something to work. Single User Mode had the same problem and I wasn’t really sure how to use the Loader prompt. However, I felt like I was making progress.

My biggest clue was the pcib8 bit. Since this was an error message during PCI device initialization, I start searching the web for things like “FreeBSD pci won’t boot” and “FreeBSD power fault detected”.

Once it became clear that I was on my own with this one, I pulled up the FreeBSD manual pages for boot(8), loader(8), and pci(4) then started reading through them. I started to get a sense for how the FreeBSD boot process worked and was ready to try setting custom boot options.

Miraculously, I discovered a single boot option that fixed my issue. Now I could finally get into the FreeBSD installer and live environment!

Here is all I needed to get FreeBSD to boot on the Mac Pro:

  1. Press 3 to “Escape to loader prompt”
  2. Enter: set hw.pci.enable_pcie_hp="0" to disable PCI-express HotPlug
  3. Enter: boot to boot
boot-options.jpg
Figure 5: Sucessful boot after setting hw.pci.enable_pcie_hp="0"

Resizing macOS

When installing FreeBSD on an machine already using EFI, you only need two partitions: freebsd-root and freebsd-swap. The FreeBSD installer calculates size using powers of two (eg: Gibibytes) while macOS uses powers of 10 (eg: Gigabyte). I decided on a 4GiB swap and 80GiB root partition for FreeBSD.

  • (84 GiB / 1 GiB) * (2^30 bytes / 1 GB) = 90,194,313,216 bytes
  • (90,194,313,216 bytes / 1 byte) * (1 GB / 10^9 bytes) = 90.194313216

So we want to resize our macOS partition to 90.19 GB

One of the great features of the “new” Apple File System (APFS) is that you can resize our startup disk while it’s mounted. There’s no need to reboot into recovery or another live environment.

It doesn’t matter what filesystem you choose because you will create the new partitions in the FreeBSD installer. The important part is being able to know which partition is which so you don’t accidentally overwrite macOS.

macOS-resize-1.png
Figure 6: Choose macOS partition to resize
macOS-resize-2.png
Figure 7: Set the new size for your disk
macOS-resize-3.png
Figure 8: Don’t be afraid
macOS-resize-4.png
Figure 9: Eventually the resize will finish

Installing FreeBSD

The first step is create the freebsd-root and freebsd-swap partitions. Don’t forget to add drive labels and enable TRIM support if you’re using an SSD.

By default, the FreeBSD installer sets generic drive names in /etc/fstab. If you don’t use labels, FreeBSD will get confused and refuse to boot whenever you add or remove drives.

If you forget to set labels on your drive partitions during the installation, you will need to add them and update the entries in /etc/fstab using the gpart utility.

manual-partition.jpg
Figure 10: Choose “Manual Disk Setup”
initial-partition-table.jpg
Figure 11: Initial partition table after resizing from macOS
freebsd-root.jpg
Figure 12: Creating freebsd-root partition
enable-trim.jpg
Figure 13: Enabling TRIM on SSD
freebsd-swap.jpg
Figure 14: Creating freebsd-swap partition
final-partition-table.jpg
Figure 15: Final partition table
installing-progress.jpg
Figure 16: FreeBSD installation progress

After creating your custom partitions, the only thing left to do is remember to add hw.pci.enable_pcie_hp="0" to your /boot/loader.conf before rebooting. I also ended up adding autoboot_delay="5".

install-done.jpg
Figure 17: Don’t forget to edit /boot/loader.conf before rebooting
set-loader-conf.jpg
Figure 18: Editing /boot/loader.conf

Post-Installation

It’s possible the Mac will default to booting FreeBSD, but you can always hold down the Option (Alt) key during boot to select a different OS.

Use Drive Labels

The first thing you should do is open /etc/fstab and switch out the drive numbers for your disk labels (Don’t forget to make a backup first!). You can also comment-out the mount for /boot/efi since the machine is going to use Apple’s EFI partition instead.

$ cat /etc/fstab
# Device        Mountpoint      FStype  Options Dump    Pass#
/dev/gpt/rootfs /               ufs     rw      1       1
/dev/gpt/swapfs none            swap    sw      0       0
#/dev/ada0p1    /boot/efi       msdosfs rw      2       2

Disable Hyperthreading

Dvorak and Switching Caps-Lock to Control

  • kbdmap Choose desired keymap (eg: us.dvorak)
  • kbdcontrol -d | sed 's/clock/lctrl/g' > ctrlcaps.keymap Dump current keymap
  • kbdcontrol -l ctrlcaps-dvorak.keymap Load custom keymap

Networking

  • Check interfaces and enable DHCP on ipv4 and ipv6: ifconfig -a
  • Add the following to /etc/rc.conf:
    • ifconfig_bge1_"DHCP"
    • ifconfig_bge1_ipv6="inet6 accept_rtadv"
  • Restart network service: /etc/rc.d/netif restart

SSH

The default /etc/ssh/sshd_config, looked good to me (i.e., no password or root logins).

Fuse and exFAT support

It would be nice to be able to mount USB drives…

  • pkg install fusefs-exfat
  • kldload fusefs
  • mount.exfat /dev/da0s1 /media/usb
  • Add fusefs to kld_list="" entry in /etc/rc.conf

Checking Disk Performance

  • camcontrol devlist
  • diskinfo -tv /dev/adN

CPU and Sensor Data

  • echo 'coretemp_load="YES"' >> /boot/loader.conf
  • kldload coretemp
  • Check temperature with: sysctl dev.cpu | grep temperature

Getting the rest of the Mac Pro’s sensor data required patching the Apple SMC driver in FreeBSD. If my patch gets accepted, all you will need to do is add asmc_load="YES" to boot/loader.conf.

diff -u original/asmc.c my-patch/asmc.c
--- original/asmc.c     2021-12-28 23:43:20.905442244 -0600
+++ my-patch/asmc.c     2021-12-29 00:10:38.424770226 -0600
@@ -328,6 +328,15 @@
     ASMC_MP5_TEMPS, ASMC_MP5_TEMPNAMES, ASMC_MP5_TEMPDESCS
   },

+       /* Idem for the Mac Pro 2013 (cylinder) */
+       {
+    "MacPro6,1", "Apple SMC Mac Pro (2013)",
+    ASMC_SMS_FUNCS_DISABLED,
+    ASMC_FAN_FUNCS2,
+    ASMC_LIGHT_FUNCS_DISABLED,
+    ASMC_MP6_TEMPS, ASMC_MP6_TEMPNAMES, ASMC_MP6_TEMPDESCS
+       },
+
   {
     "MacBookAir1,1", "Apple SMC MacBook Air",
     ASMC_SMS_FUNCS, ASMC_FAN_FUNCS, NULL, NULL, NULL,
diff -u original/asmcvar.h my-patch/asmcvar.h
--- original/asmcvar.h  2021-12-28 23:43:12.163365462 -0600
+++ my-patch/asmcvar.h  2021-12-29 00:11:36.207227372 -0600
@@ -581,6 +581,18 @@
           "Te3F", "Te3S", "Te4F", "Te4S", "Te5F", \
           "Te5S", "TeGG", "TeGP", "TeRG", "TeRP", \
           "TeRV", "Tp0C", "Tp1C", "TpPS", "TpTG", }
+
+#define ASMC_MP6_TEMPS { "TA0P", "TA1P", "TC0P", "TG0D", "TG0P", \
+       "TG1D", "TG1P", "TM0P", "TM1P", NULL }
+
+#define ASMC_MP6_TEMPNAMES     { "ambient_air_1", "ambient_air_2", \
+       "cpu_proximity", "gpu_diode_1", "gpu_proximity_1", "gpu_diode_2", \
+       "gpu_proximity_2", "mem_proximity_1", "mem_proximity_2" }
+
+#define ASMC_MP6_TEMPDESCS     { "Ambient Air 1", "Ambient Air 2", \
+       "CPU Proximity", "GPU Diode 1", "GPU Proximity 1", "GPU Diode 2", \
+       "GPU Proximity 2", "Memory Bank A", "Memory Bank B" }
+
 #define        ASMC_MBA_TEMPS          { "TB0T", NULL }
 #define        ASMC_MBA_TEMPNAMES      { "enclosure" }
 #define        ASMC_MBA_TEMPDESCS      { "Enclosure Bottom" }

Rebuilding the asmc driver with my patch:

cd /usr/src/sys/modules/asmc
make
make install
kldunload asmc
kldload /boot/modules/asmc.ko
# Check /var/log/messages for missing key entries

# Must add kld_list="/boot/modules/asmc.ko" to /etc/rc.conf instead of asmc_load="YES"
# in /boot/loader.conf so that we find our compiled version of the module

Checking sensor data:

$ sysctl dev.asmc
dev.asmc.0.temp.mem_proximity_1: 42
dev.asmc.0.temp.mem_proximity_2: 41
dev.asmc.0.temp.gpu_proximity_1: 45
dev.asmc.0.temp.gpu_diode_1: 47
dev.asmc.0.temp.gpu_proximity_2: 44
dev.asmc.0.temp.gpu_diode_2: 47
dev.asmc.0.temp.cpu_proximity: 42
dev.asmc.0.temp.ambient_air_1: 37
dev.asmc.0.temp.ambient_air_2: 29
dev.asmc.0.fan.0.targetspeed: 790
dev.asmc.0.fan.0.maxspeed: 1900
dev.asmc.0.fan.0.minspeed: 790
dev.asmc.0.fan.0.safespeed: -1
dev.asmc.0.fan.0.speed: 789
dev.asmc.0.fan.0.id: Main
dev.asmc.0.%parent: acpi0
dev.asmc.0.%pnpinfo: _HID=APP0001 _UID=0 _CID=SMC-HURONRIVER
dev.asmc.0.%location: handle=\_SB_.PCI0.LPCB.SMC_
dev.asmc.0.%driver: asmc
dev.asmc.0.%desc: Apple SMC MacPro (2013)
dev.asmc.%parent:

Changing fan speed:

  • View current: sysctl dev.asmc.0.fan.0.speed
  • Set new: sysctl.dev.asmc.0.fan.0.minspeed=1800

Submitting my patch:

Resources:

Installing the rEFInd Boot Manager

Rather than holding down the Option (Alt) key every time we want to boot into a different OS, we can get a graphical boot menu by installing rEFInd.

Here’s how to install it:

  1. Download rEFInd and copy it onto a USB drive.
  2. Reboot your Mac into recovery by holding down Command (Win) + R.
  3. Open Terminal.app.
  4. Disable System Integrity Protection (SIP): csrutil disable.
  5. Reboot and enter recovery again.
  6. Open Terminal.app and plug in your USB drive.
  7. Navigate to the refind directory on your USB drive (Look in /Volumes/).
  8. Run the installer: ./refind-install
  9. Enable SIP: csrutil enable.
  10. Reboot
refind-install.jpg
Figure 19: Installing rEFInd
refind-boot.jpg
Figure 20: The rEFInd boot menu

Customizing rEFInd

  • rEFInd will default to the most recently booted OS, so the only configuration I’m doing is setting the timeout to 5s instead of 20.
  • mkdir /Volumes/ESP
  • diskutil list (find label for EFI Boot eg: disk0s1)
  • mount -t msdos /dev/disk0s1 /Volumes/ESP
  • cd /Volumes/ESP/EFI/refind/
  • http://www.rodsbooks.com/refind/configfile.html

Footnotes:

2

I decided to upgrade the CPU and RAM to the maximum configuration originally offered by Apple. Back in 2013 this machine would have cost over $8,000. Swapping out the CPU was a bit more involved than a typical PC but the iFixit guide was really comprehensive and the whole process took about two hours.

3

Honorable mention for no GPL. Please note that systemd is not mentioned. Linux is clearly much better off with systemd and the complaining needs to stop.

Last updated: 2022-05-08