Hello Raphaël Godart, I am Henry and I want to share my insights about your concern.
To clarify, virtual machines boot from devices — not directly from .efi files. Just like a physical machine, a VM cannot boot from a standalone .efi
file placed on your host desktop. Instead, it requires a properly formatted virtual "device" that emulates a bootable medium. The most common and straightforward ways to accomplish this include:
- A virtual hard disk (.vhdx)
- A virtual DVD drive (using an .iso file)
For your use case, I recommend create a bootable ISO file that contains your bootx64.efi file then attach this ISO to a virtual machine's DVD drive and boot from it.
Step 1: Prepare the Correct Folder Structure
- The UEFI firmware in a virtual machine looks for a very specific file path on a bootable device. We need to replicate this structure on your host computer before creating the ISO.
- On your Desktop, create a new main folder. Let's call it UEFI_ISO.
- Inside the UEFI_ISO folder, create another folder named EFI.
- Inside the EFI folder, create a final folder named Boot.
- You should now have this folder path: C:\Users\Raph\Desktop\UEFI_ISO\EFI\Boot
Step 2: Copy Your .efi File
- Copy your bootx64.efi file into the Boot folder you just created. The final path to your file should be: C:\Users\Raph\Desktop\UEFI_ISO\EFI\Boot\bootx64.efi
Step 3: Create the Bootable ISO File
- Windows does not have a built-in tool to create ISO files easily, but we can use the official Microsoft command-line tool called oscdimg.exe or MakeWinPEMedia. This tool oscdimg is part of the Windows Assessment and Deployment Kit (ADK).
- Download the Windows ADK:
- Go to the official download page: Download and install the Windows ADK
- Download the installer for Windows 11.
- Install ONLY the "Deployment Tools":
- Run the ADK installer.
- When you get to the feature selection screen, you do not need to install everything. You only need to check the box for "Deployment Tools". This includes oscdimg.exe.
- Complete the installation.
- Run the ISO Creation Command:
- Open the "Deployment and Imaging Tools Environment" from your Start Menu. It will open a special command prompt with the correct paths already configured.
- Now, run the following command to create your ISO file. This command tells oscdimg to take your folder and make it a bootable UEFI-compatible image.
- After running the command, you should find a new file named Test.iso on your Desktop.
Step 4: Configure and Run the Hyper-V Virtual Machine
- Open Hyper-V Manager.
- Create a New Virtual Machine.
- Generation: This is critical. You must select Generation 2. Only Gen 2 VMs use UEFI firmware.
- Memory: Assign at least 1024 MB of RAM.
- Networking: For maximum security, select "Not Connected" or a "Private Switch". This ensures the .efi file cannot access your network or the internet.
- Virtual Hard Disk: You can create a small virtual hard disk, but we won't be using it to boot.
- Installation Options: Select "Install an operating system from a bootable image file". Click Browse and select the Test.iso file you created on your Desktop.
- Click Finish. Before you start the VM, one more crucial setting:
- Right-click your newly created VM in Hyper-V Manager and select Settings.
- Go to the Security section.
- Uncheck the box for "Enable Secure Boot". Secure Boot would block your custom, unsigned .efi file from running.
- Go to the Firmware section. Ensure the "DVD Drive" is at the top of the boot order list.
- Click OK.
Step 5: Run Your Test
- Create a Checkpoint: In Hyper-V Manager, right-click the VM and select "Checkpoint". This takes a snapshot so you can instantly revert the VM to this clean state later.
- Start the VM: Right-click the VM and select "Connect...", then click the "Start" button.
The virtual machine will now boot, look for the DVD drive, find the Test.iso, and launch your bootx64.efi application inside the safe, isolated environment. You can observe its behavior without any risk to your computer.
I hope this information and these keywords help point you in the right direction for your research.