Tuesday, February 05, 2013

FreeBSD on the Pi

I've used FreeBSD for quite some time but can't say that I ever came anywhere close to mastering it.
Nevertheless, I'm interested in testing as many OSes as possible on the Pi (well, at least the more serious ones. I've left out Puppy Linux, Open9 and RiscOS)

Of course, just like Gentoo, FreeBSD by-and-large compiles everything from source, although a partial package-manager is available.
Because the CPU is so miserably small and slow, your Pi is going to spend a lot of time unavailable while it wheezes and puffs its way to another install.

Burning the SDcard

Nevertheless, a FreeBSD image is available ready to be dd'ed onto an SDCard.
I even splashed out on a SanDisk Extreme Pro 8GB card in an effort to remove anything that might slow down performance.

Burning the image to the SDCard went without any problems as did the subsequent boot.

Next, I used portsnap to make ports collection available and then created a user (adduser).
Again, no problems.

Increasing partition size

The install results in two partitions (in Linux-speak) just as with all other RPi OSes. One for the /boot and the other for everything else.
However, the larger partition occupied only about 3.5GB of the more than 7GB available to it.
OK, so it's just a matter of increasing the size of the partition.
Where's the problem?
Well, in FreeBSD it's nowhere near as easy to fiddle around with partitions (or slices as they're called in FreeBSD) as it is in Linux.

While GParted can "see" ufs (the FreeBSD default filesystem) partitions, it cannot really do anything with them.
I spent quite some time playing around with this problem without getting anywhere.
This post from one of the FreeBSD community's main cognoscenti is interesting and basically concedes that there's simply no straightforward way of changing the partition size.

However, I then came across this very recent blog post which seemed to solve everything as it deals with increasing a FreeBSD partition on a SDCard for use in a RPi.
Can't really get much closer than that.
And it works, although you need patience and perseverance.
However, there was one rather awkward problem, the modified SDCard just wouldn't boot.
And I tried it twice.
However, as you can see from the comments to the above post, the post author doesn't seem to have had this problem.

OK, so I dd'ed the image again to my SDcard and checked that it truly booted before trying to increase the partition size.
And it booted without problem.
Now, however, before messing around with gpart, I used this great howto to dump my FreeBSD slice to a usb key (formatted to FAT32) as a bz2 compressed file.

Back to gpart and increased the partition size to take up practically all space on the card.
Now, I used the above howto to restore the dump back to the enlarged partition. This went very smoothly.
Incidentally, although I'm not sure it was necessary, I made a tar.gz of the /boot partition to the same usb-key. After increasing the size of the main partition, I replaced everything back to the /boot from the tar.gz file.

And now the boot. Yes, it boots perfectly without any problems.
Although the gpart blog post suggests it's necessary, I didn't have to use the growfs function once the Pi had booted.
When I ran

df -h
it showed that my partition was close to 7GB in size so everything looked good.

Setting up a Desktop Environment

Now, I need to install a DE (Desktop Environment).
First I need X11.
However, this is where the good news ends.
Although I tried both x11/xorg and x11-servers/xorg-server, neither compiled.
The first failed because of a gobject-introspection error.
I have the impression that the second failed because there's no Clang (cc) compiler in the kernel.
I did indeed try to install clang from ports (although I had to download both the clang and llvm sources from the Fedora repo).
However, even then the compile failed so I just gave up as it seems the main problem is that a lot of this stuff just isn't available for the moment for arm-architecture.

For the moment, FreeBSD on the Pi is pretty half-baked but at least it's a start.


No comments:

Post a Comment