About 6 hours ago, I intended to blank my flash drive and redo a bad-block scan (the thing is probably dead at this point, but occasionally, I can get one more use out of it)... so I typed the command
dd if=/dev/zero of=/dev/sda
Note: my flash drive is sdb. sda is my hard drive.
So, about half 1 second later, I killed it and cursed myself for getting a fast hard drive... I had already blasted the first 14 Gib, rendering Windows unbootable, and the partition table useless.
So, I tried gpart (found 2 ext2 partitions and a BFS one, none of which existed, but nothing else.
Worse, I didn't have any form of partition table backup, so I couldn't just restore them.
So, for anybody who screws up this royally on Linux, here's how to recover:
1) don't panic. If I did, I probably would have rebooted...
2) cat /proc/partitions. That will show you the length of each of your partitions, but not the order
3) start up fdisk, and hit 'u' to go to sector mode
4) create partitions, in the order you think they're in, using the default offset and the the number of blocks * 2 reported by /proc/partitions. DON'T create the extended partition, though... otherwise you'll lose the extended partitions.
5) write it to the disk
6) using losetup, stick each partition onto a loopback device, (everyone here should know how to find the parameters for that...) and run
file -s /dev/loop0
to make sure that you have the right parameters. It should report information on your filesystem, and NOT "data"
Also, notice that, until you run hdparm -z, the partition devices are still correct (/dev/sda1...), so you can compare against those.
7) When you're sure that everything is correct, reinstall grub, cross you fingers, and reboot. If the moons are aligned correctly, everything will work.
Then, make an MBR backup. With it, this becomes MUCH easier.
To err is human; to really foul up takes root privs...
I've done that, too... and used my grub boot floppy as a framebuffer...Candy wrote:At least you didn't dial into your harddisk... (historic oopses, chapter one: when Linus changed full-time to Linux)
Actually, a random screenshot from my framebuffer-hacking days is http://thequux.com/modules/xoopsgallery ... 01/fb2.png. (ps... that console font has been converted to a vga font image, and is in my latest kernel snapshot...). I do believe that that was my crowning achievement... besides the fbforth library which was a completely FORTH-based interface to the Linux fbdev interface...
Ahh, it just goes to show that it's not just command line tools that are being used in unintended ways...
My project: Xenon