0

I accidentally used dd on my secondary hard drive while trying to write an install disk. The command was dd bs=4M if=foo.iso of=/dev/sdb

Fortunately, I umounted the flash drive and not the hard drive, so the drive was still mounted.

Following another forum post, I was able to pull

/dev/blocks/sdb/sdb1/start: 1197565952

/dev/blocks/sdb/sdb1/size: 4662966272

/dev/blocks/sdb/sdb2/start: 2048

/dev/blocks/sdb/sdb2/size: 1197563377

sdb1 was ext4, sdb2 was ntfs. I'm fairly sure it was gpt, but I don't know how to check.

That's as far as I got though. I'm a bit of a newbie, please give me step by step if possible.

  • How large is the ISO file you copied to the disk? Did you interrupt the process? If you did, how much did it copy? – Daniel B May 22 '18 at 8:53
  • @daniel It was a xubuntu 18.04 iso. Its about 1.3 gb. I allowed it to finish writing before I realized what i did. The previous partition table got overwritten – BabylFish May 22 '18 at 8:59
  • So I assume this is a 6 TB drive, correct? Are you positive the order of partitions in the table was switched from the physical order? – Daniel B May 22 '18 at 9:11
  • @daniel It is a 2.7 tb drive. I'm not positive about the order of the partitions. It was originally formatted on a windows machine. I used gparted to shrink the ntfs partition and move it all the way to the left. Then i made an ext4 partition in the space to the right. – BabylFish May 22 '18 at 9:16
  • Oh, the sizes are in 512-byte blocks, oops. Well, sounds like GParted didn’t fix the order. Was there any data of relevance on the NTFS partition (sdb2)? – Daniel B May 22 '18 at 9:24
1

Update: It turns out the drive was gpt and the backup gpt header and partition table were not corrupt. I was able to use gdisk to load and write the backup gpt header and partition table back onto the disk using this tutorial:

https://lihashgnis.blogspot.com/2016/07/recovering-from-corrupted-gpt-partition_30.html

The ext4 partition was accessible via a manual mount from the terminal, but the ntfs partition was damaged. I had to use "chkdsk /f" from a windows install disk to fix the ntfs partition.

Hope this helps someone else in a similar situation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.