How recover broken HDD Linux containers and virtual machine?

Evosis

Member
May 25, 2021
3
0
21
35
Hi
I'm using proxmox virtual environment. Last month server HDD is broken. I recover some files but can't find virtual machine hdd files.
 
Most likely there are no files because VMs use block devices. If using LVM or ZFS these are LVs or zvols and not just files inside a filesystem you can mount to access them.
 
The system cannot be booted on the system disk. Is it possible to plug it into a second computer and recover the system?
 
Sure, you could boot a Ubuntu Live Iso on the same server or another computer and try to rescue stuff. But would be useful if you know what your storages were setup like. LVM, ZFS and so on.
You didn't created any backups?
 
Sure, you could boot a Ubuntu Live Iso on the same server or another computer and try to rescue stuff. But would be useful if you know what your storages were setup like. LVM, ZFS and so on.
You didn't created any backups?
Yes I have Backup but inside in the virtual machine...
But I guess that's the same as not making any backups.
 
Yes I have Backup but inside in the virtual machine...
But I guess that's the same as not making any backups.

Hi,

I am truly sorry for you(I also had have such events in the past). After ... I learn that at minimum, you must have a remote backup(in the same site on other server/HDD-usb) + off-site backup.


Good luck / Bafta!
 
Hi

yeah this sucks...
As Dunuin already pointed out: Proxmox most likely uses Block devices for your VM HDDs. But that depends on your setup. The default configuration is a LVM structure, that creates a separate LV for every virtual harddisk.
If the HDD is not totally busted you might be able to rescue the volumes. BUT: be careful. Depending on what exactly the issue is, turning on that drive might further the damage.
I would suggest to put the drive into another Machine, do NOT mount it anywhere. Dump everything from that drive bitwise into an image on some Storage via dd.

You can do this by using the following command as root: dd if=<input block device eg. /dev/sda> of=<somefilename> conv=noerror status=progress

After that, your file will contain a bitwise exact copy of that drive. Obviously any erroneous sectors will be empty. You maybe do not want to touch that file exept for reading, since it is your last most intact copy of that drive that you might get. for this reason you should then detach the defective drive, attach a healthy drive and write that image to the new drive.

From there you can try to use the lvm tools to find and attach the logical volumes to block devices. These block devices can then be dumped via dd again to some raw images that can be attached to a virtual machine.
BUT beware: Any of these Images can contain Errors in your Data. Wrong entries in databases, damaged Files, unmountable Filesystems etc. Be sure to carefully check what you retrieve from this ;)

I hope this might help you to recover at least something.