FreeBSD on a Mac Mini

Overview
Procedure
References

Overview

This article describes how I installed FreeBSD on a Mac Mini (Late 2012 model MD388LL/A). Why would I want to do that? I needed a small server that used minimal power, and the Mac Mini is like a laptop in a small form factor. My previous NAS machine was large and used 45W of power, but the Mini uses a mere 15W. Plus, I can mount it on a wall, up and out of the way.

Update 2021: this procedure is getting messy over time. My latest attempt with FreeBSD 13.0 using MBR or GPT would hang during boot at the "ACPI APIC table" step. My solution was to install FreeBSD 12.2 with MBR, then upgrade to 13.0 with freebsd-update. There must be something amiss in the 13.0 installer, but I did not have time to troubleshoot it. The general advice is to use MBR instead of GPT partitioning, and then bless the partition.

FreeBSD 13.0 summary:

FreeBSD 11.0 summary:

FreeBSD 10.0 summary:

I put FreeBSD on the entire disk. I could not figure out how to preserve the original macOS rescue partition.

Procedure

  1. Prepare a method to run bless from macOS installation media.

    You'll need to run the macOS command bless from the command line to make your FreeBSD disk partition bootable. You'll run bless after the FreeBSD installation by booting a macOS installation image from a USB stick or DVD-ROM drive. Be advised that older macOS install discs will likely not boot on late model Mac Mini hardware. I had another Mac running a version of macOS older than Mavericks, so I used this technique to create a Mavericks USB stick.

    Update 2020: I had difficulty using Disk Utility in Catalina to create a bootable USB stick. You can use asr on the command line instead. Assuming your USB stick is mounted as /Volumes/Untitled and you have acquired the BaseSystem.dmg file from within the Mavericks installation .app:

    sudo /usr/sbin/asr restore --source BaseSystem.dmg --target /Volumes/Untitled --erase
    
  2. Copy FreeBSD onto a USB Stick. See the FreeBSD handbook for more info.

    This section assumes you are running these commands on a Mac.

    1. Insert the USB stick into your Mac.
    2. Find the USB device name based on mount. The example below is from my machine where my USB stick is named "FAT2GB"; your mileage may vary.
      # mount
      /dev/disk1 on / (hfs, local, journaled)
      devfs on /dev (devfs, local, nobrowse)
      map -hosts on /net (autofs, nosuid, automounted, nobrowse)
      map auto_home on /home (autofs, automounted, nobrowse)
      /dev/disk2s1 on /Volumes/FAT2GB (msdos, local, nodev, nosuid, noowners)
      
    3. Unmount (but do not eject) the USB stick using Disk Utility.
    4. Write the FreeBSD image to the USB stick.

      Be very sure you know the proper device name for your USB stick in the next step.

      # dd if=FreeBSD-10.0-RELEASE-amd64-memstick.img of=/dev/disk2 bs=64k
      10641+1 records in
      10641+1 records out
      697384960 bytes transferred in 674.222314 secs (1034355 bytes/sec)
      
  3. Boot the FreeBSD USB stick in the Mac Mini while holding down the Option key. FreeBSD will be displayed as "Windows" by the Mac boot manager.
  4. Install FreeBSD
    1. Distribution Select - I chose: docs, no games, source.
    2. Guided Partitioning
    3. Entire Disk
    4. Partition Editor - You will see three GPT partitions that were created for you when you chose Entire Disk.

      If you are using FreeBSD 11 or above, then proceed to step g below.

      If you are using FreeBSD 10, you won't use these GPT partitions. Highlight ada0 and select Modify, change partition scheme to MBR, and the next screen will have no partitions for ada0.

    5. Create a partition for FreeBSD and leave the mount point blank. This will become ada0s1.
    6. Highlight ada0s1 and select Create. Create a freebsd-ufs filesystem partition that is less than the whole disk. You will need a swap partition and (optionally) other partitions as you deem necessary. The installer defaulted to 932 GB on my disk, so I subtracted 8GB for swap.
    7. Here is my final partioning scheme. I used a single freebsd-ufs root filesystem (don't judge me).
    8. Tip: use a fully qualified domain name for the hostname to avoid sendmail startup failure.
  5. Reboot to the OS X installer residing on a USB stick or DVD-ROM drive.
  6. Open a Terminal window and bless your FreeBSD partition with the macOS bless command.
  7. Reboot to FreeBSD.
  8. If you want the Mac Mini to power on automatically after a power failure, you can install the sysutils/pciutils port which will give you setpci. Put the following command in a startup script like /etc/rc.local to make the Mac Mini boot when power is restored:
    setpci -s 0:1f.0 0xa4.b=0
    

References