Mac Mini as a FreeBSD based Git Server


I acquired a Mac Mini (2010) the other day and decided that:

  1. It would be a good Git server.
  2. It should run FreeBSD 10

Below are my experiences with getting this thing running.

It ain’t easy…

First off, this should be easy right? Download BSD to a USB stick, boot it up and install. Done! …nope.

You will need:

  • A bootable BSD image (See below about USB sticks)
  • A bootable OS X image for blessings later

USB Stick Failures

Ultimately I gave up on the path of installing from a USB stick (Kingston DataTraveler 2GB). Only one thing I attempted even got the thing to show up on the boot screen. All attempts were made using the FreeBSD-10.0-RELEASE-amd64-memstick.img.

Image techniques that did not show up at boot:

Using Mac Linux USB Loader and instructions here I was able to create USB stick that showed up and booted, but failed to properly kick off the BSD installer. It was a interesting experiment anyway.

After banging my head against the nonsense above, I finally resorted to a DVD and the full FreeBSD 10 image. It of course booted right up.

FreeBSD Installation

For the installation of BSD itself, it was straight forward. My setup is similar to that found on on this blog.

Note that a after the installation finishes you must run bless(8): Boot using a OS X image, drop to the shell and execute something similar to th e following:

$ bless --device /dev/disk0s1 --setBoot --legacy

Post Installation

Some other minor gotchas:

First, to eject the install DVD hold F12 at the boot menu!

Second, I was unable to properly boot. The log was spammed with never ending cycle of:

bge0: link state changed to DOWN
bge0: link state changed to UP.

This was solved by adding a entry in /boot/loader.conf:

  1. Boot into single user mode
  2. Mount / as RW: mount -rw
  3. /boot/loader.conf and add: hw.pci.enable_msi=”0”

You may also want your Mini to boot up after a power failure. This requires a couple steps:

First, determine your Mini’s chipset vendor:

$ pciconf -lv

This will give you a list of devices. Look for the entry with “LPC” in it. For my device it looks like this:

isab0@pci0:0:3:0:       class=0x060100 card=0xcb89106b chip=0x0d8010de rev=0xa2 hdr=0x00
vendor     = 'NVIDIA Corporation'
device     = 'MCP89 LPC Bridge'
class      = bridge
subclass   = PCI-ISA

You then need to add a entry to a startup script such as /etc/rc.local. According to this page and various other sources, the line for NVIDIA is:

setpci -s 00:03.0 0x7b.b=0x19

Git Server Installation

To install Git, I followed the guide on this blog. They are repeated here with any tweaks for archive:


Update pkg (need 1.3.8+ for latest Git port):

$ cd /usr/ports/ports-mgmt/pkg
$ make
$ make reinstall

Get the latest ports stuff:

$ portsnap fetch extract
$ portsnap fetch update

See also Upgrading FreeBSD Ports

(…this takes a very long time…)

Install Git Port

$ cd /usr/ports/devel/git
$ make install clean; rehash

(Used default options for all prompts)

Creating a user for Git

$ pw groupadd -n git -g 9418
$ pw useradd -n git -u 9418 -g git -c git -d /git \
-s /usr/local/libexec/git-core/git-shell -h -

Creating a Git directory

$ mkdir /git
$ chown git:git /git/
$ chmod 755 /git
$ mkdir /git/base/
$ chown git:git /git/base/
$ chmod 775 /git/base/

SSH Keys

We want Git to use SSH keys for authentication:

$ mkdir /git/.ssh/
$ chmod 700 /git/.ssh/
$ touch /git/.ssh/authorized_keys
$ chmod 600 /git/.ssh/authorized_keys
$ chown -R git:git /git/.ssh/

Then, add public key(s) to the authorized_keys file. See for example Generating SSL Keys.

Load Git @ System Start

To load Git at system startup, add the following to /etc/rc.conf:

git_daemon_flags="--syslog --base-path=/git --export-all --reuseaddr --detach"