How to add/attach a physical HDD to VM libvirt

This post will be older than settings and installation of a VM but still is very important topic for users who deal with VMs.

I build my VMs on NVMe m.2 ssd but we may need TBs of data and we need to access that datas in our guest too. The solution for media files generally adviced to use samba which allows guests to access files over LAN. What about game files ? Maybe your Steam folder ?

I will attach sdb which is 1TB mechanical hdd for steam folder. But sdb will not be points out to my 1TB hdd in everytime. so, we need to fix the identity of the HDD. Go to the “
->Disks
->Choose the partition
->Additional partition options (Gears)
->Edit Mount Options
-> Choose /dev/disk/by-id/ata– …..

    <disk type="block" device="disk">
      <driver name="qemu" type="raw"/>
      <source dev="/dev/disk/by-id/ata-WDC_WD10EZEX-00MFCA0_WD-WCC6Y5ZE8TJ5-part2"/>
      <target dev="vdb" bus="virtio"/>
      <address type="pci" domain="0x0000" bus="0x08" slot="0x00" function="0x0"/>
    </disk>

Adding this code block to libvirt xml file under the windows.qcow2 or whatever your file name and extension, this setting will solve the problem.

source : https://www.charleslabri.com/adding-passthrough-physical-disk-in-kvm-guests/

Leave a Reply