Booting Refind on KVM

refind-pic

This is a quick recipe to boot a refind image on KVM. This is just to test UEFI boot configuration in virtualized environments.

First step is to create a refind boot image. For that I use this script:

To use this script, you need to download the binary zip file refind image from here. Also, the following packages need to be installed:

  • util-linux : for sfdisk and fallocate
  • unzip
  • dosfstools : for mkfs.vfat.
  • mtools : for mcopy.

And create the image using the command:

sh mkimg.sh refind-bin-0.14.2.zip boot.img 12G

To use the newly created image in a KVM environment.

uefi logo

virt-install \
        --name vm1 \
        --memory 1024 \
        --vcpus 1 \
        --clock offset=utc \
        --disk boot.img,format=raw \
        --osinfo linux2022 \
        --graphics vnc \
        --autoconsole text \
        --virt-type kvm \
        --console pty \
        --rng /dev/urandom} \
        --import \
        --boot uefi
  • memory is in Megabytes.
  • osinfo values can be found using the command virt-install --osinfo list.
  • The main settings to pay attention here is --boot uefi, which tells the system to set up a UEFI VM.