Old school manual ARM for Libvirt/KVM
NB These instructions are out of date since the release of Debian 11 (Bullseye). Some parts of this guide will need to be updated to the new Debian release.
Overview
- Create a non-EFI (old school) ARM hardfloat virtual machine for Libvirt/KVM using a traditional interactive Debian install.
- See Four ARMs for Libvirt/KVM virtualisation for prerequisites, why, and other alternatives.
Get the Installer Images
NB Instead of vmlinuz and initrd.gz as the filenames you should use filenames that include the debian version and architecture (e.g. call vmlinuz debian-10.6.0-armhf-vmlinuz).
For Debian 10 (Buster)
- Get [Debian Buster armhf
kernel](
https://deb.debian.org/debian/dists/buster/main/installer-armhf/20190702+deb10u6../../assets/images/cdrom/vmlinuz
) - Get [Debian Buster armhf
initrd]
('https://deb.debian.org/debian/dists/buster/main/installer-armhf/20190702+deb10u6../../assets/images/cdrom/initrd.gz
) - Get [Debian Buster armhf CD#1
image](
https://mirror.csclub.uwaterloo.ca/debian-cd/10.6.0/armhf/iso-cd/debian-10.6.0-armhf-xfce-CD-1.iso
)
Prepare to Use the Debian-Installer Image
Open the download location in a terminal.
Copy the kernel, initrd, and CD image
- sudo cp vmlinuz initrd.gz debian-10.6-buster-armhf-complete-image.img /var/lib/libvirt/images on the machine where you will host the ARM VM.
OR upload kernel, initrd, and CD image using virsh
Execute
ls -al vmlinuz initrd.gz debian-10.6.0-armhf-xfce-CD-1.iso
Execute
virsh -c qemu+ssh://user@host/system vol-create-as --pool default --name vmlinuz --format raw --allocation \<size-from-ls> --capacity \<size-from-ls>
Execute
virsh -c qemu+ssh://user@host/system vol-upload --pool default --vol vmlinuz --file vmlinuz
Execute
virsh -c qemu+ssh://user@host/system vol-create-as --pool default --name initrd.gz --format raw --allocation \<size-from-ls> --capacity \<size-from-ls>
Execute
virsh -c qemu+ssh://user@host/system vol-upload --pool default --vol initrd.gz --file initrd.gz
Execute
virsh -c qemu+ssh://user@host/system vol-create-as --pool default --name debian-10.6.0-armhf-xfce-CD-1.iso --format raw --allocation \<size-from-ls> --capacity \<size-from-ls>
Execute
virsh -c qemu+ssh://user@host/system vol-upload --pool default --vol debian-10.6.0-armhf-xfce-CD-1.iso --file debian-10.6.0-armhf-xfce-CD-1.iso
Create the ARM VM using Virtual Machine Manager
- Launch “Virtual Machine Manager” (virt-manager from the command line).
- Select ‘File|New Virtual Machine’
- Select ‘Import existing disk image’
- Change ‘Architecture options’ to Architecture: ‘arm’, Machine Type: ‘virt-2.12’. (virt-3.0 and virt-3.1 are known to not work with this guide; newer and older versions likely will work)
- Select ‘Browse…’, create a virtual hard disk for the new VM, and select ‘Choose Volume’.
- For each of the kernel and initrd, browse to the file and select ‘Choose Volume’.
- Set ‘Kernel args’ to ‘elevator=noop noresume’.
- Set the operating system to ‘Debian10’
- Select ‘Forward’
- Configure the amount of memory and cpus (max 4) and select ‘Forward’
- Set the VM name and check ‘Customize configuration before install`
- Select the appropriate network device for your virtual hosting setup.
- Click ‘Finish’
- Select ‘Add Hardware’, and add a Controller of ‘Type: SCSI’ and ‘Model: VirtIO SCSI’.
- Select ‘Add Hardware’, and add Storage (CD-ROM) for the CD ISO image (use SCSI as the bus type).
- Select ‘Begin installation’
- Make sure to select the VM console when it appears otherwise random errors may occur.
Perform Debian Installation
I won’t cover this in detail as it’s a fairly standard Debian install except:
- These instruction assume you don’t use LVM.
- GRUB installation will fail. This is expected — we will work around this below.
- Click through (OK/Continue/Ignore) until you are able to Select ‘Continue without bootloader’
- Installation will complete and the VM will reboot into the installer.
- Force Off the VM (e.g. in VMM with ‘Virtual Machine|Force Off’)
- Remove the CD image from the CD-ROM (optionally remove the virtual CD-ROM device too; you won’t need it).
Enable Booting the Virtual Machine
NB You will need to repeat this whenever the initramfs and/or kernel is updated.
Copy the kernel and initramfs from the domain (VM)
So that you can use it to boot the domain (VM).
On the virtual machine host:
Become root
Execute
mkdir /tmp/armbootfiles
Execute
chmod 700 /tmp/armbootfiles
Execute
cd /tmp/armbootfiles
Execute
guestfish -c qemu:///system --ro -i -d \<name-of-your-vm>
Execute
ls /boot
to find the names of the newest vmlinuz and initrd.img (you don’t want the plain vmlinuz and initrd.img because they are just symlinks).Execute
copy-out /boot/vmlinuz-x.x-x.x-armmp-lpae /boot/initrd.img-x.x.x-x-armmp-lpae ./
Execute exit
Execute
prename -e 's/^/\<name-of-your-vm>/' *
Execute
mv \<name-of-your-vm>-* /var/lib/libvirt/images
Execute exit
Edit the domain (VM) to update the direct boot
Using the kernel and initrd from the VM.
- In Virtual Machine Manager, in the VM Details page, Select ‘Boot Options’
- Make sure ‘Enable direct kernel boot’ is checked.
- For the ‘Kernel Path’, ‘Browse’ to the location of the new kernel and select ‘Choose Volume’
- For the ‘Initrd Path’, ‘Browse’ to the location of the new initrd.img and select ‘Choose Volume’
- Add
root=/dev/vda2
to ‘Kernel args’. (If you used LVM the path will be slightly different). - Select ‘Apply’
Alternative method to edit domain (VM)
- Execute
virsh -c qemu+ssh://user@host/system edit \<name-of-domain>
- Place the appropriate paths in the <kernel>…</kernel> and <initrd>…</initrd> tags.
- Also edit the <cmdline>…</cmdline> to add root=/dev/vda2 as above.
- Save your changes.
Boot to Test
Test that your system now boots properly by using ‘Virtual Machine|Run’.