Can you passthrough a known bad HD to a VM?

CancunManny

New Member
Dec 30, 2023
20
1
3
I have a known bad 4TB HD. I tried to rescue files with my regular PC but was just too cumbersome since I had to keep computer on, had case open with hard drive stiking out, etc.

I now have a new computer, so my old one became a proxmox server. I created a VM with ubuntu, and was able to passthrough a good 4TB hard drive that I plan to use to capture the recovered files. However when I try to passthrough the known bad hard drive I get an error. I want to use tools like ddrescue, testdisk, etc to try and recover some files.

When I list disks this is what I get

root@proxmox:~# find /dev/disk/by-id/ -type l|xargs -I{} ls -l {}|grep -v -E '[0-9]$' |sort -k11|cut -d' ' -f9,10,11,12 16:32 /dev/disk/by-id/ata-ST4000DM000_WDH0ZXXX -> ../../sda 16:32 /dev/disk/by-id/wwn-0x5000c5009d4b4XXX -> ../../sda 16:32 /dev/disk/by-id/ata-KINGSTON_SV300S37A240G_50026B7246055XXX -> ../../sdb 16:32 /dev/disk/by-id/wwn-0x50026b7246055XXX -> ../../sdb 19:01 /dev/disk/by-id/ata-ST4000DM004-2U9104_ZW60PXXX -> ../../sdc 19:01 /dev/disk/by-id/wwn-0x5000c500e6c82XXX -> ../../sdc root@proxmox:~#

sda is the known bad hard drive
sdb is the hd being used by proxmox
sdc is the 4tb drive that will receive the recovered files

As a side note, I only passed the /dev/disk/by-id/wwn-0x5000c500e6c82XXX -> ../../sdc to my VM, do I also need to passthrough /dev/disk/by-id/ata-ST4000DM004-2U9104_ZW60PXXX -> ../../sdc or should I be passing only the ata one?

When I try to passthrough the bad drive I get this:


root@proxmox:~# qm set 104 -scsi2 /dev/disk/by-id/ata-ST4000DM000_WDH0ZA0M update VM 104: -scsi2 /dev/disk/by-id/ata-ST4000DM000_WDH0ZA0M qemu-img: Could not open '/dev/disk/by-id/ata-ST4000DM000_WDH0ZA0M': Could not read image for determining its format: Input/output error could not parse qemu-img info command output for '/dev/disk/by-id/ata-ST4000DM000_WDH0ZA0M' - malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "(end of string)") at /usr/share/perl5/PVE/Storage/Plugin.pm line 954. volume /dev/disk/by-id/ata-ST4000DM000_WDH0ZA0M does not exist root@proxmox:~#

How can I access the bad drive to scan it and try to recover files?

Thanks in advance for any and all suggestions
 
Thats no real passthrough. For your VM to be able to directly access the real physical disks you would need to PCI passthrough a whole disk controller (with all disks attached to it). With "qm set" your VM is working with a virtual disk that is mapped to the physical disk so there is another abstraction layer in between you probably don't want when trying to rescue data from a bad disk.

Would be easier to boot some data recovery Live linux distro bare metal and then try with that to rescue some data.
 
Last edited:
Thanks for the feedback. Seems I will store the bad drive until I have a bare metal I can sacrifice for a week or two while I try to recover some files.

ty again!
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!