The hard drive on my laptop is slowly failing and a combination of being busy, lazy, and cheap is preventing me from replacing it. About once every two weeks over the past couple months, one of the Windows registry files becomes corrupted and the XP disk is unable to repair it. And the HD fails basic manufacturer-provided diagnostics. But I’m stubborn. So I’ve been routinely resuscitating this box and I decided to post the process I use.

If you boot and see a message like

Windows could not start because the following file is missing or corrupt C:\windows\system32\config\system

then you may be interested in this. I should note that there are more Windows-y ways to fix this. But I have an Ubuntu Edgy disc on hand, and so these instructions are for using Ubuntu Edgy as a band-aid an adhesive bandage for a dying hard drive or a screwy Windows installation. The ntfs-3g and ntfs-config packages are necessary to mount your local hard drive in read-write mode, otherwise these instructions would be much shorter.

I’m assuming you have a good backup from which to restore the missing or corrupt files that are preventing you from booting Windows off your hard drive. My backups are available via a networked Samba mount. If yours are on a secondary internal hard drive, an external hard drive, a CD or floppy or thumb drive, some of these steps won’t apply to you.

  1. Get a copy of Ubuntu and burn it to a bootable medium. I'm using a Ubuntu 6.10 (Edgy) on a CD-R.
  2. Insert your bootable medium into the crappy computer. Boot said crappy computer from the medium. You may need to fiddle with your BIOS to get it to boot from removable media, but hopefully not.
  3. At the Ubuntu boot menu, chose "Start or Install Ubuntu." Don't worry: it won't write over your hard drive or touch any of your data.
  4. When the operating system is done loading, click on the Applications menu, and choose Accessories, then Terminal.
  5. Since my backups are available on a Samba mount, and the Edgy CD does not have Samba installed, I first must install the Samba FS and its dependencies: sudo apt-get install smbfs
  6. Create a directory for mounting the Samba share: sudo mkdir /mnt/remote
  7. Mount the share, substituting appropriate values for the IP address and the share name: sudo smbmount // /mnt/remote
  8. If not running Edgy, see this guide to mounting local Windows drives in read-write mode. Otherwise, first open the aptitude sources list: sudo nano -wc /etc/apt/sources.list and add the following three lines at the bottom of the file:
    deb edgy main main-all deb edgy main main-all deb edgy main main-all
    Save and close the file.
  9. Let aptitude update its list of sources: sudo apt-get update
  10. Install necessary packages: sudo apt-get install ntfs-3g ntfs-config libfuse2
  11. Launch the ntfs-config utility: sudo ntfs-config Call the mount point "windows", which will live at /media/windows. Click the Add checkbox next to the device corresponding to your local drive (/dev/hda1 for me). Click Apply. Make sure the checkbox next to "Enable write support for internal drive" is clicked on the next dialog, and click Ok.
  12. Copy over backed up versions of missing or corrupt files: sudo cp /mnt/remote/repair/system* /media/windows/WINDOWS/system32/config/ is an example I've used a couple times.
  13. Shutdown, remove the Ubuntu CD when prompted, and boot off your hard drive. Cross fingers. And you should be back in action.