2

I was supposed to run a command on /dev/sdb which is a flash drive to create a new GPT table. Accidentally, I've not noticed that I was working on /dev/sda and I've created a new GPT table using fdisk and I deleted the vfat signature. I know for sure, my system once restarted will not boot again. What should I do? This is a bad day!

1

Would it be faster to simply backup (eg, don't turn the box off!), reinstall, and restore? If not, maybe this'll help: http://www.tldp.org/HOWTO/Partition/recovering.html

TL;DR:

  1. make a partition larger than the deleted partition.
  2. run dumpe2fs on the partition (assuming you're using ext4 or variant) and grep block count: dumpe2fs /dev/sda1 | grep "Block count:"
  3. delete the partition
  4. recreate the partition with the block size you got from step 2 ; you may need to specify this in cylinders: num_cylinders = (step2_blocks /(block_size = (unit_size = ((number of heads) * (number of sectors/cylinder) * (number of bytes/sector))/1024)))
  5. fsck /dev/sda1
  6. At this point, should be mountable on reboot. I'd still back that puppy up before putting it to the test.

If you've got more partitions, repeat procedure above for each of them in turn.

  • you should write what is in this link here. Then this solution will be always on this community if this link breakes. – Vitor Abella Aug 3 '17 at 20:03
  • Well, I'm out of luck. I've reinstalled the operating system and all my files are gone. That's why I'm bastard. – direprobs Aug 4 '17 at 8:52
  • Sorry to hear that. We've all been there. – sloth-jr Aug 4 '17 at 11:33

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.