Sanity Check on Mac Mini
bc979 at lafn.org
Sun Mar 10 00:46:45 UTC 2013
I have documented what I have completed and what remains to be done for the install of 9.1 on a Mini. I wrote this as a section of the Handbook, although its not in the right format as I don't know what that format is. I believe this needs to be retained in the documentation somewhere easily found for those who need it in the future.
2.12 Installing FreeBSD on an Apple Mac Mini
The Mac Mini is an attractive server platform. Its small, runs cool, low powered, and reasonably cheap. There a variety of configurations available. However, the bottom of the line seems to be a powerful server.
There are a few issues with installing FreeBSD on the mini. Mostly they derive from the newer hardware it uses and that it uses EFI rather than a BIOS for booting. There is not a simple install that will get the unit working, but the additional steps required are quite simple. The goal of these instructions is to get FreeBSD 9.1-Release running as a headless server on a Late 2012 Mini. Its probably possible to setup the mini as a workstation, but that would require some additional effort to test the display and mouse interfaces and find fixes for any issues with those.
The original intent was to have the server without system source so that it could be maintained using freebsd-update. However, that will probably have to wait until 9.2-Release is available. In the meantime, freebsd-update has to be used with care since I believe it will replace the modified bge files.
2.12.1 Preparing for the Install
You can select either the i386 or the amd64 distributions. Both have been tested with these procedures and yield a working server. The bottom of the line mini comes with 4 GB of memory installed. The i386 distribution will only use 2 GB. The remainder will not be used. The amd64 distribution builds larger binary modules, but it will use all the memory.
Download the 9.1 Release distribution Memstick Image. You will need to copy that to a memstick. There are instructions in section 2.3.5 for copying the image to the memstick. Obtain a display and USB keyboard and connect them to the mini.
With a browser go to svnweb.freebsd.org/base/head/sys/dev. Click on the bge folder. Click on the name if_bge.c. Find Revision 245931. Click on the download link and save the file.
Go back to the bge page and click on if_bgereg.h. Find Revision 243686. Click on the download link and save the file. Edit the saved if_bgereg.h file and add the following to the end:
#define PCIER_DEVICE_CAP 0x4
#define PCIER_DEVICE_CTL 0x8
#define PCIEM_CAP_MAX_PAYLOAD 0x00000007
#define PCIEM_CTL_RELAXED_ORD_ENABLE 0x0010
#define PCIEM_CTL_NOSNOOP_ENABLE 0x0800
#define PCIER_DEVICE_STA 0xa
#define PCIEM_STA_CORRECTABLE_ERROR 0x0001
#define PCIEM_STA_NON_FATAL_ERROR 0x0002
#define PCIEM_STA_FATAL_ERROR 0x0004
#define PCIEM_STA_UNSUPPORTED_REQ 0x0008
There was a change to some of the names in if_bgereg.h after the 9.1 Release was created, but before the corrections to the bge driver were included. It would be possible to grab the appropriate earlier verion of if_bgereg.h, however, when rebuilding the kernel, there are other drivers that use the new names. This seems to be the easiest approach. Also, it worked.
Go back to the dev page and click on the mii folder. Click on brgphy.c. Find revision 244482. Click on the download link and save the file.
Copy the saved files to another memstick.
2.12.2 Installing the 9.1 Release
Boot the mini using the memstick. Hold down the Option key on the keyboard and power up the mini. You will hear the hardware check beep and shortly thereafter the screen will show one or more boot icons. Double click on the one named "Windows". It will have a USB icon.
Continue through the normal installation procedure as detailed earlier in this chapter. If you are building a FreeBSD only server, use the entire disk. Also, be sure to install the system source. You will need it later.
At the end of the install you will be asked to reboot the mini. Here is where the first problem occurs. If you pop out the memstick and let the system reboot, it will hang with an empty folder icon in the center of the display.
The problem is that the EFI boot loader can't find anything to boot. There are several approaches that may work. The Mac bless utility has been used to bless the boot disk so the boot loader can find it. There are currently no instructions available for this approach. The one way that has been shown to work is to make sure the memstick is removed when you boot the mini. Once you get the empty folder icon, plug the memstick back in. The system will shortly boot from the internal disk. There is no known explanation for this phenomena other than "it just works".
2.12.3 Rebuilding the kernel to support the Ethernet Interface
Once the system has been rebooted, you will notice that ifconfig does not show the ethernet interface. The bge driver needs to be updated to recognize the NIC. Mount the second memstick with the files retrieved earlier and move them into the kernel source. I used the following commands:
cp -p brgphy.c /usr/src/sys/dev/mii
cp -p if_bgereg.h /usr/src/sys/dev/bge
cp -p if_bge.c /usr/src/sys/dev/bge
then rebuild the kernel. Note the instructions here are for GENERIC, but you can use KERNCONF to specify a custom kernel.
Reboot the server as before. Now ifconfig will show bge0 and it will work. The mini is now running a useable version of 9.1-Release. There are still some items remaining to be resolved: Updating the kernel with the recent security patches, Disabling Bluetooth and Wireless to save power, and unattended rebooting. These issues are still being addressed.
2.12.4 Running freebsd-update to get the Latest Security Updates
Freebsd-update provides a very convenient was to keep the system up to date with security updates. It does require that you remain on the Release distribution and not use modified kernels. Since the mini requires updates to the bge driver that will not be incorporated into the 9.1-Release, the modified bge files need to be save somewhere other than in /usr/src. Freebsd-update will replace them in their normal locations with the "newer" ones that do not support the mini's NIC. I saved a copy in my home directory along with a short script that copies them into the kernel.
Run: freebsd-update fetch
Run: freebsd-update install
Check the differences between the updated bge files and those in the kernel source. If they have changed, the rebuild the kernel. At the moment, the security updates have not affected the kernel so it did not need to be rebuilt.
2.12.5 Automatic Startup after Power is Restored
Generally servers need to be automatically restarted after a power failure. The mini has that capability, but I haven't found how to set it yet.
2.12.6 Disabling Bluetooth and Wireless
Mac OS-X provides a way to disable both of these. Ifconfig does not show either. The Wireless NIC is not attached to a driver so is status is quite difficult to determine. My guess is that the appropriate driver will need an update to enable it to be found and controlled. The same seems to hold for the Bluetooth controller.
2.12.7 Unattended Booting
Supposedly there is a way to boot the mini on OS-X and use the bless utility to set the disk properly for booting. I have not found the magic incantation that will make that work yet. Using the memstick is the only way so far.
2.12.8 Other Versions of the Mac Mini
I will be installing on a Mac Mini 1,1 (quite old) shortly and will update this with those results. I don't have access to any other units.
More information about the freebsd-stable