# Installing FreeBSD on Intel Mac Mini



## dgh3 (Sep 13, 2013)

I have a Mac Mini that apparently does a GPT install from the DVD just fine, but writing the boot code with gpart apparently trashes enough of the GPT header to completely confuse the Mac Mini's firmware. The system is not bootable to the internal drive. 

I've experimented with changing the the gpart bootcode to not overwrite the GPT structure by eliminating the -b option, but that will let me boot from OSX, and get into rEFIt. rEFIt does not show the FreeBSD install.

What I want to accomplish: install a FreeBSD/ZFS file system with a dual boot with OSX. I'm completely willing to reformat the hard drive; it has no useful information on it

I've tried this both with FreeBSD 9.1 alone, and FreeBSD 9.1 with an OSX partition with rEFIt installed. I can boot off an external Firewire drive to an OSX system with rEFIt installed, but running rEFIt off the external drive does not show the FreeBSD system either.

I've searched the forums, and other people have had similar problems. What others claim to work is installing on an MBR style partitioning scheme. I can live with that; OSX does not seem to care whether its disk format is GPT, MBR or APM. (The OSX installer won*'*t let you install on anything other than GPT, but that*'*s another matter. I can copy an OSX system from a GPT partition quite readily.)

I can't seem to find any MBR/ZFS install example for FreeBSD 9.1. What exists is for version 8.4 "Installing FreeBSD Root on ZFS using FreeBSD-ZFS partition in a FreeBSD MBR Slice". The ZFS bootstrap files look like they have changed a lot between version 8.4 and version 9.1*.*

I've downloaded the FreeBSD-8.4-RELEASE-amd64-dvd1 image and will give that a try. I'll report back what happens.

Is someone willing to update the ZFS install on a MBR formatted disk for version 9.1?


----------



## throAU (Sep 14, 2013)

Following with interest... I've tried to run FreeBSD and Ubuntu on my old 2007 spec mini and failed; I ended up bricking it with rEFInd and had to resurrect using a firewire cable off my Macbook


----------



## kpa (Sep 14, 2013)

I don't think it's the GPT bootcode  that is the problem since the /boot/gptboot code is written on a separate partitition and the /boot/pmbr is written so that the MBR partition table stays intact. What is lacking instead is support for the hybrid MBR/GPT partition table the Intel Macs use.


----------



## dgh3 (Sep 15, 2013)

The approach I've taken is to partition the disk entirely with gpart. gpart is required to do the partitioning because the 64 kB freebsd-boot partition is under the OS X 1Gig 1 GB minimum partition size.

gpart creates the 150Gig 150 GB partition, which will be reformatted under OS X as journaled HFS+. I've done this several times and it works well.

gpart also creates the first 50Gig 50 GB partition, which will be formatted under OS X as a maczfs partition. This partition will be initialized with OS X/maczfs mounted under FreeBSD.

The second 50G 50 GB partition will initialized as zfs ZFS by whatever version of FreeBSD I can get to boot and will stay at that filesystem version.

The last partition, a freebsd-zfs partition taking up the remainder of the space, is intended to hold the mountpoint / and everything under it.

What is left out of the following partitioning code is the gpart command to write the bootstrap:

```
gpart destroy -F ada0
gpart create -s gpt ada0
gpart add -b 34 -s 64k -t freebsd-boot ada0
gpart add -s 4G -a 4k -t freebsd-swap -l swap0 ada0 
gpart add -s 150G -a 4k -t freebsd-ufs -l osxserve ada0 
gpart add -s 50G -a 4k -t freebsd-ufs -l macZFS0 ada0 
gpart add -s 50G -a 4k -t freebsd-zfs -l bsdZFS0 ada0 
gpart add -s 60G -a 4k -t freebsd-ufs -l bsdUFS0 ada0 
gpart add -a 4k -t freebsd-zfs -l disk0 ada0
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0
```

When I write only the gptzfsboot bootstrap file, the internal hard drive is still "OK" to the firmware. This tells me the basic GPT partition setup is compatible between FreeBSD v9.1 gpart and OS X. `gpart bootcode -p /boot/gptzfsboot -i 1 ada0`

After I write the pmbr file with the following code, the internal drive is unusable: `gpart bootcode -b /boot/pmbr`.

Switching to MBR is possible and has been done before. Here is an example where bootcamp Boot Camp is used to make an MBR partition to install FreeBSD.

https://wiki.freebsd.org/AppleMacbook#Apple.27s_MacBook_on_FreeBSD

I'm pursuing that strategy now.


----------



## dgh3 (Sep 17, 2013)

Installation of FreeBSD 9.1 now completed on a GPT formatted disk. It took installing as an i386 system, not amd64. The only flaw I found in the install script is that the file lib32.txz didn't exist and had to be taken out of the install list.

rEFIt v0.14 now shows the FreeBSD logo. For those that want to try this, rEFIt lives inside an OS X partition as a startup item. 

To install OS X, first use  `gpart` to create a partition large enough to hold OS X; this is done as part of the FreeBSD install.  Then reboot into the OS X install disk and use the OS X disk utility to erase the partition and recreate as journaled HFS+. The OS X installer will then run normally.

This Mac Mini is an older model, but it does have a Core 2 Duo processor. The firmware does not know how to boot a 64 bit system off disk. For some reason, the amd64 dvd1 image was bootable. The first clue that I ignored was that the memory stick with amd64 was bootable on my later model Macbook Pro laptop, but not bootable on the Mac Mini.

I found this out by going to the Boot Camp documentation. For this model Mac Mini it says you can load a 32 bit Vista system, but not a 64 bit version.


----------



## throAU (Sep 18, 2013)

Cheers, sounds like you have the same spec Mini as me - first generation with the Core 2 and the 32 bit EFI. I bricked mine (Firewire + Target disk mode rocks) by attempting to install 64 bit FreeBSD (or Ubuntu) and attempting to boot it using 64 bit filesystem drivers. It was a pretty half-hearted attempt and I just shelved it for another day. Might give it another shot this weekend, my Mini is just sitting in the corner doing nothing as I've got no use for it - but I have a USB ethernet adapter and it could be used for a neat little firewall/router.


----------



## dgh3 (Sep 18, 2013)

*Mac mini identification*

My Mac Mini identifies itself as a Macmini3,1  (from About this Mac). It*'*s known as an "Early 2009" model and can boot OSX 10.5. It*'*s going to be primarily a file server/git server; this is why I'm insisting on ZFS. Secondary usage will be a VPN.

For these purposes I really don*'*t care whether it*'*s running the i386 or amd64 version. It*'*s got 4 GB of memory and I'm aware that only 2 GB will get used in i386 mode.

There is an ancient version of ZFS that runs under OSX 10.6 and later.  This version, known as maczfs, will be the bridge between my OSX files and source and FreeBSD with its much more recent ZFS implementation.


----------



## fernandel (Sep 24, 2013)

Useful link for installing FreeBSD on Apple computers: https://glenbarber.us/2011/11/12/Dual-Booting-OS-X-and-FreeBSD-9.html


----------



## dgh3 (Jan 12, 2014)

Thanks  @fernandel. I got very familiar with installing FreeBSD 9.2 using GPT and your glenbarber post is identical to what I wound up doing.

I never got the boot process to intiate without using rEFIt on an external Firewire-mounted system.  rEFIt is a MacOS boot loader somewhat similar to GRUB. rEFIt did boot and run and initiate the FreeBSD bootstrap process on the internal drive OK.

I lost interest in running ZFS on a 4 GB i386 Mac Mini when I found the hardware recommendations for FreeNAS and found out what was really recommended for a ZFS file server. A ZFS rooted system did install and run OK once I figured out to use the i386 disk1.iso to install FreeBSD.

I then switched to a different interest, running CentOS 6 (aka Red Hat Linux). I installed this operating system and left the Mac Mini running for about 6 weeks.

The Mac Mini was running warm, with the fans on. I noticed this but didn't think much of it until the newly installed internal hard drive failed. CentOS reported a nonrecoverable SMART hard drive failure.  OSX also reported a nonrecoverable SMART drive failure when I booted off DVD and attempted to reformat the internal hard drive with OSX running DiskUtility off the install disk.

I was curious. I then booted FreeBSD 9.2 dvd1, recreated the GPT file system with `gpart destroy -F ada0`, then re-created the partitioning using the automatic menu. FreeBSD 9.2 installed OK without complaining about a SMART hard drive failure. I never tried to boot this install.

I've learned that cooling is very important on the small form factor Mac Mini, and the OSX systems have code to spin down the disks and CPU sleep to limit heat generation. This low power mode is important and not turning it on was probably a big contributor to the internal HD drive failure.

The question I have of this forum is: why isn't the failed internal drive be reported by the FreeBSD installer? Are there any checks I can run in FreeBSD LiveCD mode that would assist in debugging this situation?


----------

