3

I am new to linux(ubuntu) and made my first mistake. Hoping for some help. I accidentally formatted usd hard drive (sudo mkfs.ext4 /dev/sdb1). I have been searching and found that testdisk might help? I've also read a few thing that mentioned restoring via superblocks. Has anybody gone through this or know the best way to fix it?

I appreciate the help.

thank you

Nick

1 Answers1

2

Nick, ouch. Been there.

I recommend making a bit-for-bit backup of the disc first. Use dd if=/dev/sdb of=~/sdb.img (This assumes you have enough space in your home directory, so if /dev/sdb is a big disc, you'll have to get a bigger disc to write your backup image to, which can also be a USB disc if you prefer, but usually these are slower than direct-attach SATA).

After doing that, testdisk is your tool of choice. You want to try to recovery the original partition. testdisk will look for possible partitions, and after finding one, will offer you the opportunity to write the partition back to the disc.

Only then, run testdisk and try writing the partition metadata back when it finds your lost partition. With luck, your files are still there. Good luck.

If you have experience with mounting loopback devices, you can also do the testdisk run on the image file, and after writing the partition metadata back to it you can mount it as a loopback device. This can be more complicated, if for example, it's an LVM partition and/or encrypted.

Rich
  • 776