So I had an old Mac Mini (the G4) laying around which I have long wanted to find some use for. As my internet connection is slow (I live in Spain) and I wanted to do some sort of traffic shaping so that I could still stream media while downloading stuff, especially when leaving torrents and steam to download overnight while I stream myself some Husky before going to bed.
Long story short, I have purchased an USB Ethernet Adapter from DealExtreme (Branded as LogiLink) abd installed a 12.04.2 LTS Precise Pangolin version of Ubuntu Server, mainly because it’s easy to install and ppc version was available. However, it didn’t do everything I wanted it to do easily, so I started looking for options and pfSense got my attention. It’s based on FreeBSD so I should be able to run it on my PowerPC based device, however there are no installers for it so I would have to build it myself. Ok, let’s do it.
The first thing I needed was to get the FreeBSD installed on the MacMini. I checked the FreeBSD ftp archive and found that version 8.1 is available. As pfSense 2.0.1 is based on FreeBSD 8.1 I have decided that this is what I’m going to use and downloaded the FreeBSD-8.1-RELEASE-powerpc-disc1.iso from here, burned it on to a CD, stuck it into the mac mini, booted it and proceeded with the installation.
Well, not really. I didn’t expect it to work right away and it didn’t. First of all, the installer did not even boot, getting stuck on reading the CD and coming up with big_read errors on acd1. After some research it turned out that it’s because of (Correct me if I’m wrong) no DMA implementation for ATA controler in G4, so I had to interrupt the startup to get to the console prompt and type the following:
After that the installer booted just fine and I have picked the Standard installation and was greeted with a Disk Label Editor which showed me my existing partitions from the previous ubuntu installation. Unfortunately, it could not delete them and they were using all the disk space so I had to get rid of them before proceeding. According to the documentation, Disk Label editor should run after Fdisk but that wasn’t the case, fdisk did not run and I could not find a way to get to it. Fortunately, the FreeBSD installer has an option to start the Emergency Holographic Shell (in Extras). Pick that option, wait for it to start the shell and then press alt+f4 (ikr) to get to the shell. From here you will be able to run gpart which will do what you need. Below are sample commands that you can use (it WILL wipe all your stuff from the drive, so make sure you’ve got everything you need backed up)
#show us what we've got
# wipe everything from the drive
gpart destroy ad1
# re-create the geom
gpart create ad1
# create partitions, you might want a different setup
# you have to have apple_bootstrap partition, this is where the bootloader will go
gpart add -s 800K -t Apple_bootstrap ad1
# I will use the 5G partition for root /
gpart add -s 5G -t freebsd-ufs ad1
# 4g partition for swap
gpart add -s 4G -t freebsd-swap ad1
# 20 gigs for /usr
gpart add -s 20G -t freebsd-ufs ad1
# rest of the drive for /var
gpart add -t freebsd-ufs ad1
After the above, I had to reboot (remember the DMA trick) for the Disk Label editor to see the changes (I have later found that pressing “U” for Undo in disk label editor will refresh the layout) and go through each partition with a C key to “create it” and the installation would start and succeed.
I have followed the pfSense appliance build instructions from pfSense devwiki. I will post the sequence I have used (with slight adjustments I had to do) here, but you should see the link if you need details.
I should mention that running the below takes forever, especially the build_pfPorts part. I had to leave it running overnight.
mkdir -p /usr/src/crypto/openssl/ssl
echo "WITHOUT_X11=yo" >> /etc/make.conf
echo "OPTIONS_UNSET=X11" >> /etc/make.conf
echo "BATCH=yo" >> /etc/make.conf
mkdir -p /home/pfsense/pfSenseGITREPO /usr/pfSensesrc
portsnap fetch extract
cd /usr/ports/textproc/expat2 && make depends install
cd /usr/ports/devel/git && make depends install
cd /usr/ports/sysutils/fastest_cvsup/ && make depends install
cd /home/pfsense && git clone git://github.com/pfsense/pfsense-tools.git tools
cd /home/pfsense && git clone git://github.com/pfsense/freesbie2.git freesbie2
cd /home/pfsense/tools/builder_scripts && chmod a+rx *.sh
csup -h `fastest_cvsup -c tld -q` /usr/share/examples/cvsup/standard-supfile
rm -rf /home/pfsense/installer
scripts/get_bsdinstaller.sh ; scripts/rebuild_bsdinstaller.sh
The above MOSTLY worked for me, except for the actual build_iso part which failed. After some searching I’ve found a bug report that was very close to what I was seeing, albeit for a different BSD version but the fix worked for me. All I had to do was build the cdrtools (CD burning tools) manually. To do this use
make install clean
After that I was able to run
That should do the trick and you should have a pfSense iso available. You can also build other pfSense versions using scripts in the /home/pfsense/tools/builder_scripts.