I tried to use the Virtual Machine Manager (virt-manager)'s graphical user interface on Ubuntu to create a Raspberry Pi virtual machine. I found it to be a little tricky having to know the right parameters and configuration. This post describes the steps I went through to successfully create and run the Raspberry Pi virtual machine.
Install software prerequisites
If virt-manager and/or QEMU are not installed on the Ubuntu host, then run the following commands to install them.
$ sudo apt-get install qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virtinst libvirt-daemon virt-manager
Download a Raspberry Pi OS image
- Open up a browser to https://www.raspberrypi.com/software/operating-systems/.
- Click on a Raspberry Pi OS image of your choice to download. For example, Raspberry Pi OS Lite.
- Unzip the download file and place the extracted image file e.g. 2021-05-raspios-buster-armhf-lite.img to a folder, e.g. /path/to/folder/.
Download a QEMU kernel and the device tree blob (.dtb) for Raspberry Pi
- Open up a browser and browse to the repository https://github.com/dhruvvyas90/qemu-rpi-kernel.
- Click on kernel-qemu-4.19.50-buster and download the kernel to a folder, e.g. /path/to/folder/.
- Next, click on versatile-pb-buster.dtb and download the file to a folder, e.g. /path/to/folder/.
Create a new VM
- On the Ubuntu host, run virt-manager.
The Virtual Machine Manager graphical application appears.
- Click the Create a new virtual machine button.
The New VM dialog box wizard appears. - In the Architecture options drop down, choose armv6l in the Architecture combo box. Then select versatilepb in the Machine Type combo box. Press Forward.
Step 2 page appears.
- In the Provide the existing storage path field, click Browse.
The Choose Storage Volume dialog appears. - Click Browse Local and choose to open the previously downloaded Raspberry Pi OS image, e.g. /path/to/folder/2021-05-raspios-buster-armhf-lite.img.
- In the Kernel path field, click the Browse button.
The Choose Storage Volume appears again. - Click Browse Local and choose to open the previously downloaded kernel file, e.g. /path/to/folder/kernel-qemu-4.19.50-buster.
- In the DTB path field, click the Browse button.
The Choose Storage Volume appears. - Click Browse Local and choose to open the previously downloaded dtb file, e.g. /path/to/folder/versatile-pb-buster.dtb.
- In the Kernel args field, type in the following:
root=/dev/vda2 panic=1 - Finally, in the Choose the operating system you are installing field, type and choose the following:
Generic default (generic)
The Step 2 of the New VM dialog should look like the screen below. - Click Forward.
Page Step 3 appears. - In the Memory field, change the value to 256.
- Click Forward.
Page 4 appears. - Optional. Change the Name from vm-armv6l if necessary.
- Toggle on Customize configuration before install. In the Network selection drop down, select Specify shared device name. Then type in virbr0 in the Bridge name.
- Click Finish.
The vm-armv6l on QEMU/KVM dialog box appears.
Customize configuration
- Click CPUs. Then in the Model combo box, choose arm1176. Then click Apply to save the change.
- Click Boot Options. Toggle on Enable boot menu. Then Toggle on IDE Disk 1. Click Apply.
- Click on IDE Disk 1. Then click the Advanced options drop down. In the Disk bus field, change from IDE to VirtIO. Click Apply.
- Click the NIC icon. Then change the Device model to virtio. Click Apply.
- Optional. Click Add Hardware to add additional peripherals such as Serial mouse, Video card etc. if necessary.
- Click Begin Installation.
The processing messages appear and the Raspberry Pi VM is created.
No comments:
Post a Comment