Preparing for the worst.
Unfortunately I did not. I really wish i had taken the time to do some type of HD backups, if i had, i would not have lost everything. A lot of people believe you need to pay money for a good HD backup software. Thanks to Linux this is not true, as i will illustrate below you can do it for free!
Most of you, probably everyone besides me, do not care about my troubles but here’s how my week went down. Monday morning 7 AM i get into work, resume standby and start my day. Computer is running horribly slow so i start doin some diagnostics. I turn to the event viewer and see the following message:
The device, \Device\Harddisk0\D, has a bad block.
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
YIKES. I have a C drive (purely for windows and windows partition dependant components) and a D drive for everything else. I share the D drive between my Windows and Linux OS. I quickly restart and boot into Linux so i can start to backup my crap. I boot into Ubuntu and start copying my email, documents, etc to my External Hard-drive. I copy my email, some of my programing projects, and get to my Documents. I start to copy everything and notice that it is stating it will take almost a day to complete, i decided to ditch my pictures and just take my documents. Well that proved to be a tragic mistake. I finish my documents and decide to try to get my pictures one more time… computer hard locks. As a result i am force to hard reset and upon restart i get an unrecognized boot device. Good bye Mr. Hard drive.
In attempt to save my disk i instantly used a rescue CD to scan my HD for partitions. The recovery disc gave me all the info i needed to recreate my partition table (First Sectors, and Number of sectors). I jot them down and try to recreate the partition table and am constantly hit with I/O Write Failed error in Linux. I run a ntfsfix and a fsck and find out that the sector that went bad bridges my Extended partition. So it sits before and after the sector that begins the Logical partition that my D drive is located on. That didn’t come out clean so for example lets say my Primary Partition starts at sector 63 and ends at 1024. My extended partition starts at 2048 and ends at infinity. Well the sectors that went bad were 2040-2050. As a result it was not letting me we write the parition table. I am sure there is some way to fix my issue, at least to recover my data, but after a day of attempting and i am sure some horribly rash and impatient decisions, i lost everything.
Pessimistic Backup Strategy
Well if you can’t control the future, you can the past. I now have scripted a routine to automatically perform a backup once a month of my important files (Sandbox, Documents, Pictures). I will no longer have to worry about losing data. during the process i came a cross a free way to do HD Imaging. Its very fast, and like i said, most importantly free. The tools required are an External Hard Drive and a Ubuntu Live cd. Steps are outlined below(Pictures might follow, but i am running out of space).
- Download the Ubuntu Live CD (http://www.ubuntu.com/GetUbuntu/download) and burn the ISO.
- Make sure your External HD is in the NTFS format. If it is not you will not be able to create a file larger than 4 GBs(assuming it is Fat32). If your HD is unfortunatly formated in the wrong FS type perform a convert and get that thing to the 20th century.
- Boot into Ubuntu and choose the option “Try Ubuntu without any change to your computer”. This will load Ubuntu into memory without touching the HD. (Completely safe..)
- Once you boot into linux make sure you know which devices you are going to backup. For me i have a sata drive and i was backing up my primary (/dev/sda1) and my storage (/dev/sda5). If you are using ide it might be hda, just an fyi.
- Make sure your External Drive is mounted R/W and you know where once again for me it was mounted to /media/My\ Passport.
Now the fun begins. To backup your stuff issue the following command.
# sudo ntfsclone –save-image –output /media/My \Passport\backups\laptop\backup_c.img /dev/sda1
It took my computer about 5 minutes to backup my C drive (only about 3 GB used) and 10 for my D (~5 GB).
In the event you ever need to perform a full restore the process is simple.
- Format your hard-drive. I used GParted but you can do it however you want. If you use GParted just execute sudo gparted in a terminal and it will launch the GUI. Its a pretty simple process. I created a Primary Drive, and then a Storage drive 60 GBs and and then a Linux Partition about 5 GBs. One thing i was able to do was restore the image to a different sized HD! I was able to load my old storage drive which was about 40 GBs into the larger one seamlessly.
- When you are ready to restore type the following command in a terminal
#sudo ntfsclone –restore-image –overwrite /dev/sda1 /media/My\ Passport\backups\laptop\backup_c.img
After about 10 minutes you are done!
I actually use this technique to re-load my computer once i am done on a project. I have saved off a “fresh” OS install that has a computer that is configured to run java and one that has the full .net stack (SQL Server 2005, BizTalk, Visual Studio 2005 and 2008, etc) and in less then 30 minutes i can have a computer that has been completely rebuilt. It truly is a powerful tool if you use it to its full potential.