Skip to content

Emulated Environment Setup

Xiaoguang Wang edited this page Oct 24, 2023 · 4 revisions

This page demonstrates how to get an x86-64 + aarch64 emulated environment setup. It is very important that both x86-64 and aarch64 kernels are of the same version and have the same CGROUPs.

You can also get vanilla Ubuntu cloud images from here or use the following command to download the VM images from the command line:

wget https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64.img
wget https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-arm64.img

Install the QEMU emulator for x86-64 and aarch64 guests on an x86-64 host:

sudo apt-get install qemu-system-x86-64
sudo apt-get install qemu-system-arm qemu-efi

Before launching VMs, you need to follow this link to set up the password for Ubuntu images.

Once the VM password is set, use the following command to run the x86-64 VM:

sudo qemu-system-x86_64 \
-enable-kvm -cpu host -smp 2 -m 4096 -nographic \
-drive id=root,media=disk,file=focal-server-cloudimg-amd64.img \
-device e1000,netdev=net0 -netdev user,id=net0,hostfwd=tcp:127.0.0.1:5555-:22

Use the following command to launch the aarch64 VM:

qemu-system-aarch64 \
-smp 2 -m 1024 -M virt -cpu cortex-a57 -nographic \
-bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd \
-device virtio-blk-device,drive=image -drive if=none,id=image,file=focal-server-cloudimg-arm64.img \
-device e1000,netdev=net0 -netdev user,id=net0,hostfwd=tcp:127.0.0.1:5556-:22

This hosts the x86-64 and aarch64 cloud images and forwards their SSH port to 5555 and 5556, respectively.