Below are the steps to get an ARM64 version of Ubuntu running in the QEMU emulator on Windows 10.
Install for Windows from choco package manager
choco install qemu --version=2021.5.5 -confirm
PS D:\arm64-ubuntu2004\qemu> qemu-system-aarch64 --help
Check appending Window System PATH C:\Program Files\qemu
applied.
Then typing the terminal with some commands.
qemu-img --help
qemu-system-aarch64 -M virt -cpu help
Into your working directory...
- Copy the
ubuntu-20.04-server-cloudimg-arm64.img
OS image from https://cloud-images.ubuntu.com/releases/20.04/release/ - Copy the
QEMU_EFI.fd
firmware image from https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/ - Download
user-data.zip
from below zip raw file on this Gist. then, extract to user-data.img.
#cloud-config
password: asdfqwer
chpasswd: { expire: False }
ssh_pwauth: True
Login first password will be asdfqwer
The Ubuntu server images require configuration data be provided as an image, such as setting auth credentials.
We need input password below example <WE_HAVE_PASSWORD_MUST_BE_CREDENTIAL>
.
sudo apt -y install cloud-image-utils
cat >user-data <<EOF
#cloud-config
password: <WE_HAVE_PASSWORD_MUST_BE_CREDENTIAL>
chpasswd: { expire: False }
ssh_pwauth: True
EOF
cloud-localds user-data.img user-data
The tool used to convert the config text file into an image file only runs on Linux, so I've attached a user-data.img
file (and the text file used to create it) in a zip file to this Gist.
Extract the user-data.img
file to the working directory.
In user-data text file contents.
#cloud-config
password: asdfqwer
chpasswd: { expire: False }
ssh_pwauth: True
The user-data.img
file was created for password authentication as outlined in https://stackoverflow.com/a/53373376
If booting is confirmed, we will power off for a while and change the storage capacity.
Resize your image in the host what you want. :)
qemu-img resize ubuntu-20.04-server-cloudimg-arm64.img +32G
Start the vm, ssh into it and enter the following command
sudo growpart /dev/vda 1
Run the below to boot the image, you will some some benign errors at startup. Wait until the output settles down (even after you see the login prompt, as the post-boot config may not have completed yet).
qemu-system-aarch64 -m 4096 -cpu cortex-a72 -smp 4 -M virt -M gic_version=3 -nographic -bios QEMU_EFI.fd -drive if=none,file=ubuntu-20.04-server-cloudimg-arm64.img,id=hd0 -device virtio-blk-device,drive=hd0 -drive file=user-data.img,format=raw -device virtio-net-device,netdev=net0 -netdev user,hostfwd=tcp:127.0.0.1:2222-:22,id=net0
qemu-system-aarch64 -m 16384M,slots=4 -cpu cortex-a72 -smp cpus=8 -object memory-backend-ram,id=mem0,size=4096M -numa node,cpus=0-1,nodeid=0,memdev=mem0 -object memory-backend-ram,id=mem1,size=4096M -numa node,cpus=2-3,nodeid=1,memdev=mem1 -object memory-backend-ram,id=mem2,size=4096M -numa node,cpus=4-5,nodeid=2,memdev=mem2 -object memory-backend-ram,id=mem3,size=4096M -numa node,cpus=6-7,nodeid=3,memdev=mem3 -M virt -M gic_version=3 -nographic -bios QEMU_EFI.fd -drive if=none,file=ubuntu-18.04-server-cloudimg-arm64.img,id=hd0 -device virtio-blk-device,drive=hd0 -drive file=user-data.img,format=raw -device virtio-net-device,netdev=net0 -netdev user,hostfwd=tcp:127.0.0.1:2222-:22,id=net0
Long command need indent, enter.
We can check below.
qemu-system-aarch64 -m 4096 -cpu cortex-a72 -smp 4 -M virt -M gic_version=3 -nographic \
-bios QEMU_EFI.fd \
-drive if=none,file=ubuntu-20.04-server-cloudimg-arm64.img,id=hd0 \
-device virtio-blk-device,drive=hd0 \
-drive file=user-data.img,format=raw \
-device virtio-net-device,netdev=net0 \
-netdev user,hostfwd=tcp:127.0.0.1:2222-:22,id=net0
To break down these lines:
qemu-system-aarch64 -m 4096 -cpu cortex-a72 -smp 4 -M virt -M gic_version=3 -nographic
- run the ARM64 virtual platform emulator with 4GB RAM and 4 Cortex-A72 cores with no GUI support.
-M virt -M gic_version=3
- use the QEMU's Virt DTB mem map and GIC v3.
-bios QEMU_EFI.fd
- use the firmware downloaded above.
-drive if=none,file=ubuntu-20.04-server-cloudimg-arm64.img,id=hd0
- use the Ubuntu image file
-device virtio-blk-device,drive=hd0
- mount drive from above as a block device
-drive file=user-data.img,format=raw
- use the configuration data image file
-device virtio-net-device,netdev=net0
- create a virtual network device
-netdev user,hostfwd=tcp:127.0.0.1:2222-:22,id=net0
- set up the networking stack and forward the SSH port
Then from a good Terminal emulator (I recommend the new Windows Terminal app with one of the Powerline fonts) you can connect over SSH with the below, and the configured password (sample file have asdfqwer
):
Do terminal with ssh.
ssh ubuntu@localhost -p 2222
Upload my-file.sh
from host to vm.
scp -P 2222 my-file.sh ubuntu@localhost:/home/ubuntu
Download my-file.sh
from vm to host.
scp -P 2222 ubuntu@localhost:/home/ubuntu/my-file.sh .
Building the Kernel
You must set the following flags when you build the kernel:
Install kdump and crash utility
Kdump setup
crashkernel=512M-:192M 이 들어가 있어야 함.
reboot 후 확인하기
Login root
is_kdump_ok.sh
스크립트 참고dbgsym-ubuntu2004.sh
스크립트 참고Let kernel panic