kraaakilo

Command Palette

Search for a command to run...

Blog passthrough-physical-disk-proxmox-vms
virtualizationJULY 13, 2024

Passthrough Physical Disk to Proxmox VMs

virtualization

Introduction

Passing a physical disk directly to a virtual machine in Proxmox can improve performance and simplify storage management. This guide explains how to locate the disk, assign it to a VM, and detach it if needed.


1. Locate and Prepare the Disk

Identify the Disk

  • In the Proxmox UI, go to Disks.
  • Find your disk and note the serial number.
  • (Optional) Wipe the disk if you want to erase all data.

Get Disk Path

Run this command in the Proxmox shell to list disks by ID:

bash

find /dev/disk/by-id/ -type l | xargs -I{} ls -l {} | grep -v -E '[0-9]$' | sort -k11 | cut -d' ' -f9,10,11,12

Locate the path corresponding to your disk (e.g., /dev/disk/by-id/ata-WDC...).


2. Assign Disk to VM

Add Disk via Shell

Use the qm command to attach the disk:

bash

qm set <vmid> -<disk-type><number> /dev/disk/by-id/<disk-serial>
  • Replace <vmid> with your VM ID (e.g., 100).

  • Use scsi or virtio depending on the guest OS.

    • scsi is recommended for Linux and Windows.
    • virtio may be better for macOS guests.

Example:

bash

qm set 100 -scsi1 /dev/disk/by-id/ata-WDC...

Confirm and Boot

  • In the VM’s Hardware tab, the disk should now appear.
  • Start the VM and check if the disk is detected.

3. Remove Disk from VM

To detach the disk from the VM, use:

bash

qm unlink <vmid> --idlist <disk-type><number>

Example:

bash

qm unlink 100 --idlist scsi1

This will unlink the passthrough disk without affecting the VM configuration.


Conclusion

Using a physical disk passthrough in Proxmox allows your VM to access storage with near-native performance. This is useful for dedicated drives, testing, or improving I/O. You can attach and remove disks easily using the qm CLI and Proxmox UI.

Let's connect

Stay in the loop with my latest projects and insights! Follow me on Twitter to catch all the updates as they happen. Don't miss out on the journey – let's connect and explore the world of tech together. Click to follow now!