Michael Vorburger.ch Blog

Pass through" a physical disk in Virtual Machine Manager

May 31, 2024
Pass through" a physical disk in Virtual Machine Manager image

Pass through" a physical disk in Virtual Machine Manager

Here is how to “pass through” an actual physical disk from a Linux (workstation) host into a (Linux) virtual machine, using the Virtual Machine Manager (VMM) UI with click-click.

One reason why one might want to do this could be e.g. to explore running TrueNAS in a VM.

Steps

  1. Open VM’s settings via menu Edit > Virtual Machine Details

  2. Click Add Hardware (lower left)

  3. Use Storage section of Add New Virtual Hardware

  4. Choose Select or create custom storage (instead of Create a disk image for the virtual machine)

  5. In the textbox after the Manage button (do NOT click), simply fill in the /dev/disk/by-id/... path (of whatever disk you want to pass through, obviously). Do NOT use e.g. /dev/sda1 by its corresponding ID; use ls -l /dev/disk/by-id/ to see which is which.

  6. As Device type: use Disk device

  7. As Bus type: use SATA (typically)

  8. Click Finish

  9. Start the VM

  10. Guest should now see the disk!

VMM is of course based on libvirt, for qemu, so the same is also possible by editing XML with virsh edit; it would look something this:

<disk type="block" device="disk">
  <driver name="qemu" type="raw" cache="none" io="native" discard="unmap"/>
  <source dev="/dev/disk/by-id/ata-ST8000AS0002-1NA17Z_Z840N805"/>
  <target dev="sda" bus="sata"/>
  <address type="drive" controller="0" bus="0" target="0" unit="0"/>
</disk>