- Raspberry Pi 4 Model B(8GB)
- Ubuntu 22.04.4
- 5.15.0-1049-raspi
Check KVM module is enabled.
sudo dmesg | grep -i kvm
# Result >
# [ 0.328294] kvm [1]: IPA Size Limit: 44 bits
# [ 0.329951] kvm [1]: vgic interrupt IRQ9
# [ 0.330228] kvm [1]: Hyp mode initialized successfully
or run this command.
sudo apt install -y cpu-checker
kvm-ok
# Result >
# INFO: /dev/kvm exists
# KVM acceleration can be used
Install packages.
sudo apt install -y qemu-kvm libvirt-daemon libvirt-clients bridge-utils virtinst virt-manager
Check the libvirtd status.
sudo systemctl enable libvirtd --now
sudo systemctl is-active libvirtd
# Result > active
Add user to group.
sudo usermod -aG libvirt $USER
sudo usermod -aG kvm $USER
Check network list.
sudo virsh net-list
# Result >
# Name State Autostart Persistent
# --------------------------------------------
# default active yes yes
# if there's no default network, then run this
sudo virsh net-start default
Create guest VM using virt GUI manager.
virt-manager
Create guest VM using commands.
First, you need OS image file.
wget https://cdimage.ubuntu.com/releases/jammy/release/ubuntu-22.04.4-live-server-arm64.iso
# Result >
# -rw-rw-r-- 1 libvirt-qemu kvm 1.9G ubuntu-22.04.4-live-server-arm64.iso
then, create guest machine.
sudo virt-install --name=test-vm \
--vcpus=4 \
--memory=2048 \
--cdrom=./ubuntu-22.04.4-live-server-arm64.iso \
--disk size=10
Then, you can see GRUB page.
GRUB page (If you don't need customization, just keep going by defualt options)
- Select
Install Ubuntu Server
There's an error on the first line of output.(But it doesn't matter. Just a bug.)
EFI stub: ERROR: FIRMWARE BUG: kernel image not aligned on 64k boundary
Bug: https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1947046
- Select
Switch to rich mode
- Language setting
- Network connection
- Congifure proxy
- Configure Ubuntu archive mirror
- Storage configuration
- Confirm destructive action -> Select
continue
- Profile setup
- SSH setup
- Featured Server snaps
- Installing system(it will take a while to complete)
- Select
Reboot
-> error
Failed unmounting /cdrom. Please remove the installation medium, then press enter
-> press ENTER
-> no login prompt
-> ctrl + c
-> login
Guest VM is created!!
Check isolated environment btw host and guest.
In the guest
yunha@test-vm:~$ uname -a
# Result >
# Linux test-vm 5.15.0-101-generic #111-Ubuntu SMP Wed Mar 6 18:01:01 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux
In the host
pi@pi:~$ uname -a
# Result >
# Linux pi 5.15.0-1049-raspi #52-Ubuntu SMP PREEMPT Thu Mar 14 08:39:42 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux
We can check allocated guest VM's resources.
We can check automatically created disk images.
sudo ls /var/lib/libvirt/images/
# Result > test-vm.qcow2
Logout.
exit
Exit to host.
ctrl + ]
Show all the guest VMs.
virsh list --all
# Result >
# Id Name State
# -------------------------
# 10 test-vm running
Connect the virtual serial console for the guest.
virsh console <VM>
Reboot.
virsh reboot <VM>
Power-off.
virsh shutdown <VM>
Start the guest machine.
virsh start <VM>
Immediately terminate the VM.
(This doesn't give the domain OS any chance to react, and it's the equivalent of ripping the power cord out on a physical machine. It's better to use shutdown)
virsh destroy <VM>
Removing VM.
virsh undefine <VM>
# Result >
# error: Failed to undefine domain 'test-vm'
# error: Requested operation is not valid: cannot undefine domain with nvram
# --nvram remove nvram file
virsh undefine --nvram <VM>
- Error 1
You will need to grant the 'libvirt-qemu' user search permissions for the following directories: ['/home/pi']
sudo chmod +x /home/pi
- Error 2
WARNING Couldn't configure UEFI: Did not find any UEFI binary path for arch 'aarch64'
sudo apt install qemu-efi-aarch64
then, execute virt-install with --boot uefi
option.
- Korean
- English
- If I set disk size too small, I have to manually do storage configuration later. But this makes booting error. For now, I don't know why.
- Check
virt-install --import
option.