Linux recovers XP boot sector(s)
March 16th, 2007
Well, a post about Windows… who’d say about that…
The thing is: is have a HP desktop that after a good BIOS update, got its motherboard dead. Good BIOS update. Pretty much dead motherboard. Not only happened to me. There are foruns about these HP BIOS updates for this motherboard series that gave lot’s of problems. No warranty, so no HP help, after talking to HP tech dept., support dep., and even quality dept. So, two solutions: get someone to rebuild the PLCC chip info, or buy new material. Faster, buy. New motherboard, processor, memory. Installation madness: had do hard-wire cables to some pins (some front panel functions). Nothing that a good manual circuit reading couldn’t do.
Turn on: everything running fine except for the front big blue light. 1 minute to fix it. Now, let’s see who will behave better on this first boot up: the OEM Win XP or the Ubuntu Edgy GNU/Linux installation? Fast answer: XP reboots after 2 secs. No way to make it run, using any boot options. Edgy got it to the end, just needing a X-server reconfiguration. Wow! Linux wins.
XP: when trying to reinstall the thing from the Recovery Partition, couldn’t do it either. Very funny long error message to phone call someone and a Code Purple. Code Purple ? What the… So i e-mailed Microsoft questioning if i’d lost the license to run that HP OEM XP, sending my Key on that email. Yes, i did register XP, i do just have legal software. First e-mail response: buy a new one or check our support page. New e-mail: my motherboard got broken. Had to buy a new one and therefore all the other material. Who can i contact to give me a simple, valid, complete answer ? New response, very helpfull this time. I’ll send some data, the OEM Key, invoices for the PC and new motherboard and they even want a damage report for the morherboard
Ok… i’ll send it all. I’m cooperative.
But before all this, i made a mistake… When reinstalling GRUB i did a:
sudo grub-install --root-directory=./ /dev/hda1
The problem is in hda1, the “1″ more precisely. Mistake. It should have been .../hda. So, no boot for the FAT32 XP Recovery Partition. Using the Recovery Console was unsusefull, with that fixboot. I didn’t trust the fixmbr, nor i needed it. After some reading and having only one distro working, i decided to go *manual mode*. In short, some partition boot sectors analisys with:
dd if=/dev/hda1 of=./output1.dat bs=512 count=1
Searching the web had no good efects. Some commercial apps to solve it, but i prefer to understand what must be done.
After some reading on Daniel B. Sedory extensive info site (very tech), i managed to understand that the XP boot sector really needs 6 sectors. But the first sector got “damaged” by the GRUB. At a time, i reminded that FAT32 does have backup, so i did a:
dd if=/dev/hda1 of=./boot.dat bs=512 count=6 skip=6
hexdump -C boot.dat > boot.hex*
Now i could see difs between the sectors. So… this meant i could try to fetch the backup sectors and manually place them on the beggining of the partition. Here we go:
dd if=./boot.dat of=/dev/hda1 bs=512 count=6
After this i got the 6 first sectors again and compared them to the ancient ones. Different, so the placement was ok.
Reboot. GRUB boot. XP Recovery FAT32 partition boot. Cool!
* hexdump is awsome. I used it 2 years ago to recover my father’s jpeg Paris photos from a FAT destroyed Sony MMC card. All of them. Signatures, jpeg file signatures. This is a very good personnal data viewer. Give it a try on some file of your own. See this screenshot of the 6 boot sectors.
So remember, XP needs 6 sectors to boot on FAT32. I could not find this on the web but on Daniel website, viewed then on the hexdump. For NTFS the approach should not be difficult problably. So beware, you’r walking on a wire, no net. So, backup. I did a backup of the first, say, 20 sectors of my /dev/hda1 in case things went wrong:
dd if=/dev/hda1 of=./boot_backup.dat bs=512 count=20
All this on unmounted partitions.
So now i have Ubuntu 7.04 Feisty Fawn runnin’ fast, with all its great improvements. And XP that i barelly use, just to maintain some Win32 apps, waiting for MS decision to letting me keep the license, or not. On the other hand, i can buy a Vista OEM version “packed” in all this new material (controversial?). Or not.
pedro said:
after all, the “Code Purple” code is due to an HP script. This script tests some component codes to match a predefined value. If the value doesn’t match, then hardware changes problably occurred. XP reinstall stops in this case. A very friendly Microsoft worker gave me a precious help on this. He refered some manufacturers are allowed to develop scripts to control some aspects of the global instalation. HP does it this way: there is a script in
C:\hp\bin\ConfigCheck\cfgchk.batThe cfgchk.bat file contains the following:
c:\hp\bin\hpdmi r > dmiout.txt
python c:\hp\bin\ConfigCheck\run.py
del dmiout.txt
cd ..
rd /s /q c:\hp\bin\ConfigCheck
I just deleted the run.py file using the Recovery Console. And it worked. The XP installation went on ’till the end. Microsoft was very kind to send me another Key so that i have a valid license again. I want to thank this very friendly and professional Microsoft worker. Not all MS workers resemble Steve Balmer, right ? heh…
Now i can again maintain my (ancient) Borland Delphi Windows apps to make my older clients happy clients. Yes, Delphi is an excellent (altough proprietary) platform to create very robust apps.