Skip to content

Instantly share code, notes, and snippets.

@wheelcomplex
Forked from dch/free-mbp.md
Created June 3, 2016 08:37
Show Gist options
  • Save wheelcomplex/3e0a4b0d685e059381859f59a840e572 to your computer and use it in GitHub Desktop.
Save wheelcomplex/3e0a4b0d685e059381859f59a840e572 to your computer and use it in GitHub Desktop.
FreeBSD-11.0-CURRENT with zfs boot on a UEFI-based Apple MacBook Pro early 2011 15" 8 core 2GHz i7

Intro

The goal is to be able to share OSX and FreeBSD while we nut out all the tricky pieces, and use the zpool that FreeBSD boots from, in OSX as our main working storage.

You'll need an MBP with dual drives, in my case, SSDs. This will almost certainly work with a single drive, but the partitioning is a wee bit complicated.

Build and install zfsosx from source.

Backup & be prepared for data loss etc.

Create the zpool

zpool create -f -o ashift=12 -O atime=off -O compression=lz4 -R /zroot zroot /dev/disk1
diskutil list disk1
  /dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *512.1 GB   disk1
   1:                        ZFS                         512.1 GB   disk1s1
   2: 6A945A3B-1DD2-11B2-99A6-080020736631               8.4 MB     disk1s9
# import pool again without mounting any datasets by default
zpool export zroot
zpool import -N -R /zroot zroot

Create the FreeBSD installation image

From a previous zfs-root installation of FreeBSD, make a zpool image to recover from. You can of course send this over ssh if required.

zfs snapshot -r zroot@post-install
zfs send -i -R zroot@post-install | xz -9 > zroot.post-install.zfs.xz

Restore the FreeBSD image

zpool umount -a
xzcat /var/tmp/zroot.post-install.zfs.xz| zfs recv -Fvu zroot

There will be a few warnings, e.g.:

attempting destroy zroot
failed - trying rename zroot to zrootrecv-730-1
failed (2) - will try again on next pass
receiving full stream of zroot@post-install into zroot@post-install
received 41.7KB stream in 1 seconds (41.7KB/sec)
receiving full stream of zroot/tmp@post-install into zroot/tmp@post-install
received 46.8KB stream in 1 seconds (46.8KB/sec)
receiving full stream of zroot/var@post-install into zroot/var@post-install
received 2.08MB stream in 1 seconds (2.08MB/sec)
receiving full stream of zroot/var/mail@post-install into zroot/var/mail@post-install
received 41.7KB stream in 1 seconds (41.7KB/sec)
receiving full stream of zroot/var/crash@post-install into zroot/var/crash@post-install
received 43.0KB stream in 1 seconds (43.0KB/sec)
receiving full stream of zroot/var/tmp@post-install into zroot/var/tmp@post-install
received 43.0KB stream in 1 seconds (43.0KB/sec)
receiving full stream of zroot/var/log@post-install into zroot/var/log@post-install
received 166KB stream in 1 seconds (166KB/sec)
receiving full stream of zroot/usr@post-install into zroot/usr@post-install
received 41.7KB stream in 1 seconds (41.7KB/sec)
receiving full stream of zroot/usr/home@post-install into zroot/usr/home@post-install
received 41.7KB stream in 1 seconds (41.7KB/sec)
receiving full stream of zroot/usr/src@post-install into zroot/usr/src@post-install
received 41.7KB stream in 1 seconds (41.7KB/sec)
receiving full stream of zroot/usr/ports@post-install into zroot/usr/ports@post-install
received 41.7KB stream in 1 seconds (41.7KB/sec)
receiving full stream of zroot/ROOT@post-install into zroot/ROOT@post-install
received 41.7KB stream in 1 seconds (41.7KB/sec)
receiving full stream of zroot/ROOT/default@post-install into zroot/ROOT/default@post-install
received 798MB stream in 16 seconds (49.9MB/sec)
local fs zroot does not have fromsnap (-v in stream); must have been deleted locally; ignoring
local fs zroot/ROOT does not have fromsnap (-v in stream); must have been deleted locally; ignoring
local fs zroot/ROOT/default does not have fromsnap (-v in stream); must have been deleted locally; ignoring
local fs zroot/usr does not have fromsnap (-v in stream); must have been deleted locally; ignoring
local fs zroot/usr/home does not have fromsnap (-v in stream); must have been deleted locally; ignoring
local fs zroot/usr/ports does not have fromsnap (-v in stream); must have been deleted locally; ignoring
local fs zroot/usr/src does not have fromsnap (-v in stream); must have been deleted locally; ignoring
local fs zroot/var does not have fromsnap (-v in stream); must have been deleted locally; ignoring
local fs zroot/var/mail does not have fromsnap (-v in stream); must have been deleted locally; ignoring
local fs zroot/var/tmp does not have fromsnap (-v in stream); must have been deleted locally; ignoring
local fs zroot/var/crash does not have fromsnap (-v in stream); must have been deleted locally; ignoring
local fs zroot/var/log does not have fromsnap (-v in stream); must have been deleted locally; ignoring
local fs zroot/tmp does not have fromsnap (-v in stream); must have been deleted locally; ignoring

Make it boot

# inform FreeBSD what the bootable dataset is
zpool set bootfs="zroot/ROOT/default" zroot

Set up refind

  • use diskutil to mount the hidden EFI partition on /dev/disk0

  • copy FreeBSD's boot1.efi to a new dir /Volumes/EFI/EFI/freebsd/

  • refind may need tweaking, if so a stanza like the following may help:

    menuentry "FreeBSD 11.0-CURRENT" {
        loader /efi/freebsd/boot1.efi
        graphics off
    	  icon /efi/refind/icons/os_freebsd.icns
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment