Proxmox Physical Disk to VM – Only 2 Commands!

VMs are great, they allow you to consolidate many computers in to 1 physical system without forcing you to use a single OS. Sometimes it’s nice to give these VMs access to HW directly. In this guide I’ll show you how to pass a disk, at the block level through to a VM in Proxmox. This isn’t passing the disk through directly so it’s not a good idea to use ZFS or raid on the passed through disks. You’ll notice they still show as a VirtIO device inside the VM.

My personal use case is storage my home security camera footage on a hard drive. I didn’t want to make a single large virtual hard drive, I wanted the VM to use the whole disk for the footage. Proxmox is what I run on my 24×7 VM host, therefor I’ll be using it in this guide.


Finding the Disk in the Proxmox Terminal

I presume you already have a VM ready and a disk in the system that you want to pass through.

The first step is so find the ID of the disk you want to pass through. While you can use /dev/sdX, you don’t want to as this can change as you add, remove or rearrange disks. Here are the steps for finding the ID You’ll need to either login by SSH or go to the Proxmox terminal directly.

Type in ls /dev/disk/by-id/

root@pve:~# ls /dev/disk/by-id/
ata-Samsung_SSD_860_EVO_250GB_S3Y9NX0M509446L
ata-Samsung_SSD_860_EVO_250GB_S3Y9NX0M509446L-part1
ata-Samsung_SSD_860_EVO_250GB_S3Y9NX0M509446L-part2
ata-Samsung_SSD_860_EVO_250GB_S3Y9NX0M509446L-part3
ata-WDC_WD20EARX-00ZUDB0_WD-WMC1H0037415
ata-WDC_WD20EARX-00ZUDB0_WD-WMC1H0037415-part1
ata-WDC_WD20EARX-00ZUDB0_WD-WMC1H0037415-part2
---truncated---

The lines ending with part1, part2 etc are the partitions on each disk. We aren’t interested in these as we want the whole disk regardless of partitions. The line I’ll want to pass my WD 2TB drive is ‘ata-WDC_WD20EARX-00ZUDB0_WD-WMC1H0037415‘ however this will be unique for every HDD/SSD.

Once you have identified the disk you’re interested in there is only 1 more line to type! But first lets identify the ID of the VM you want to attach this disk to. Open the Proxmox WebGUI and look at the VM list.

Remember the number of the VM you want to attach to. We need to make a command to pass the disk through now. It goes as follows:

qm set VM-ID -virtio2 /dev/disk/by-id/DISK-ID

replace VM-ID with the number of the VM and DISK-ID with the disk ID. In my case I will end up with ‘qm set 100 -virtio2 /dev/disk/by-id/ata-WDC_WD20EARX-00ZUDB0_WD-WMC1H0037415‘.

After doing this you should be able to see the disk in the Hardware tab for your VM.

Now, if your OS already knows about VirtIO then you’re done! If not keep reading… I’ll explain how to install the driver.

VirtIO Driver in Windows

Installing the VirtIO driver is quite simple. They don’t give you an installer program so I’ll guide you through the manual install process below.

  1. You’ll want to go to this link and download the VirtIO ISO. Scroll down to Direct downloads and select Stable virtio-win iso.
  2. Upload this ISO to Proxmox ISO Storage and mount it in your Windows VM’s CD drive.
  3. Boot the VM and open device manager.
  4. Right click the new HDD and select Update Driver Software….
  5. Select Browse my computer for driver software.
  6. Click browse then browse to the viostor folder inside the cd.
  7. Pick your OS and 64/32 bit folder then go next. It should install the driver and your disk should be working. Now you can make your partition in disk management like normal.

All done! Congratulations.

If you’ve found this guide helpful please drop a comment below or share it on one of the social media links.

Share this post

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on pinterest
Share on print
Share on email

Join the Conversation

18 Comments

  1. Hi,
    Thanks for this informations.
    Is there any limitation about the number of disks that can be attacher to a vm please ?
    Thanks in advance

  2. Thanks so much! This guide was a huge help and much appreciated. Crazy there isn’t better documentation around this.

    If the VM I wish to pass the drive to is linux, do you know what I have to do to get that drive recognized by the VM or the VM’s file manager? Perhaps I need to configure VirtIO on VM?

    TIA

    1. I have not tried but I would expect it to automatically work in a Linux VM.

      1. It did work automatically, however, I had forgotten to mount it! DUH.
        Identified disk and made new partition. At that point it mounted automatically and I updated etc/fstab with my new disk and now it is persistent through boots!

        Thanks again

  3. Was going this route, and got it working in an Ubuntu VM, but realized a fatal flaw:

    To access that same storage from another VM or from the host, it need to be mounted in multiple places at once and that’s a big no-no.
    What if 2 (or 3) systems try to update the journal at the exact same time?

    1. To access storage from a VM your best bet is a network share. Multiple VMs can’t share a disk, if it’s possible it’s outside of the scope of what I know.

      NSF or Samba are your best bets, good luck!

  4. Hi,
    I wonder if I can add more than just one virtio drive to a vm in proxmox. Whenever I want to add a second hard drive it automatically removes the first one and replaces it instead of adding the second one. Maybe I miss something, but it would be great if you could help me out…
    Thanks in advance!

    1. I was looking for just this thing but couldn’t find the answer. I tried just changing -virtio2 to -virtio1 (I guess you could choose whatever number you want but at least it showed up in Hardware tab)

      1. So after running qm set 301 -virtio1 /dev/…disk1ID
        and also qm set 301 -virtio1 /dev/…disk2ID
        and launching TrueNAS Core now all three disks are showing up in both the Proxmox Hardware page for the VM as well as the storage>hard drive section in TrueNAS (The two virtio passthrough disks and the default virtual harddisk that proxmox used during vm creation)

  5. I plugged an old sata HD to my pc with Proxmox installed on it, then I’d like to passthrough it to a VM (OMV5). Can I do that through this procedure? Do I need to format it via the “Initialize disk with GPT” button first (no fiile system or partition setup with it)?

    1. When you pass it through it’s at block level so no need to format it first. The VM will see what ever file system was on the drive.

  6. @Alpenmerlin – not sure if you still have this issue, but yes, you can. In the following command listed in this article:
    qm set VM-ID -virtio2 /dev/disk/by-id/DISK-ID
    replace “-virtio2” with “-virtio3” “-virtio4”, etc. for each successive disk you want to add, and make sure each DISK-ID is also changed to the respective DISK-ID of the disk you want to pass through. I have 5 drives passed through to OMV this way – thanks @JohnKeen for the initial info.

Leave a comment

Your email address will not be published. Required fields are marked *