Outlined below is a general technique for running FreeBSD/arm (32-bit) in a chroot running on a FreeBSD/amd64 host. It will focus running FreeBSD 10.4, but can be used for any version. A user in the community is trying very hard to update a 10.4 machine to something newer and needs to build a new shell and is having trouble. So I went through these steps to create an environment where I could build it for him. I thought I'd document them for everybody.
Below, any prompt that starts with '%' is done in tcsh. Adjust for your shell, but I don't think any of the commands change.
When running as root, I use sudo.
One could easily open up your system in other ways, but for a quick note I'm ignoring that.
I also generally omit output, except where it matters.
mdconfig
produces the name of the device created, for example, and that needs to be used in subsequent steps.
I've used crazy output to minimize damage to most system.
I use sudo
to indicate commands run by root, but you can do it however you feel comfortable (I also assume your preferred way of running as root is already on the system and I don't have to explain that).
Commands run as root can be dangerous, so you are doing at your own risk.
I downloaded this from FreeBSD's archival old version server. I selected the RPI-B image, but you can select whatever you want. I had thought to boot FreeBSD 10 with the qemu system rpi emulator, but it doesn't work with the linux instructions because I couldn't get -kernel to work with any of u-boot.img, kernel, kernel.gz.tramp. So I pivoted and thought I'd use qemu's bsd-user to do the job. For newer versions that support armv7, I'd be more inclined to grab those. Note, the output from mdconfig matters, so if yours is different, adjust the instructions following accordingly.
% mkdir ~/arm10
% cd ~/arm10
% fetch http://ftp-archive.freebsd.org/pub/FreeBSD-Archive/old-releases/arm/armv6/ISO-IMAGES/10.4/FreeBSD-10.4-RELEASE-arm-armv6-RPI-B.img.xz
% xz -d FreeBSD-10.4-RELEASE-arm-armv6-RPI-B.img.xz
% sudo mdconfig FreeBSD-10.4-RELEASE-arm-armv6-RPI-B.img
md123
% sudo mount /dev/md123s2a /mnt
% sudo tar -C /mnt -c -f - | tar xvf -
% sudo umount /mnt
% sudo mdconfig -d -u 123
To run the armv6/armv7 binaries, you'll need an emulator.
I used the old qemu-user-static port based on a fork of qemu 3.10 to do this.
It works well, even with old versions of FreeBSD.
I also add qemu_arm_static_enable=YES to my /etc/rc.conf
on the systems I run, but you don't have to do that unless you want things to survive reboot.
% sudo pkg install qemu-user-static
% sudo service qemu_user_static onestart
% mkdir -p ~/arm10/usr/local/bin
% cp /usr/local/bin/qemu-arm-static ~/arm10/usr/local/bin
Now you are ready to rumble... I mean, test things out. If everything worked, then you should the same thing I do below:
% sudo chroot ~/arm10 /bin/sh
# uname -a
FreeBSD rebo 15.0-CURRENT FreeBSD 15.0-CURRENT #58 main-n267479-18469e00dc45-dirty: Wed Jan 10 16:31:01 MST 2024 imp@rebo:/usr/home/imp/obj/usr/home/imp/git/head/amd64.amd64/sys/GENERIC arm
# uname
FreeBSD
# uname -p
armv6
#
You can easily convert this tree into a jail, though that's a bit more involved. When I need to do this for more modern, supported versions, I just use poudriere.