Difference between revisions of "Passthrough Physical Disk to Virtual Machine (VM)"

From Proxmox VE
Jump to navigation Jump to search
m (Nicholas A. Schembri moved page Physical disk to kvm to Using a Raw Physical Hard Drive as Passthrough to QEMU/KVM Virtual Machine(VM) on Proxmox VE(PVE): This page was hard to find from google. I'm hoping to line up with virtual box and other...)
(Formatted to add link to tutorial and Disk Recovery Tools - I have a failed disk in a cluster I can't get access to. How do recover the data without taking the proxmox host out of service? Repair the disk from inside the kvm vm)
Line 1: Line 1:
'''NOTE''': This guide only works for Virtual Machines, '''not''' for Container. For that see https://forum.proxmox.com/threads/container-with-physical-disk.42280/#post-203292
+
By adding the raw physical device to the Virtual machine, you can test installers and other disk repair tools that work with disk controllers like ddrescue, gnu ddrescue, Clonezilla, Ubuntu Rescue Remix.
  
Before adding physical disk to host make note of vendor,serial  so that you'll know which disk to share in /dev/disk/by-id/  
+
 
 +
 
 +
'''NOTE''': This guide only works for Virtual Machines, '''not''' for Container. For that see https://forum.proxmox.com/threads/container-with-physical-disk.42280/#post-203292
 +
 
 +
As the disk is attached to the physical and virtual host, this will also prevent Virtual Machine live migration. A second side effect is host system IO wait, when running ddrescue, other vm's running on the host can stutter.
 +
= Attach Pass Through Disk =
 +
== Identify Disk ==
 +
Before adding a physical disk to host make note of vendor, serial  so that you'll know which disk to share in /dev/disk/by-id/  
  
 
lshw on pve host after adding.  note use ''apt-get install lshw'' if lshw is not already installed.   
 
lshw on pve host after adding.  note use ''apt-get install lshw'' if lshw is not already installed.   
Line 33: Line 40:
  
  
*add to kvm :
+
== Update Configuration ==
 
<pre>
 
<pre>
 
qm set  592  -scsi2 /dev/disk/by-id/ata-ST3000DM001-1CH166_Z1F41BLC
 
qm set  592  -scsi2 /dev/disk/by-id/ata-ST3000DM001-1CH166_Z1F41BLC
Line 40: Line 47:
 
</pre>
 
</pre>
  
* check
+
== Check Configuration File ==
 
<pre>
 
<pre>
 
grep Z1F41BLC /etc/pve/qemu-server/592.conf
 
grep Z1F41BLC /etc/pve/qemu-server/592.conf
Line 47: Line 54:
 
</pre>
 
</pre>
  
*stop and restart ... then configure disk from within the kvm.
+
== Stop and Restart KVM Virtual Machine ==
 +
You may need to configure the guest operating system now that the disk is available.
 +
 
 +
= Tutorial =
 +
[ https://dannyda.com/2020/08/26/how-to-passthrough-hdd-ssd-physical-disks-to-vm-on-proxmox-vepve/ Example with screenshots ]
 +
 
 +
= Disk Recovery Tools =
 +
# Ubuntu Rescue Remix - [ http://www.geekyprojects.com/storage/how-to-recover-data-even-when-hard-drive-is-damaged/ how to use Ubuntu Rescue Remix and Ddrescue ]
 +
# ddrescue
 +
# gnu ddrescue
 +
# Clonezilla
 +
# TestDisk
 +
# PhotoRec
 +
# Recuva
 +
# Foremost
 +
# Parted Magic
 +
# SpinRite - Low Cost Commercial - Smartctl tutoral on proxmox planned

Revision as of 20:12, 22 November 2020

By adding the raw physical device to the Virtual machine, you can test installers and other disk repair tools that work with disk controllers like ddrescue, gnu ddrescue, Clonezilla, Ubuntu Rescue Remix.


NOTE: This guide only works for Virtual Machines, not for Container. For that see https://forum.proxmox.com/threads/container-with-physical-disk.42280/#post-203292

As the disk is attached to the physical and virtual host, this will also prevent Virtual Machine live migration. A second side effect is host system IO wait, when running ddrescue, other vm's running on the host can stutter.

Attach Pass Through Disk

Identify Disk

Before adding a physical disk to host make note of vendor, serial so that you'll know which disk to share in /dev/disk/by-id/

lshw on pve host after adding. note use apt-get install lshw if lshw is not already installed.

lshw -class disk -class storage

...
           *-disk
                description: ATA Disk
                product: ST3000DM001-1CH1
                vendor: Seagate
                physical id: 0.0.0
                bus info: scsi@3:0.0.0
                logical name: /dev/sda
                version: CC27
                serial: Z1F41BLC
                size: 2794GiB (3TB)
                configuration: ansiversion=5 sectorsize=4096
...
  • device names like /dev/sdc should never be used as those can change. instead use /dev/disk/by-id . check by listing all of that directory then look for the disk added by matching serial number from lshw and the physical disk :
ls -l /dev/disk/by-id/ata-ST3000DM001-1CH166_Z1F41BLC
lrwxrwxrwx 1 root root 9 Jan 21 10:10 /dev/disk/by-id/ata-ST3000DM001-1CH166_Z1F41BLC -> ../../sda

or try

ls -l /dev/disk/by-id | grep Z1F41BLC


Update Configuration

qm set  592  -scsi2 /dev/disk/by-id/ata-ST3000DM001-1CH166_Z1F41BLC

update VM 592: -scsi2 /dev/disk/by-id/ata-ST3000DM001-1CH166_Z1F41BLC

Check Configuration File

grep Z1F41BLC /etc/pve/qemu-server/592.conf

scsi2: /dev/disk/by-id/ata-ST3000DM001-1CH166_Z1F41BLC,size=2930266584K

Stop and Restart KVM Virtual Machine

You may need to configure the guest operating system now that the disk is available.

Tutorial

[ https://dannyda.com/2020/08/26/how-to-passthrough-hdd-ssd-physical-disks-to-vm-on-proxmox-vepve/ Example with screenshots ]

Disk Recovery Tools

  1. Ubuntu Rescue Remix - [ http://www.geekyprojects.com/storage/how-to-recover-data-even-when-hard-drive-is-damaged/ how to use Ubuntu Rescue Remix and Ddrescue ]
  2. ddrescue
  3. gnu ddrescue
  4. Clonezilla
  5. TestDisk
  6. PhotoRec
  7. Recuva
  8. Foremost
  9. Parted Magic
  10. SpinRite - Low Cost Commercial - Smartctl tutoral on proxmox planned