When booting `lineage-22.1-20250202-UNOFFICIAL-virtio_arm64only.img` on Debian 13 ARM `libvirt` at some point I face:

```
BdsDxe: loading Boot0001 "UEFI QEMU QEMU USB HARDDRIVE 1-0000:00:01.2:00.0-1" from PciRoot(0x0)/Pci(0x1,0x2)/Pci(0x0,0x0)/USB(0x0,0x0)
BdsDxe: starting Boot0001 "UEFI QEMU QEMU USB HARDDRIVE 1-0000:00:01.2:00.0-1" from PciRoot(0x0)/Pci(0x1,0x2)/Pci(0x0,0x0)/USB(0x0,0x0)
error: no such device: PERSIST.
error: file `/grubenv_abootctrl' not found.
```

How to solve this issue?
Aug 13, 8:50pm

The error you're encountering:

text
error: no such device: PERSIST.
error: file `/grubenv_abootctrl' not found.

is not uncommon when booting Android-x86 or LineageOS images in a virtualized environment like libvirt on ARM64. This issue typically arises because the image expects certain UEFI/GRUB configurations or device paths that are either missing or misconfigured in your virtual machine setup.


Root Causes

  1. Missing or Incorrect Bootloader Configuration The image is trying to access /grubenv_abootctrl, a file used by Android-x86's GRUB-based bootloader to manage boot entries (e.g., for A/B slot switching). This file is either:

    • Not present in the image.
    • Not accessible due to incorrect UEFI boot order or device mapping in libvirt.
  2. UEFI Firmware Compatibility The QEMU UEFI firmware (edk2) used by libvirt may not fully support the bootloader logic expected by LineageOS for ARM64.

  3. Storage Device Not Detected The error no such device: PERSIST suggests the system cannot find the persistent storage partition (often used for /data or bootloader state in Android-x86).

  4. ARM64-Specific Quirks LineageOS for ARM64 (especially in a virtualized environment) may have unofficial or experimental support, leading to bootloader issues.


Solutions to Try

1. Check the Image's Bootloader

  • Verify if the image has a GRUB configuration: Mount the image and check if /grubenv_abootctrl exists:
    bash
    sudo mount -o loop,offset=$((512*2048)) lineage-22.1-20250202-UNOFFICIAL-virtio_arm64only.img /mnt
    ls /mnt/grubenv_abootctrl
    • If missing, the image may be corrupt or incomplete.
    • If present, the issue is likely UEFI boot order or device visibility.

2. Modify the Libvirt XML for UEFI Boot

Your libvirt domain XML should explicitly define:

  • UEFI firmware (OVMF for ARM64).
  • Correct boot order (prioritize the virtual disk over USB).
  • VirtIO storage (not USB emulation).

Example XML Snippet

xml
<domain type='qemu'>
  <os>
    <type arch='aarch64' machine='virt'>hvm</type>
    <loader readonly='yes' type='pflash'>/usr/share/qemu-efi-aarch64/QEMU_EFI.fd</loader>
    <nvram>/var/lib/libvirt/qemu/nvram/lineage_VARS.fd</nvram>
    <boot dev='hd'/>
  </os>
  <devices>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/path/to/lineage-22.1-20250202-UNOFFICIAL-virtio_arm64only.img'/>
      <target dev='vda' bus='virtio'/>
    </disk>
    <controller type='virtio-serial'/>
    <controller type='usb' model='qemu-xhci'/>
  </devices>
</domain>

Key Fixes:

  • Remove USB boot entries (force boot from vda).
  • Use virtio for storage (not USB emulation).
  • Ensure UEFI firmware is ARM64-compatible (e.g., QEMU_EFI.fd for AArch64).

3. Manually Specify the Boot Device

If the VM still tries to boot from USB, override the boot order in libvirt:

bash
virsh boot --domain <your-vm-name> --harddisk --persistent

Or edit the XML to disable USB boot:

xml
<boot dev='hd'/>
<boot dev='cdrom'/> <!-- Optional, if needed -->

4. Rebuild the Image with Correct Bootloader

If the image lacks /grubenv_abootctrl, it may need to be rebuilt with proper GRUB support:

  • Use mkbootimg or abootimg to repack the boot image.
  • Ensure the kernel command line includes:
    text
    root=/dev/vda1 androidboot.hardware=qemu androidboot.force_normal_boot=1

5. Try a Different UEFI Firmware

Some users report success with custom UEFI builds for ARM64:

  • Download a prebuilt OVMF for AArch64:
    bash
    sudo apt install qemu-efi-aarch64
  • Point libvirt to the correct firmware path (e.g., /usr/share/qemu-efi-aarch64/QEMU_EFI.fd).

6. Debug with QEMU Directly

Test outside libvirt to isolate the issue:

bash
qemu-system-aarch64 \
  -machine virt \
  -cpu cortex-a72 \
  -smp 4 \
  -m 4G \
  -bios /usr/share/qemu-efi-aarch64/QEMU_EFI.fd \
  -drive file=lineage-22.1-20250202-UNOFFICIAL-virtio_arm64only.img,format=raw,if=virtio \
  -nographic
  • If this works, the issue is libvirt-specific (e.g., XML misconfiguration).
  • If it fails, the issue is image-related (e.g., missing bootloader files).

7. Check for ARM64-Specific Patches

  • Some unofficial LineageOS builds require custom kernel patches for virtio.
  • Search the LineageOS forums or XDA Developers for ARM64 virtio fixes.

Next Steps

  1. Verify the image's integrity (checksum, file existence).
  2. Test with QEMU directly (bypass libvirt).
  3. Update libvirt XML to enforce virtio boot.
  4. Check logs (dmesg, journalctl -u libvirtd) for storage/UEFI errors.

Question for You

Have you tried booting this image outside of libvirt (e.g., with QEMU directly)? If so, did you encounter the same error?

Aug 13, 8:50pm

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Vibe can make mistakes. Check answers. Learn more