Run Ubuntu in QEMU on macOS (Apple Silicon)
Contents
This post is a guide to run Ubuntu in QEMU on macOS (Apple Silicon).
The laptop in this post is MacBook Pro (13-inch, M1, 2020)
.
The OS is macOS 12.4 21F79 arm64
.
Prerequisite
- ubuntu-22.04-live-server-arm64.iso
- QEMU >= 7.0
- vde_vmnet >= v0.6.0 (DEPRECATED: Use the successor to set the networking up.)
- macOS >= Monterey (Apple Silicon)
Preparation
|
|
Test
|
|
If the test is failed, try to reload the launch plists manually to make sure the processes (vde_switch
and vde_vmnet
) are running.
|
|
Install Ubuntu
Download QEMU EFI.
1
curl -L https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/QEMU_EFI.fd -o QEMU_EFI.fd
Create an image.
1
qemu-img create -f raw -o preallocation=full ubuntu.img 40G
Boot QEMU to install Ubuntu.
1 2 3 4 5 6 7 8 9
qemu-system-aarch64 \ -machine virt,accel=hvf \ -cpu host \ -smp 8 \ -m 8G \ -drive if=virtio,format=raw,file=./ubuntu.img \ -cdrom <path/to/ubuntu iso> \ -nographic \ -bios QEMU_EFI.fd
Boot Ubuntu in QEMU
|
|
Test
Use the command lspci
to check whether the network device is ready.
|
|
Configure the networking
Get the name of the network device.
1 2 3 4 5 6
$ ip link 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: enp0s1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
We can see the name of the network device is
enp0s1
.Configure the netplan.
i. Create the configuration file.
1
sudo touch /etc/netplan/enp0s1-config.yaml
ii. Edit the
/etc/netplan/enp0s1-config.yaml
using the following content.1 2 3 4 5 6 7 8 9 10 11
network: version: 2 ethernets: enp0s1: dhcp4: false addresses: [192.168.105.2/24] nameservers: addresses: [192.168.105.1] routes: - to: default via: 192.168.105.1
Test the netplan.
1 2 3 4
sudo netplan try # Ping the gateway. ping 192.168.105.1
Log into the server by SSH
|
|
Author Adonis Ling
LastMod 2024-05-27 (c60dd84)