Suppose you have a nice PowerMac G5 big beast around and want to install a modern operating system on it. Suppose that you want FreeBSD to run on it. Suppose that you would like to use ZFS as much as possible, say to use the machine as a NAS.

If all of the above apply to you, you have come to the right place! Read on for how I got FreeBSD 10.0-CURRENT with a ZFS root to work on a PowerMac G5. I am pretty sure the instructions here apply to other PowerPC-based machines as well, although the specific details on how to set up the boot loader most likely differ.

Note that I performed this procedure from a FreeBSD installation residing on the second drive of the machine. I suppose everything described here can be done in the same manner from the live shell provided by the installer, although the paths and the ordering of the instructions might be slightly different. (Tip: you might want to reserve the first few GB of your drive for a plain FreeBSD installation to use for recovery-purposes only, and you can later use this simplified system to bootstrap the real one as described below.)


The following instructions assume that the disk onto which FreeBSD will be installed is ada0 and that the whole disk is devoted to FreeBSD. In other words: the procedure will wipe all data on ada0; you have been warned.

For reference, the disk layout used in the procedure below looks as in the following table. This is based on a 650G hard disk with 6G of RAM:

Index Device Label Type Size
1 ada0s2 BOOTSTRAP apple-boot 800K
2 ada0s3 BOOT freebsd-ufs 512M
3 ada0s4 SWAP freebsd-swap 12G
4 ada0s5 ROOT freebsd-zfs Remaining

The step-by-step instructions:

  1. Initialize the partition table in ada0:

    gpart create -s APM ada0
  2. Create an Apple_Bootstrap partition, a boot partition, a swap partition, and the ZFS pool:

    gpart add -l BOOTSTRAP -s 800K -t apple-boot ada0
    gpart add -l BOOT -s 512M -t freebsd-ufs ada0
    gpart add -l SWAP -s 12G -t freebsd-swap ada0
    gpart add -l ROOT -t freebsd-zfs ada0
  3. Install the stage one bootloader onto the BOOTSTRAP partition:

    gpart bootcode -p /boot/boot1.hfs -i 1 ada0
  4. Load the ZFS modules:

    kldload /boot/kernel/opensolaris.ko
    kldload /boot/kernel/zfs.ko
  5. Create the ZFS pool:

    mkdir /boot/zfs
    zpool create zroot /dev/ad0s5
    zpool set bootfs=zroot zroot
  6. Create any file systems you desire under the new pool. I am only going to separate /home in this post to prevent a lot of verbosity. However, the original instructions in which I am basing this post contain a more detailed list on what you might want to split out:

    zfs create setuid=false zroot/home
  7. Create and mount the /boot file system:

    newfs /dev/ada0s3
    mkdir /zroot/boot
    mount /dev/ada0s3 /zroot/boot
  8. Unpack the desired sets:

    for s in base docs kernel; do
    tar -xzvpf .../${s}.tgz -C /zroot
    done
  9. Create a new /zroot/etc/rc.conf with at least the following:

    zfs_enable="YES"
    hostname="your.name.example.com"
    ifconfig_gem0="DHCP"
  10. Create a new /zroot/boot/loader.conf with at least the following:

    zfs_load="YES"
    vfs.root.mountfrom="zfs:zroot"
  11. Install the ZFS boot cache:

    cp /boot/zfs/zpool.cache /zroot/boot/zfs/zpool.cache
  12. Perform basic system setup:

    chroot /zroot
    # IN THE CHROOT
    passwd
    tzsetup
    cd /etc/mail
    make aliases
    exit
  13. Create a new /zroot/etc/fstab with at least the following (although the tmp is optional):

    # Device    Mountpoint  FStype  Options Dump    Pass#
    /dev/ada0s3 /boot ufs rw 1 1
    /dev/ada0s4 none swap sw 0 0
    tmpfs /tmp tmpfs rw 0 0
  14. Fix up the /boot file system. This is horrible but is the best I've gotten so far. The problem is that the boot.hfs loader seems to have /boot/loader hardcoded in it, which obviously breaks when /boot is a separate partition. A symlink of . to boot does not work, unfortunately. So:

    cd /zroot/boot
    mkdir boot
    cd boot
    ln -s ../* .
    rm loader ; ln ../loader loader
  15. Unmount file systems and finish the ZFS setup:

    umount /zroot/boot
    zfs unmount -a
    zfs set mountpoint=legacy zroot
    zfs set mountpoint=/home zroot/home
  16. Reboot, enter OpenFirmware (Option+Command+O+F) and set up the machine for automatic booting:

    setenv auto-boot? true
    setenv boot-device sd0:2,\:tbxi
    reset-all

And that should be it! A fully-manual installation of FreeBSD just to get ZFS up and running for the root file system... but I hope you enjoy the results :-)

For further reference, here are the original instructions on which the above steps are based:

Comments from the original Blogger-hosted post: