virt-manager Ubuntu cloudimage

Ubuntu aarch64 virt-manager

This is step-by-step to add Ubuntu aarch64 vm via virt-manager.

  1. Download ubuntu arm64 image from cloud images

    Assume the name of the downloaded image is </path/to/ubuntu-cloudimg-arm64.img>.

    Change the root password of the image with this command

    virt-customize -a <qcow2_img_file.img> --root-password password:<pass>

    NOTE: You might want to resize the image so we can grow the partition later.

    Th example below is to add additional 10 GB to the selected qcow2 image. Change the image path to the one we've downloaded

    qemu-img resize <qcow2_img_file.img> +10G
  2. Create varstore.img and varstore-copy.img

    truncate -s 64m </path/to/varstore.img>
    cp </path/to/varstore.img> </path/to/varstore-copy.img>
  3. Create efi.img. You might need to install qemu-system-arm

    truncate -s 64m </path/to/efi.img>
    dd if=/usr/share/qemu-efi-aarch64/QEMU_EFI.fd of=</path/to/efi.img> conv=notrunc
  4. Open virt-manager. Just forward until the end, BUT DON'T CLICK FINISH YET. Check Customize configuration before install, then click FINISH

  5. On the configuration window, edit the XML, and copy-paste xml file ubuntu-arm64.xml attached below. Edit all </path/to/.....> with ones from previous steps.

    You might want to change uuid too

  6. Click Begin Installation

Once logged in to vm, you might want to do this

Grow Partition

  1. If previously you resize the image with qemu-img resize, you need to grow the Partition with parted. Assuming you logged in as root

    parted /dev/vda
  2. Inside this parted execute resizepart <partition_number> 100%, in my case the <partition_number> is 1.

    (parted) resizepart 1 100%
    Warning: Partition /dev/vda<partition_number> is being used. Are you sure you want to continue?
    Yes/No? Yes
    (parted) quit

    If you got response to fix the partition instead, Proceed with Fix until finish, the re-enter resizepart command again after that.

  3. Then in bash/sh execute resize2fs /dev/vda<partition_number>, in my case the <partition_number> is 1.

    resize2fs /dev/vda1
  4. After this, I think you need to reboot to make partition larger.

Connect to network and internet

Since I didn't use cloud-init to set preset data, I don't have dhcp client and my NIC is down.

For this steps, assume the NIC is eth0. Please check the actual NIC name with ip -br a.

Also I use virbr as the bridge with subnet is 192.168.122.0/24

  1. Add temporary IP address and Link the NIC up

    ip addr add 192.168.122.10/24 dev eth0
    ip link set eth0 up
  2. Set the route to connect to internet

    ip route add default via 192.168.122.1 dev eth0
  3. At this stage, you should be able to connect to internet, but somehow there's no DNS resolver.

    Edit /etc/systemd/resolved.conf since ubuntu uses systemd-resolved.

    Add any available resolvers. Your /etc/systemd/resolved.conf might look like this

    [Resolve]
    DNS=8.8.8.8 1.1.1.1
    FallbackDNS=1.0.0.1
  4. restart systemd-resolved

    systemctl restart systemd-resolved
  5. Now, install dhcpcd for DHCP client

    apt update
    apt install dhcpcd
    systemctl restart dhcpcd.service