Quick and easy way to try out FreeBSD Arm64 and RISC-V64 images on a x86_64 host.
Notes:
- We are going to use the pre-built VM images supplied by FreeBSD instead of installing from scratch.
- We will convert the
.raw
image files tozvols
- We will bridge the network interface on the host and use a
tap
interface on the VM
pkg install qemu u-boot-qemu-arm64 u-boot-qemu-risckv64 # Qemu + u-boot
pkg install opensbi # for RISC-V64
pkg install pixz # Fast xz file decompressor (Optional)
cd $HOME
FREEBSD_BASE_URL=https://download.freebsd.org/releases/VM-IMAGES/13.0-RELEASE
ARM64_IMAGE_FILE=FreeBSD-13.0-RELEASE-arm64-aarch64.raw
RISCV64_IMAGE_FILE=FreeBSD-13.0-RELEASE-riscv-riscv64.raw
# Fetch and extract ARM64 image
fetch ${FREEBSD_BASE_URL}/aarch64/Latest/${ARM64_IMAGE_FILE}.xz
pixz ${ARM64_IMAGE_FILE}.xz
# Fetch and extract RISC-V64 image
fetch ${FREEBSD_BASE_URL}/riscv64/Latest/${RISCV64_IMAGE_FILE}.xz
pixz ${RISCV64_IMAGE_FILE}.xz
# Assuming you have a zpool called `data`
ZPOOL_NAME='data'
ARM64_ZVOL=Qemu_ARM64_001
RISCV64_ZVOL=Qemu_RISCV64_001
# We'll create a dataset to store our zvols
zfs create -o canmount=off $ZPOOL_NAME/zvols
zfs create -V 10G $ZPOOL_NAME/zvols/$ARM64_ZVOL
zfs create -V 10G $ZPOOL_NAME/zvols/$RISCV64_ZVOL
zfs set compression=on $ZPOOL_NAME/zvols/$ARM64_ZVOL
zfs set compression=on $ZPOOL_NAME/zvols/$RISCV64_ZVOL
dd if=$HOME/$ARM64_IMAGE_FILE \
of=/dev/zvol/$ZPOOL_NAME/zvols/${ARM64_ZVOL} \
bs=1M status=progress
gpart revover /dev/zvol/$ZPOOL_NAME/zvols/${ARM64_ZVOL}
dd if=$HOME/$RISCV64_IMAGE_FILE \
of=/dev/zvol/$ZPOOL_NAME/zvols/$RISCV64_ZVOL \
bs=1M status=progress
gpart revover /dev/zvol/$ZPOOL_NAME/zvols/$RISCV64_ZVOL
ETH_DEV='em0' #Chage this to match your host's eth dev.
BRIDGE_DEV='bridge0'
ARM64_TAP='tap_arm64'
RISCV64_TAP='tap_riscv64'
ifconfig $BRIDGE_DEV create
ifconfig tap0 create
ifconfig tap0 name $ARM64_TAP
ifconfig tap1 create
ifconfig tap1 name $RISCV64_TAP
ifconfig $BRIDGE_DEV addm $ETH_DEV addm $ARM64_TAP addm $RISCV64_TAP
ifconfig $ARM64_TAP up
ifconfig $RISCV64_TAP up
ifconfig $BRIDGE_DEV up
qemu-system-aarch64 -M virt -m 512m -cpu cortex-a57 -nographic \
-bios /usr/local/share/u-boot/u-boot-qemu-arm64/u-boot.bin \
-netdev tap,ifname=${ARM64_TAP},script=no,id=net0 \
-device virtio-net-device,netdev=net0 \
-drive file=/dev/zvol/${ZPOOL_NAME}/zvols/${ARM64_ZVOL},if=virtio,cache=none,id=hd0,format=raw
qemu-system-riscv64 -M virt -m 512m -nographic \
-bios /usr/local/share/opensbi/lp64/generic/firmware/fw_jump.elf \
-kernel /usr/local/share/u-boot/u-boot-qemu-riscv64/u-boot.bin \
-netdev tap,ifname=${RISCV64_TAP},script=no,id=net0 \
-device virtio-net-device,netdev=net0 \
-drive file=/dev/zvol/${ZPOOL_NAME}/zvols/${RISCV64_ZVOL},if=virtio,cache=none,id=hd0,format=raw