LinuxDevCenter.com

oreilly.comSafari Books Online.Conferences.

We've expanded our Linux news coverage and improved our search! Search for all things Linux across O'Reilly!

Search
Search Tips

advertisement

Listen Print Discuss Subscribe to Linux Subscribe to Newsletters

Four Tough Lessons of System Recovery
Pages: 1, 2

The Real Solution

At this point, I came eye to eye with the Knoppix CD on the shelf (figuratively speaking). Remembering my mistake, I took the CD from the shelf, put it inside the laptop and booted with LILO command line: knoppix lang=tr 2, which would open with the Turkish locale to runlevel 2--more than enough for me.



I was worried that Knoppix would not recognize my brand new SATA device and I would be totally helpless. To my relief, cfdisk recognized the disk just fine, although there was nothing to see thanks to that wonderful and unnamed partition rescue software.

After that, I started gpart, which easily found my missing partitions.

Thumbnail, click for full-size image.
Figure 1. gpart finds the partitions. (Click for full-size image.)

I noted the exact sector numbers of those partitions and started fdisk. The exact output of gpart was:

root@1[knoppix]# gpart /dev/sda

Begin scan...
Possible partition(Windows NT/W2K FS), size(40000mb), offset(0mb)
Possible partition(Windows NT/W2K FS), size(24998mb), offset(40000mb)
Possible partition(DOS FAT), size(13348mb), offset(64998mb)
Possible partition(Linux ext2), size(16286mb), offset(79106mb)
End scan.

Checking partitions...
Partition(OS/2 HPFS, NTFS, QNX or Advanced UNIX): primary
Partition(OS/2 HPFS, NTFS, QNX or Advanced UNIX): primary
Partition(DOS or Windows 95 with 32 bit FAT, LBA): primary
Partition(Linux ext2 filesystem): primary
Ok.

Guessed primary partition table:
Primary partition(1)
   type: 007(0x07)(OS/2 HPFS, NTFS, QNX or Advanced UNIX)
   size: 40000mb #s(81920097) s(63-81920159)
   chs:  (0/1/1)-(1023/254/63)d (0/1/1)-(5099/74/63)r

Primary partition(2)
   type: 007(0x07)(OS/2 HPFS, NTFS, QNX or Advanced UNIX)
   size: 24998mb #s(51196312) s(81920160-133116471)
   chs:  (1023/254/63)-(1023/254/63)d (5099/75/1)-(8286/29/55)r

Primary partition(3)
   type: 012(0x0C)(DOS or Windows 95 with 32 bit FAT, LBA)
   size: 13348mb #s(27336896) s(133116543-160453438)
   chs:  (1023/254/63)-(1023/254/63)d (8286/31/1)-(9987/194/62)r

Primary partition(4)
   type: 131(0x83)(Linux ext2 filesystem)
   size: 16286mb #s(33354720) s(162010800-195365519)
   chs:  (1023/254/63)-(1023/254/63)d (10084/180/1)-(12160/239/63)r

In fdisk I entered sector mode (for that gpart output was in that format) and began to build a new partition table, which was, in fact, an identical copy of the old one.

For this I wrote fdisk /dev/sda and then pressed o (an empty partition table).

Next I pressed u to change to the sector mode. Then I pressed n (new) and p (primary) and made my first partition (which used to be C). Then I changed its type to 07 for NTFS.

One by one, I rebuilt the partitions. Finally, I selected sda1 as the active boot partition.

After I wrote the partition table, I saw that Knoppix realized that there was a change and udev checked those partitions and mounted them. Needless to say, all my data was there, with nothing missing.

What a relief. I rebooted my laptop--with great expectation, if I may add--and saw that... it would not boot.

I was pretty sure that this had nothing to do with the partition. Most probably the MBR or Windows bootloader had some kind of a problem. Solving this would be easy; I just had to boot with the XP Pro install CD and enter recovery mode.

Thumbnail, click for full-size image.
Figure 2. The cfdisk partition list. (Click for full-size image.)

Finally Reinstalling Windows

With all of my good expectations, I once more had a problem. My Windows XP installation CD lacked the drivers of the brand new SATA disk; therefore, it could not see the hard disk. If that was not enough, it asked me--IMHO mockingly--if I had a disk with my needed drivers. Politely I told the computer that if I even had such a disk, I did not know where to insert it, because my brand new laptop, most understandably, lacked a floppy drive. The installation was not completely unreasonable and told me that a USB diskette driver would do the job, but a USB flash disk or a CD-ROM would not.

This was ridiculous. Looking around for any signs of a Candid Camera crew, I used my old laptop to search for a workaround.

There was a way. A fabulous little program called nLite makes it trivial to prepare a custom Windows installation disk. This disk can include your preferred service pack, hot fixes, device drivers, and even pre-installed software. In addition to this, the program was capable of building a full automated, unattended installation.

Thumbnail, click for full-size image.
Figure 3. The nLite welcome screen. (Click for full-size image.)

I made a new installation CD including my SATA drivers and booted the laptop with that.

Thumbnail, click for full-size image.
Figure 4. nLite lets you customize your installation. (Click for full-size image.)

After entering the recovery mode by pressing r, I gave two commands, fixboot and fixmbr, and booted one final time. (I prepared to accept defeat if even this proved futile).

I don't know if the gods showed me mercy or the little computer gnomes finally gave up. Windows booted just fine with everything in its proper place (some four hours later if I may add).

After this, booting again from Knoppix and reinstalling grub was easy.

I've learned four lessons from this incident.

  • If you realize that you are (still) in a mistake, use the backups. Do not be lazy about this. No matter how bad your situation is, you can always end up in a worse one.
  • Never be doubly lazy. If you are taking a shortcut to avoid a lot of work, do so properly. In this case, I was mistaken to search for a do-it-all program, while I knew that I had a program to do the job correctly, albeit with a little more work.
  • Take the time to choose the right tool. Searching for and using the wrong tool cost me almost four hours, while the right tool (which was under my hand from the very beginning) fixed everything in just half an hour.
  • Although mistakes cost you time, patience, and/or hair, they do teach you. Try to avoid them if you see them coming, but if you cannot, show respect and solve them. Remember, good enemies always make you a better fighter.

KIVILCIM Hindistan works as a full time computer security consultant with a CISSP, using Linux and Free Software as weapons of choice.


Return to the Linux DevCenter.


Have you used Knoppix or another rescue CD to recover from catastrophic failures? Let us know.
You must be logged in to the O'Reilly Network to post a talkback.
Post Comment
Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • system recovery
    2007-09-29 23:39:20  foxy78 [Reply | View]

    its realy helpful for it guys like us to know that life can be easy with the info you give us

    Crystal Figurines (http://www.crystalnaples.com)
  • The right disk?
    2006-09-06 10:22:04  ckolos [Reply | View]

    One thing that's always saved me a great deal of confusion is specifying the exact disk I want to partition from the command line...

    Meaning:

    cfdisk /dev/sda

    instead of

    cfdisk



Tagged Articles

Be the first to post this article to del.icio.us

Sponsored Resources

  • Inside Lightroom
Advertisement

Sponsored by:

O'Reilly Media

©2009, O'Reilly Media, Inc.
(707) 827-7000 / (800) 998-9938
All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.
About O'Reilly
Academic Solutions
Authors
Contacts
Customer Service
Jobs
Newsletters
O'Reilly Labs
Press Room
Privacy Policy
RSS Feeds
Terms of Service
User Groups
Writing for O'Reilly
Content Archive
Business Technology
Computer Technology
Google
Microsoft
Mobile
Network
Operating System
Digital Photography
Programming
Software
Web
Web Design
More O'Reilly Sites
O'Reilly Radar
Ignite
Tools of Change for Publishing
Digital Media
Inside iPhone
O'Reilly FYI
makezine.com
craftzine.com
hackszine.com
perl.com
xml.com

Partner Sites
InsideRIA
java.net
O'Reilly Insights on Forbes.com