Alright, this is one of those times when I am are saying... Breathe deep, don't panic.
What happened?
As a usual part of leisurely tinkering with my system, I was trying write a 24.5 MB img file to my USB drive for a BIOS update. The normal command would be:
dd if=bios.img of=/dev/sdX bs=1M
Done that a hundred times. No problem.
Now you know the problem when you're mentally tired and your command turns out like this:
dd if=bios.img of=/dev/sda bs=1M
So it replied: dd: failed to open ‘/dev/sda’: Permission denied
And without thinking twice, you did:
sudo dd if=bios.img of=/dev/sda bs=1M
One should look happy when terminal replied this:
23+0 records in
23+0 records out
24117248 bytes (24 MB) copied, 0.0138706 s, 1.7 GB/s
But what a horror two seconds later when realizing it's your sda.
What's the current status?
The system is still up. It seems that there is a cache of the partition that Linux is reading. The original partition contained efi
, swap
, and /
. I'm not sure now of their original sizes and order. The current partition shows only 22.98 MiB of fat16
to be mounted on /boot/efi
, while the rest of my SSD drive is unallocated.
So, this is one of those times when one should say... Breathe deep, don't panic, and do not reboot (yet).
Any help? Pleeeaaaase? ;-) Thanks.
It's been four days, and accepting the comments from the original question, I took the opportunity to do a fresh install of the system. (And that's why it's good for your home directory to be in a different disk...)
On the other hand, I think I accidentally (not again...) found the tool(s) that could have been used that time. "Could" was highlighted since of course, I was not able to try this. For those that can try these later (we hope not on your working system), maybe you can confirm if these really work:
testdisk
from theuniverse
repo. Their official website says: "It was primarily designed to help recover lost partitions and/or make non-booting disks bootable again when these symptoms are caused by faulty software: certain types of viruses or human error (such as accidentally deleting a Partition Table). Partition table recovery using TestDisk is really easy."There you go, automated.
gpart
from the official repos. The Wikipedia article says, "It is also good at finding and listing the types, locations, and sizes of inadvertently-deleted partitions, both primary and logical. It gives you the information you need to manually re-create them (using fdisk, cfdisk, sfdisk, etc.). The guessed partition table can also be written to a file or (if you firmly believe the guessed table is entirely correct) directly to a disk device."Well, learning is a great thing. ;-)
PS
To install:
sudo apt install testdisk gpart