…because I’m an idiot. Fortunately it was a backup drive, and I believe the only thing on it was backups of backups fortunately.
I was setting up to installing Debian on another computer and ran:
sudo dd bs=4M if=debian-12.4.0-amd64-DVD-1.iso of=/dev/s?? status=progress oflag=sync
to flash it to a usb drive. I hadn’t realized the system had reassigned hard drive device ID from the previous day, and for about 3 seconds it executed before I terminated the process once I realized what I did.
I immediately created a disk image of the Data-Destroyed hard drive just in case I screwed something up in trying to recover it.
I ran testdisk, but I’m not really sure how to use it or how to try to recover the data. The drive mounts okay, and shows it has 19,336 items totalling 8.2 GB of the Debian system files.
Is this beyond repair?
The files that were overwritten in the first 3 seconds are gone. Though, It’s likely that most, if not all the data is okay. Hopefully its just the pointers to the files that was over written, meaning you’ll have to use some file recovery software on the disk/image to get it back. I don’t have any software suggestions to do that.
DD nuked the partition info and the first several hundred megabytes of data.
Next time, I would suggest setting up Ventoy so you don’t have to dd iso files to the flash drive anymore.
Yeah that’s the first thing I wrote in my notes, to stay far far away from dd.
Ventoy isn’t in the Debian repos, but I did find a similar program there - Gnome multi writer. I’ve used unetbootin in the past on Ubuntu, but Debian instructions specifically say not to use a program like unetbootin for some reason. I’ll give the multi writer a shot the next time I do a fresh install, thanks for the tip!
Ventoy isn’t something you need to install on your system. It’s a boot loader that gets installed on a flash drive. You can just copy ISO files to the flash drive and pick which one you want from the boot menu.
MultiWriter is basically just doing the same thing dd does, but with a GUI.
Phtorec can scan the drive and try to recover your remaining data. I’ve used it in the past to get files back from dying drives. Linky https://www.cgsecurity.org/wiki/PhotoRec
I used something called GetDataBack at an old MSP. If the file system is supported, it might work. It takes an extremely long time to run… just fyi. I usually duplicated the troublesome drive beforehand to an identical or larger sized one just in case.
I looked up alternates to that to see if there is anything officially in the Debian repos, and there is something called Sleuth Kit / Autopsy for hard drive data recovery. I’ll give that a shot when I get a chance, looks like it might take awhile but it’s a good learning experience, even if there’s nothing that important that I lost. Thanks for the tip!
A time machine barring that the data DD overwrote is gone. there are some theories around being able to recover things with an electron microscope but eh. You could repair the partition table and see what you can get back but its best to consider the data knackered. Sorry probably not what you want to hear but it is what it is.