UTM icon indicating copy to clipboard operation
UTM copied to clipboard

Hanging at UEFI when using apple virtualisation

Open jamesla opened this issue 2 months ago • 11 comments

I have built a nixos disk image using nixos-generator which produces a raw-efi image.

After creating the image and creating a QEMU based VM it boots fine.

However when I create an Apple virtualisation based VM that uses this image it hangs at the UEFI screen (screenshot attached). Keys lock up and I can't get any further. (screenshot below note - the error it shows regarding `EFI_RNG_PROTOCOL is actually just a warning and have confirmed this doesn't cause linux to stop booting as it falls back to a software based entropy provider)

Image

I don't see it being an issue with the image as it loads fine when I consume the image using QEMU virtualization in UTM.

I'm unable to troubleshoot because I can't press any keys.

  • UTM Version: 4.7.4
  • macOS Version: 26.0.1
  • Mac Chip (Intel, M1, ...): M4 Max

Crash log
No crash log as the vm itself is hanging not UTM.

Debug log
No debug log as the option does not appear when using an apple virtualisation vm

Upload VM

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Backend</key>
	<string>Apple</string>
	<key>ConfigurationVersion</key>
	<integer>4</integer>
	<key>Display</key>
	<array>
		<dict>
			<key>DynamicResolution</key>
			<true/>
			<key>HeightPixels</key>
			<integer>1200</integer>
			<key>PixelsPerInch</key>
			<integer>80</integer>
			<key>WidthPixels</key>
			<integer>1920</integer>
		</dict>
	</array>
	<key>Drive</key>
	<array>
		<dict>
			<key>Identifier</key>
			<string>0E6272F7-FA62-496F-9591-B3DCB81EF9AD</string>
			<key>Nvme</key>
			<false/>
			<key>ReadOnly</key>
			<true/>
		</dict>
		<dict>
			<key>Identifier</key>
			<string>78C2E926-468E-488D-A39F-D2E10FA26D55</string>
			<key>ImageName</key>
			<string>78C2E926-468E-488D-A39F-D2E10FA26D55.img</string>
			<key>Nvme</key>
			<false/>
			<key>ReadOnly</key>
			<false/>
		</dict>
	</array>
	<key>Information</key>
	<dict>
		<key>Icon</key>
		<string>linux</string>
		<key>IconCustom</key>
		<false/>
		<key>Name</key>
		<string>Linux</string>
		<key>UUID</key>
		<string>81542079-5AE4-4EB7-A548-D8074721FF28</string>
	</dict>
	<key>Network</key>
	<array>
		<dict>
			<key>MacAddress</key>
			<string>3a:89:a8:56:41:84</string>
			<key>Mode</key>
			<string>Shared</string>
		</dict>
	</array>
	<key>Serial</key>
	<array/>
	<key>System</key>
	<dict>
		<key>Architecture</key>
		<string>aarch64</string>
		<key>Boot</key>
		<dict>
			<key>EfiVariableStoragePath</key>
			<string>efi_vars.fd</string>
			<key>OperatingSystem</key>
			<string>Linux</string>
			<key>UEFIBoot</key>
			<true/>
		</dict>
		<key>CPUCount</key>
		<integer>0</integer>
		<key>GenericPlatform</key>
		<dict>
			<key>machineIdentifier</key>
			<data>
			YnBsaXN0MDDRAQJUVVVJRE8QEOerqi9iEEK3rIhtpcbwgeYICxAA
			AAAAAAABAQAAAAAAAAADAAAAAAAAAAAAAAAAAAAAIw==
			</data>
		</dict>
		<key>MemorySize</key>
		<integer>4096</integer>
	</dict>
	<key>Virtualization</key>
	<dict>
		<key>Audio</key>
		<true/>
		<key>Balloon</key>
		<true/>
		<key>ClipboardSharing</key>
		<true/>
		<key>Entropy</key>
		<true/>
		<key>Keyboard</key>
		<string>Generic</string>
		<key>Pointer</key>
		<string>Mouse</string>
		<key>Rosetta</key>
		<false/>
	</dict>
</dict>
</plist>

Is there a way to access some sort of error logs with apple virt?

Is there a way to intercept the boot so that I can get an interface to EFI directly before it hangs?

jamesla avatar Oct 01 '25 22:10 jamesla

edit: I've noticed that when using apple virt in UTM it adds this additional disk - I'm guessing that this is an EFI volume? Is there a way to tell UTM to not use a seperate efi volume and instead just use the boot partition that's already on a disk image?

Image

jamesla avatar Oct 02 '25 08:10 jamesla

Can you provide a screen capture of you going through the wizard and then getting the 4MB drive? I'm not sure how that's getting created so I need to see what options you're picking.

osy avatar Oct 02 '25 14:10 osy

Can you provide a screen capture of you going through the wizard and then getting the 4MB drive? I'm not sure how that's getting created so I need to see what options you're picking.

(The 4MB disk also gets added in same manner if I chose to boot off my .img disk image instead of an iso)

Image

jamesla avatar Oct 02 '25 20:10 jamesla

Oh it seems like when you use ASIF disk format, it shows the actual consumed size instead of the max size so this is fine. I was able to follow your steps with nixos-minimal-25.05.810656.5b5be50345d4-aarch64-linux.iso and boot into the shell fine.

osy avatar Oct 02 '25 23:10 osy

Oh it seems like when you use ASIF disk format, it shows the actual consumed size instead of the max size so this is fine. I was able to follow your steps with nixos-minimal-25.05.810656.5b5be50345d4-aarch64-linux.iso and boot into the shell fine.

Yes so it will boot if you boot from an iso, however if you boot from a precreated disk image (that contains an efi/boot partition as well as an os partition) it will fail with the error above.

The image will load fine if you use qemu emulation instead of apple virtualisation ruling out issues with the image.

I suspect this could be because apple virtualisation handles efi differently and expects a separate efi volume to be connected - which could be why it adds that 4mb volume by default and without asking when you create a new VM.

Would my suspicions be correct here? If so I would presume that I would have to create 2 seperate images - one for os and one for boot/efi and connect them both - but wanted to clarify if that's how UTM with apple virtualisation works before I started investigating that track.

jamesla avatar Oct 03 '25 00:10 jamesla

You can just delete the 4MB image. That's the 64GB disk image that's automatically created. but I doubt that makes a difference.

osy avatar Oct 03 '25 00:10 osy

You can just delete the 4MB image. That's the 64GB disk image that's automatically created. but I doubt that makes a difference.

I've tested by making a new vm and copying the manually installed disk image over and it works fine so you are correct that it isn't related to the 4mb disk that is automatically created.

I suspect this is an issue with nixos-generators raw-efi image builder.

Where would I find more information on the requirement to build a UTM (apple virt) compatible disk image?

jamesla avatar Oct 03 '25 04:10 jamesla

ASIF isn't documented anywhere but you can mount it as a regular image on macOS and write to it. RAW is literally just an empty 64GiB file.

osy avatar Oct 03 '25 04:10 osy

I've created this issue in nixos-generators (I'm using the raw-efi generator) which is designed for physical hardware and also works with qemu as it produces a .img disk image. Apparently it should also work with apple virtualisation as well.

Do you think perhaps the problem could be that Apple Virtualisation wants me to convert the outputted .img file to asif?

https://github.com/issues/created?issue=nix-community%7Cnixos-generators%7C446

jamesla avatar Oct 03 '25 05:10 jamesla

I have no idea what the tool does but UTM imports it as raw not asif. ~~You can double check by looking in config.plist. It shouldn't have IsAsif true~~ Never mind I remember that ASIF is detected by Virtualization.framework so there's no indication in config.

osy avatar Oct 03 '25 05:10 osy

I was in a similar (but not identical) scenario to what you're describing and want to share some things that might help. Put this in your nixos configuration (or add to it accordingly -- plus you can nix eval --json .#nixosConfigurations.<hostname>.config.boot.initrd.kernelModules to inspect the current configuration to check what you have is feeding through):

  boot.kernelParams = [
    "console=ttyS0,115200"
    "console=ttyAMA0,115200"
    "console=tty0"
   ];
   boot.initrd.kernelModules = ["virtio_gpu" "virtio_pci" "virtio" ];

This may fix the problem. If it does not, in the VM edit screen, under devices, if you click 'new' and then add a serial console. Then under the main menu when the VM is running go Virtual Machine -> Displays -> Serial 1. This may assist you with getting access to the VM (in conjunction with boot.initrd.systemd.emergencyAccess = true; systemd.enableEmergencyMode = true; and services.getty.autologinUser = "root";), from there you may be able to some additional diagnostics.

Take care if you change the machine image that you might need to totally recreate the VM, otherwise I suspect the changes may not take effect.

Good luck! Let us know if you get it working.

peterwaller-arm avatar Oct 23 '25 19:10 peterwaller-arm