sodcalculator

10 Tech How-To

Test a Bootable USB in a Virtual Machine Safely

Guide 10-44562 · Updated · Step by step

Testing a bootable USB drive in a virtual machine lets you verify that the drive boots correctly, the OS installs or runs as expected, and any customizations work—all without risking your physical computer. This guide walks you through creating a VM, attaching the USB, and booting from it, while keeping your host system safe. You’ll need a virtualization program (like VirtualBox or VMware Workstation Player), the bootable USB drive, and the ISO or image file it was created from (optional, but helpful for troubleshooting).

What You’ll Need

  • A computer with a virtualization program installed (VirtualBox, VMware Workstation Player, or similar).
  • The bootable USB drive you want to test.
  • Enough free disk space for the virtual machine’s virtual hard disk (at least 10 GB recommended).
  • Optional: The original ISO or IMG file used to create the USB, in case you need to re-create it.

Step-by-Step

  1. Create a new virtual machine. Open your virtualization software and click “New” or “Create a Virtual Machine.” Choose a name (e.g., “USB Test”) and select the operating system type that matches what’s on the USB (e.g., Linux, Windows, etc.). For the version, pick the closest match (e.g., Ubuntu 64-bit, Windows 10).
  2. Allocate memory and storage. Assign at least 2 GB of RAM (more if the OS requires it). For the virtual hard disk, create a new one—choose VDI (VirtualBox) or VMDK (VMware), dynamically allocated, with a size of at least 10 GB. This disk will be the “target” for the OS you’re testing; it won’t affect your real drives.
  3. Configure the VM to boot from the USB. Before starting the VM, go to its settings. Under “Storage” (VirtualBox) or “CD/DVD” (VMware), you’ll need to add the USB drive as a boot device. In VirtualBox, click the controller (e.g., SATA), then the “Adds optical drive” icon, and choose “Choose a disk file”—but wait, you want to boot from USB, not an ISO. Instead, you’ll need to create a small virtual disk that points to the physical USB. In VirtualBox, use the command line: VBoxManage createmedium disk --filename="C:\path\to\usb.vmdk" --format=VMDK --variant=RawDisk --property=RawDrive="/dev/sdX" (replace /dev/sdX with your USB device identifier, e.g., /dev/sdb). This is a bit advanced; see the Common Mistakes section for a simpler alternative.
  4. Simpler alternative: Use a live ISO instead. If the USB was created from an ISO (like most Linux distros), you can simply attach that ISO to the VM’s optical drive and boot from it. This tests the same content but not the USB boot process itself. To truly test the USB, you need the raw disk mapping method.
  5. If using the raw disk method, attach the VMDK. In VirtualBox, go to Storage, click the SATA controller, add a hard disk, and select the VMDK file you created. Make sure it’s set as the first boot device in the System > Motherboard > Boot Order.
  6. For VMware, use a physical disk. In VMware Workstation, open VM settings, go to “Hard Disk,” click “Add,” choose “Use a physical disk,” select the USB drive from the drop-down, and choose “Use entire disk.” Be careful to select the correct disk—the USB, not your system drive.
  7. Start the VM. Power on the virtual machine. It should attempt to boot from the USB. If it doesn’t, you may need to press a key (like F12) to enter the boot menu and select the USB device.
  8. Test the OS. Once booted, you can try the live environment, install the OS to the virtual hard disk, or run whatever diagnostics you need. The VM isolates everything, so your host system is safe.
  9. When done, shut down the VM. Use the normal shutdown procedure inside the VM. Then, in the host, safely remove the USB drive (eject it) before unplugging.

Common Mistakes

  • Selecting the wrong physical disk. When using raw disk mapping, choosing /dev/sda (your main drive) instead of the USB could cause data loss. Always double-check the drive letter/identifier.
  • Not enabling USB controller. Some VMs don’t have a USB controller enabled by default. In settings, ensure the USB controller is present (e.g., USB 3.0 xHCI) so the VM can see the drive.
  • Booting from the ISO instead of the USB. If you attach the ISO, you’re not testing the USB boot process. Only the raw disk method tests the actual USB.
  • Forgetting to remove the USB after testing. Leaving the USB attached to the VM can cause it to boot from it every time, which might be confusing later.
  • Using a USB 3.0 drive on a USB 2.0 controller. This can cause boot failures. Make sure the VM’s USB controller matches the drive’s speed.

Tips

  • Make a backup of the USB’s contents. If the USB contains data you need, back it up before testing, as raw disk access can be risky.
  • Use a snapshot. After creating the VM, take a snapshot before booting the USB. If something goes wrong, you can revert to the clean state.
  • Check the USB’s integrity first. Use a tool like dd or Rufus to verify the USB’s checksum matches the original ISO. A corrupted USB will fail to boot regardless of the VM.
  • Disable network in the VM. If you’re testing an OS that might phone home or download updates, disable the network adapter to keep the test isolated.
  • Use a separate virtual disk for installation. If you plan to install the OS, use a fresh virtual disk so the installation doesn’t write to the USB.

Troubleshooting

  • VM doesn’t boot from USB. Check the boot order in the VM’s BIOS/UEFI settings. You may need to press a key (e.g., Esc, F12) during startup to select the boot device. Also ensure the USB is properly attached (see Common Mistakes).
  • Error: “FATAL: Could not read from the boot medium.” This usually means the USB isn’t properly attached or the raw disk mapping is incorrect. Re-check the device identifier and permissions. On Linux, you may need to run VirtualBox with sudo to access the raw device.
  • USB is recognized but boot stalls. This can happen if the USB is USB 3.0 and the VM controller is USB 2.0. Try changing the USB controller to USB 3.0 (xHCI) in VM settings.
  • Windows can’t see the USB in the VM. In VirtualBox, you may need to add a USB filter. Go to Settings > USB, click the “Add Filter” icon, and select your USB drive. Then restart the VM.
  • VM is extremely slow. This is normal if the USB is slow or the VM has limited resources. Increase RAM and CPU cores in the VM settings if possible.
  • After testing, the USB is no longer bootable. This can happen if the OS installer wrote to the USB. To fix, re-create the USB from the original ISO using a tool like Rufus or Etcher.

Frequently Asked Questions

Can I test a Windows bootable USB in a VM?

Yes, but Windows may require specific settings (like UEFI boot). Create the VM with Windows as the guest OS type, enable UEFI in the VM settings, and use the raw disk method. Some Windows ISOs may not boot from USB in a VM due to driver issues; using the ISO directly is often easier.

Will testing the USB in a VM damage my host computer?

No, if you correctly select the USB drive as the raw disk, the VM only accesses that USB, not your host drives. However, if you accidentally select your main drive, it could be overwritten. Always double-check the drive identifier.

Can I test a bootable USB that contains a full OS installation?

Yes. The VM will boot from the USB and you can run the installer, which will install to the virtual hard disk. This tests the USB’s ability to boot and install, which is the most thorough test.

What if my USB is not detected by the VM?

First, ensure the USB controller is enabled in the VM settings. Then, in VirtualBox, add a USB filter for the device. If using raw disk mapping, make sure the device path is correct and that you have permission to access it (run the VM as administrator on Windows, or use sudo on Linux).

Is it safe to use the same USB on my physical computer after testing?

Yes, as long as the VM didn’t write to the USB. If the installer or OS modified the USB, it might no longer be bootable, but it won’t harm your computer. You can re-create the USB from the ISO if needed.

Can I test a USB that boots a live Linux environment without installing?

Absolutely. Boot the VM from the USB, and you’ll get the live desktop. You can test hardware compatibility (within the VM’s virtual hardware), software, and your custom scripts. Note that the VM’s hardware is virtual, so real-hardware issues won’t be caught.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →