oreilly.comSafari Books Online.Conferences.


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

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.

Linux Online Certification

Linux/Unix System Administration Certificate Series
Linux/Unix System Administration Certificate Series — This course series targets both beginning and intermediate Linux/Unix users who want to acquire advanced system administration skills, and to back those skills up with a Certificate from the University of Illinois Office of Continuing Education.

Enroll today!

Linux Resources
  • Linux Online
  • The Linux FAQ
  • Linux Kernel Archives
  • Kernel Traffic

  • Sponsored by: