10

How to run FreeBSD/ARM64 in a VM on an ARM Linux server

 3 years ago
source link: https://mightynotes.wordpress.com/2020/08/04/how-to-run-freebsd-arm64-in-a-vm-on-an-arm-linux-server/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

How to run FreeBSD/ARM64 in a VM on an ARM Linux server

external-content.duckduckgo.com_.png?w=800

COSCUP 2020 just ended and I learned a lot in the two days. One of the many cool things is that I can actually run FreeBSD on my server! So be it inside a VM. Whatever, it is still very cool to have actual UNIX running on ARM. Friends in the FreeBSD community at COSCUP provided a ton of assistant. I’ll probably never figure out how to make FreeBSD boot in a ARM VM. A huge thank-you to everyone that helped.

Let’s clarify now. I mean we’ll be running FreeBSD for Aarch64 while using KVM. Running the AMD64 version using QEMU will be too easy. Yet even though FreeBSD officially supports Aarch64 on various hardware and QEMU. ARM being ARM, that (Linux) kernel configurations differ very much from vendor to vendor. It still took me a while to boot FreeBSD properly.

Booting FreeBSD

Even tho the document states there’s images for Aarch64. It is never linked to in FreeBSD’s official website. I had to navigate myself to download.freebsd.org and find the file. Then decompress it after downloading.

wget wget https://download.freebsd.org/ftp/releases/VM-IMAGES/12.1-RELEASE/aarch64/Latest/FreeBSD-12.1-RELEASE-arm64-aarch64.qcow2.xz
unxz FreeBSD-12.1-RELEASE-arm64-aarch64.qcow2.xz

Now we need a UEFI image. (Or U-Boot, I didn’t bother with it) My installation of QEMU doesn’t come with one nor I can find one in my package manager. Some Googling turns up one.

wget https://lxr.missinglinkelectronics.com/qemu/+save\=pc-bios/edk2-aarch64-code.fd.bz2

Then expand the rootfs since the default size is only big enough to hold a minimal system. The system is configured to resize the rootfs when it sees disk space growth. I gave it an extra 80G.

qemu-img resize FreeBSD-12.1-RELEASE-arm64-aarch64.qcow2 +80G

Now we are ready to boot FreeBSD. The parameters I use are more or less the ones in FreeBS

Now we are ready to boot FreeBSD. The parameters I use are more or less the ones in FreeBSD’s documents. And modified a bit to make it work on my machine (ex: virtio doesn’t work for unknown reasons).

qemu-system-aarch64 -m 4096M -cpu host,pmu=off -M virt,gic-version=3 --enable-kvm -smp 8 \
-bios edk2-aarch64-code.fd -serial telnet::4444,server -nographic \
-drive file=FreeBSD-12.1-RELEASE-arm64-aarch64.qcow2,id=hd0 \
-device e1000,netdev=net0 \           
-netdev user,id=net0

QEMU is listening on localhost:4444 for a telent connection. Run telnet localhost 4444 to boot the system. And that’s it. FreeBSD is running in a VM on an ARM server!

image.png?w=768
FreeBSD on ARM64!

Oh, remember to run shutdown -p now to shutdown FreeBSD. Unlike Linux, shutdown now doesn’t perfrorm a ACPI shutdown. It just drops you into single user mode. And BSD commands tends to stop parsing arguments after the first non-argument. rm directory -r on Linux removes directory recursively. But on BSD it will removes directory and -r non recursively.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK