After a lot of online research, this is a summary of the steps I had to take to finally emulate Raspbian (Buster version) on Ubuntu.
For more information, check the sources in the guide and at the bottom.
Last tried Jan 2023 on a Lubuntu 22.04 LTS VM on Virtualbox
$ sudo apt update
$ sudo apt install qemu-system-arm qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virtinst libvirt-daemon virt-manager
-
Download 2022-09-22-raspios-buster-armhf-lite.img.xz from Download Page or Download Link.
-
Extract using $
unxz 2022-09-22-raspios-buster-armhf-lite.img.xz
- $
qemu-img convert -f raw -O qcow2 2022-09-22-raspios-buster-armhf-lite.img 2022-09-22-raspios-buster-armhf-lite.qcow2
- Available at Dhruv Vyas's Repo.
- Choose Import existing disk image.
- Under Architecture Options:
- Select Architechture: armv6l.
- Select Machine Type: versatilepb.
- Click Forward.
- Under Provide the existing storage path:
- Click Browse.
- Click Browse Local.
- Go to the downloaded OS image location and select the OS Image (.img or .qcow2).
- Under Choose the operating system you are installing: select Generic or unknown OS. Usage is not recommended.
- Click Forward.
- Input Memory: 256.
- Input CPU: 1.
- Click Forward.
- Rename VM if you like.
- Toggle Customize configuration before install ON.
- Choose Network selection: Virtual network 'default' : NAT.
- Click Finish.
-
Go to CPUs tab:
- Select Model: arm1176.
- Click Apply.
-
Go to Boot Options tab:
- Expand Direct kernel boot.
- Toggle Enable direct kernel boot ON.
- Input or browse Kernel path:
/.../kernel-qemu-4.19.50-buster
. - Input or browse DTB path:
/.../versatile-pb-buster.dtb
. - Input Kernel args:
root=/dev/vda2 panic=1
. - Click Apply.
-
Go to IDE Disk 1 tab:
- Select Disk Bus: VirtIO.
- Click Apply.
-
Go to NIC tab:
- Select Device Model: virtio.
- Select Apply.
-
Click Add Hardware:
- Go to Channel tab.
- Input Name:
org.qemu.guest_agent.0
- Select Device Type: UNIX socket (unix).
- Click Finish.
-
(Optional) Click Add Hardware:
- Go to RNG tab.
- Click Finish.
-
Click Begin Installation.
-
The VM will start and begin installation. Wait for it to finish, you'll be prompted to log in.
- Log in with the default credentials Login:
pi
and Password:raspberry
. - Run $
sudo raspi-config
to configure the OS (hostname, password, ssh, language, keyboard layout, etc.). - Run $
sudo apt install qemu-guest-agent
to install QEMU guest agent and enable host control.
Whenever you want to use your Raspbian VM again, just start Virtual Machine Manager and launch it.
- Enable ssh server (in raspi_config → Interface Options) to access your VM through ssh on your host machine.
- Shutting down and starting up your VM can be time consuming. Instead, you can save and restore a snpashot in Virtual Machine Manager.
- Setup Qemu in Debian Linux (Jan 2022) by Chris Titus.
- Use Virtual Machine Manager to create a Raspberry Pi virtual machine on Ubuntu (Oct 2021) by Dominoc925.
- How to run the Raspberry Pi Os in a virtual machine with Qemu and Kvm (Feb 2021) by Egidio Docile.
- Qemu-guest-agent Wiki page (Aug 2020) on Proxmox.com.
- How to use bridged networking with libvirt and KVM (Mar 2021) by Egidio Docile.
- It seems that you cannot use a bridged connection with a wireless interface: Archlinux.org forum.