# Linux recovers XP boot sector(s)

## March 16, 2007 by pedro mota

\n\nWell, a post about Windows… who’d say about that…\nThe 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.\n\nTurn 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.\n\nXP: 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.\n\nBut before all this, i made a mistake… When reinstalling GRUB i did a:\n\nsudo grub-install --root-directory=./ /dev/hda1\n\nThe 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:\n\ndd if=/dev/hda1 of=./output1.dat bs=512 count=1\n\nSearching the web had no good efects. Some commercial apps to solve it, but i prefer to understand what must be done.\nAfter some reading on Daniel B. Sedory (now on the internet archive) 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:\n\ndd if=/dev/hda1 of=./boot.dat bs=512 count=6 skip=6\nhexdump -C boot.dat > boot.hex\n\nNow 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:\ndd if=./boot.dat of=/dev/hda1 bs=512 count=6\n\nAfter this i got the 6 first sectors again and compared them to the ancient ones. Different, so the placement was ok.\n\nReboot. GRUB boot. XP Recovery FAT32 partition boot. Cool!\n\n 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.\n\nSo 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:\n\ndd if=/dev/hda1 of=./boot_backup.dat bs=512 count=20\n\nAll this on unmounted partitions.\n\nSo 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.\n

blogged with VIM

\n