Skip to content

Instantly share code, notes, and snippets.

@billti
Last active April 12, 2024 04:18
Show Gist options
  • Star 77 You must be signed in to star a gist
  • Fork 21 You must be signed in to fork a gist
  • Save billti/d904fd6124bf6f10ba2c1e3736f0f0f7 to your computer and use it in GitHub Desktop.
Save billti/d904fd6124bf6f10ba2c1e3736f0f0f7 to your computer and use it in GitHub Desktop.
ARM64 Linux on Win10

Below are the steps to get an ARM64 version of Ubuntu running in the QEMU emulator on Windows 10.

Install QEMU

Install for Windows from https://qemu.weilnetz.de/w64/ (I used qemu-w64-setup-20181211.exe)

Put C:\Program Files\qemu on your PATH, and run the below to check it's working (which will list out the CPUs the AArch64 emulator can emulate):

qemu-system-aarch64 -M virt -cpu help

Copy the Firmware and OS images

Into your working directory...

Create the configuration data image

The Ubuntu server images require configuration data be provided as an image, such as setting auth credentials.

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.

The user-data.img file was created for password authentication as outlined in https://stackoverflow.com/a/53373376

Launch the emulator from the working directory

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 2048 -cpu cortex-a72 -smp 4 -M virt -nographic -bios QEMU_EFI.fd -drive if=none,file=ubuntu-16.04-server-cloudimg-arm64-uefi1.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 2048 -cpu cortex-a72 -smp 4 -M virt -nographic - run the ARM64 virtual platform emulator with 2GB RAM and 4 Cortex-A72 cores with no GUI support.
  • -bios QEMU_EFI.fd - use the firmware downloaded above.
  • -drive if=none,file=ubuntu-16.04-server-cloudimg-arm64-uefi1.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 (asdfqwer):

ssh ubuntu@localhost -p 2222
@km-hussain-in
Copy link

km-hussain-in commented Sep 23, 2020

Expanding the image size by 8GB

shutdown the vm
qemu-img resize ubuntu-16.04-server-cloudimg-arm64-uefi1.img +8G
start the vm, ssh into it and enter the following command
sudo growpart /dev/vda 1
reboot

@shahril96
Copy link

This guide also works well with Ubuntu 20.04

@cuj
Copy link

cuj commented Jan 25, 2021

it is asking me for an ubuntu login and password, what should I type?

@gerocell
Copy link

gerocell commented Feb 2, 2021

This guide also works well with Ubuntu 20.04

Hi,

What is the login/password for the 20.04 image?

Thank you.

@BlissedEL
Copy link

This guide also works well with Ubuntu 20.04

Hi,

What is the login/password for the 20.04 image?

Thank you.

If you use the same configuration data file, the credentials are the same - login: ubuntu, password: asdfqwer.

@bb33bb
Copy link

bb33bb commented Feb 4, 2021

i tried manytimes and password is not ok , some one have the problem?
ubuntu
asdfqwer

@iamshivambhandari
Copy link

Hi. Great Tutorial. One doubt. How to access files in Windows host from the Qemu Emulator?

@oijkn
Copy link

oijkn commented May 25, 2022

Thank you for this tuto, can you tell me how I can configure the interface eth0 to communicate with my local network in subnet 192.168.1.0/24, please?

For people who want to configure network, there is the command that I use :
qemu-system-aarch64 -m 2048 -cpu cortex-a72 -smp 4 -M virt -nographic -bios QEMU_EFI.fd -drive if=none,file=ubuntu-16.04-server-cloudimg-arm64-uefi1.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:222-:22,id=net0,net=192.168.1.0/24,dhcpstart=192.168.1.10,dns=192.168.1.1

@tmoonlight
Copy link

i tried manytimes and password is not ok , some one have the problem? ubuntu asdfqwer

me too....

@hackertron
Copy link

internet is not working for me. any suggestions ?

@devsec110
Copy link

what is the password for root?

@richardkmatchfit
Copy link

Hi, I've got the above working fine (Ubuntu server guest, Arm64, running on QEMU/Windows host.

I need to do some development with a small Linux platform, can you give me some clues how to run a 32-bit ARM linux image with an emulated device with a GUI? Thanks.

@vadim-dem
Copy link

I had a similar problem with login in the command line box where I started qemu-system-aarch64, but after my attempt to login from another terminal window by "ssh ubuntu@localhost -p 2222", I got a "Generating locales (this might take a while)..." message in the first terminal, and after all ssh host key generation related messages I was able to login at the first terminal too

@thomas172
Copy link

how do I import and open a binary file?

@daparic
Copy link

daparic commented Oct 4, 2023

I tested this in Windows 11 and using ubuntu-22.04-server-cloudimg-arm64.img it works. All the rest remains as-is. I owe you a beer, thank you.

@daparic
Copy link

daparic commented Oct 5, 2023

Expanding the image size by 8GB

shutdown the vm qemu-img resize ubuntu-16.04-server-cloudimg-arm64-uefi1.img +8G start the vm, ssh into it and enter the following command sudo growpart /dev/vda 1 reboot

Works in ubuntu-22.04-server-cloudimg-arm64.img right away without any subsequent growpart anymore. Thank you.

@MagicDev0428
Copy link

hello, thank you very much.
I successfully installed above environment. But now I need to increase disk size of image. how can I find above image file on my Ubuntu and how to increase the disk size?

@8nhuman8
Copy link

8nhuman8 commented Oct 23, 2023

Works well on Windows 11, just had to wait some time to load cloud-init (wasn't able to login with those credentials)

@jimailo
Copy link

jimailo commented Nov 1, 2023

It works, entered the system without problems

@vurdalaque
Copy link

works like a charm for ubuntu-22.04-server-cloudimg-arm64.img
only difference made - allow others host systems to connect via ssh by changing hostfwd=tcp::2222-:22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment