Running Linux in a Virtual Machine on ARM

I am following the Running Linux in a Virtual Machine guide on MacOS 14 w/ ARM. Fedora kernel and RAM disk images were acquired for aarch64.

I opened LinuxVirtualMachine.xcodeproj from the example; selecting 'LinuxVirtualMachine' under 'Targets', and navigating to 'Signing and Capabilities', I linked my Personal Team (needed to connect my Apple ID) under 'Signing->Team'. Clicking 'run' outputs the following:

Usage: /Users/shea/Library/Developer/Xcode/DerivedData/LinuxVirtualMachine-baalsbzvoxxbspgicozzllxbyqmh/Build/Products/Debug/LinuxVirtualMachine <kernel-path> <initial-ramdisk-path>
Program ended with exit code: 64

So I execute the following in Terminal from a directory containing the two images from Fedora:

% /Users/shea/Library/Developer/Xcode/DerivedData/LinuxVirtualMachine-baalsbzvoxxbspgicozzllxbyqmh/Build/Products/Debug/LinuxVirtualMachine ./vmlinuz ./initrd.img

And receive the output:

Failed to start the virtual machine. Error Domain=VZErrorDomain Code=1 "The virtual machine failed to start." UserInfo={NSLocalizedFailure=Internal Virtualization error., NSLocalizedFailureReason=The virtual machine failed to start.}

An old thread seems to imply this may be because the kernel image used to be compressed but is no longer? Another commenter suggests it is because vmlinuzis a gz file and to extract it, but file vmlinuzoutputs vmlinuz: PE32+ executable (EFI application) Aarch64 (stripped to external PDB), for MS Windows and gzip won't work even with the .gz extension. Did I miss a step?

Replies

The issue is very likely because the Linux kernel image is compressed indeed.

There are a couple of options you can try:

  • The Linux kernel repository has a extract-vmlinux that can extract an uncompressed Linux image from a compressed one.
  • You can compile your own kernel disabling compression in the configuration. I also find it pretty convenient to build a full Linux environment using the "Builtroot" tools.

For completeness, let's also mention that Virtualization supports EFI. If your use case doesn't require extremely fast boot of Linux, it's a really convenient way of integrating Linux: https://developer.apple.com/documentation/virtualization/running_gui_linux_in_a_virtual_machine_on_a_mac?language=objc

  • Thanks for the reply!

    Following the instructions at the GUI Linux VM guide, I get an error at the 'Run and Build' step.

    GUILinuxVirtualMachineSampleApp/AppDelegate.swift:99: Fatal error: Failed to retrieve the machine identifier data.
    

    There was no prompt to choose an ISO.

  • As to the first bullet point, using extract-vmlinux in a directory containing vmlinux (after chmod +x ./extract-vmlinux) with

    ./extract-vmlinux vmlinuz
    

    returns

    tr: Illegal byte sequence
    extract-vmlinux: Cannot find vmlinux.
    

    I tried to get clever and renamed vmlinuz to vmlinux and entered using ./extract-vmlinux vmlinux but no luck.

Add a Comment