Hi all, this is an example of “the end justifies the means”. I'm sure some experts may disagree with my method but the end result worked. To me that's what matters. This is my story about when I accidentally reformated my main hard drive last week, I thought I'd share................
It's amazing how easy it is to delete partitions or wipe drives by accident. I suppose the easy solution is to always back up and be ready for it but another factor to consider is the time taken to set up your machine just the way you like it.. Email accounts, data, virtual machines etc take plenty of time to set up as well as the download amount and time to bring your system back to current.
Just such a thing happened to me recently where I added a new portable drive to the system and somehow wiped the partitions from my working drive instead of the new drive.
DON'T PANIC! Rushing in without thinking while you are stressed will not help. Turn the machine off, take a deep breath, grab a coffee and when you have gotten over the initial panic work out what to do next. Document what you do so when you work out the best way to handle the problem you will have instructions to follow instead of your memory.
Some good advice I have seen in the forums is to clone the drive and then only work on the cloned drive. I read many threads suggesting various methods to do this, I started with my trusty PCLinuxOS disk but was unable to clone the drive or run Test Disk no matter what I tried. I then thought to use Parted Magic to access the tools suggested in the forums.
To do this you method you will need a second hard drive, preferably one of a different capacity. Add your second drive and boot the PC up using “Parted Magic”. Navigate to Start> System Tool> G4L (ghost for Linux) The reason for using a different size drive if you have two 80gig drives in the machine G4L only indentifies them as SDA, SDB etc. So choosing same capacities but different brands will not help. In my case the deleted drive was a WD800 “Raptor” drive and I cloned it to a Samsung 160gig drive.
In G4L select the “RAW mode” and then “click and clone”. Then select your source drive, go back and select your destination drive. DO NOT get this wrong. (hence why we do this after a coffee etc) Then start the copy only when you are happy you have source / destination correct. This will take 30 minutes to whatever depending on your source drive.
G4L is good as it will do a RAW copy of the drive irrespective of partitions being there or not. As an example “Acronis” will not let you select a “blank” drive for cloning as it needs to see a partition table.
That's the first part of the job done. Shut down, remove you original source drive, mark it as such and put it in a safe place.
Now reboot and select Start> System Tools> Test Disk
I selected the “No Log” option but this would be personal choice methinks. Test disk now looks for physical devices. Select your disk and click “Analyze”. Now at this point “Test Disk” found every bit of rubbish that was ever on this hard drive. As I knew I only used three partitions in Linux, being 12 gig for / (root), 3gig for “swap” and 50gig for “Home” it was easy to pick the restoration. Truth be known “Test Disk” is far smarter than me and I just let it do it's thing as what's most important is I was working from a back up of my drive.
After a reboot I could only log in as “root”. At this point if this happens to you do your backing up as the system went downhill fast after this point. I did find plenty of info about the error messages in the PCLinuxOS forums and maybe could have repaired from this point, however. On a second reboot the system became even more unstable so it's at this point I decided to be more creative. (remember I am fully backed up at this point and only continuing to learn more)
I booted up the PC from my PCLinuxOS 2010.7 disk and reinstalled the operating system being careful to NOT format my “Home” partition. After a reboot the first thing I did was a full system update. I now had a fully functioning basic install. I then reinstalled the missing apps such as Showfoto and Virtual box, reinstalled my printer and was back to a fully functional system. (even my virtual machines worked)
Hope this helps someone.