Moving a Windows 2000 installation to a larger disk
I had a bit of a computer adventure this week. I ran a program called “Eraser” – no link because it might be malware – which is supposed to wipe the unused space on your disk. (As a former IT pro, these sorts of programs always interest me.)
Now, there may or may not be a connection with that program, but the next time I turned my computer on, it didn’t find the hard drive. Not at all.
I booted from a Knoppix 4.0 CD that I keep on hand for this sort of situation, and it mounted my hard drive just fine. I checked a couple of files, and everything looked good. Strange.
I booted from a Windows 2000 CD and went into the recovery console. I tried the usual fixes – fixmbr, fixboot, chkdsk. There was no effect.
I searched the web for similar problems and found all sorts of potential causes – a bad disk, a bad disk controller, bad memory, BIOS corruption… ugh. It’s really a pain to troubleshoot these sorts of problems, especially when it’s a personal system and you don’t have spares on hand.
I reset the BIOS to its default settings, pulled and tested the CMOS battery, and ran a memory test (memtest86, on the Knoppix disk). No problems found, and no change.
Finally, just trying things at random, I changed the hard disk type in the BIOS from “AUTO” to “LBA”. And it worked! Go figure – AUTO had worked for the last two or three years.
By this time I’d already ordered a new 250GB SATA disk from NewEgg. Even though the computer was working again, the old disk was 120GB and nearly full, so I went ahead with the upgrade. Here are the steps that worked for me:
- Back up the old disk. You never know when something will go wrong.
- Turn off the computer.
- Connect both the old and the new disk.
- Boot into the Knoppix CD. At the boot prompt, enter “knoppix dma” to enable DMA for faster copying.
- On the desktop, I see /dev/hda and /dev/sda. Those must be my two disks.
- From a shell prompt, I run “fdisk -s /dev/hda” and “fdisk -s /dev/sda”. The former tells me that /dev/hda is 120GB (my old disk) and /dev/sda is 250GB (my new disk).
- I run “fdisk -u /dev/hda” and use “p” to display the information about this disk. The “-u” is to use sectors, instead of cylinders, in case the two disks have different geometries. Write down the start and end sectors. Note the partition type (NTFS in my case.) DON’T MAKE ANY CHANGES TO THIS DISK!
- Run “fdisk -u /dev/sda” and create a partition with the exact same start and end sectors as on /dev/hda. Change the type of this partition to NTFS. Toggle the bootable flag to make this partition bootable. Save these changes.
- Copy the boot code from the old disk to the new disk, with “dd if=/dev/hda of=/dev/sda bs=446 count=1”. (Recall that in my case, /dev/hda is the old disk, and /dev/sda is the new disk. You may have to change these. If you’re not familiar with disk devices under unix, you should probably use a commercial program like Drive Image or Norton Ghost.)
- Copy the data from the old disk to the new disk, with “dd if=/dev/hda1 of=/dev/sda1”. This may take a few hours, depending on the size of the disks and the speed of the computer.
- At this point the new disk should be bootable, but the partition will be the same size as the old disk. You could make a second partition on the new disk and use that space as a separate drive letter, but I wanted to use the entire disk as my C: drive. There are two ways to do this.
- The graphical way: Run “qtparted”. Select the first partition on the new disk, /dev/sda1 in my case. Right-click and select “resize”, and change “space after” to zero. Use File->Commit from the pull-down menu to save the changes.
- The command-line way: Run “fdisk -u /dev/sda” and delete the partition, then re-create the partition with the SAME STARTING SECTOR but with the ending sector set so the partition is the maximum size possible. Then run “ntfsresize /dev/sda1” to finish the job.
In my case, I hit another snag. The new disk worked fine, but every so often Windows would give me the error: “The file or directory C: is corrupt and unreadable. Please run the chkdsk utility.” After that, the computer would refuse to boot. I booted into Knoppix, and the files looked fine. I booted from the Windows 2000 CD, and when I tried to run the command “DIR” from the recovery console, it gave me the error: “An error occurred during directory enumeration.” Huh?
It turns out that I had hit yet another size boundary. Apparently, not very long ago, the PC industry didn’t forsee disks reaching beyond 137GB. And although my computer seemed to be working fine, when I filled the disk with more than 137GB of data, it corrupted the disk.
To get past the 137GB boundary, you need:
- A computer whose BIOS supports 48-bit LBA (logical block addressing). I couldn’t find definitive information about mine, an ECS 865G-M 5.0 with BIOS dated 2004, but it turns out that it does.
- A disk that supports 48-bit LBA – if the disk is larger than 137GB this should be a given.
- An operating system that supports 48-bit LBA. This was the key.
By default, Windows 2000 does not support 48-bit LBA. But if you have service packs 3 or 4 installed, you can enable 48-bit LBA with a registry key. See the article 48-Bit LBA Support for ATAPI Disk Drives in Windows 2000 for details. Why this is not enabled by default is completely beyond me.
I ended up removing the new disk, installing the old disk, booting into Windows, making that registry change, and then repeating the above steps to move from the old disk to the new disk. This time, when I booted from the new disk, I was able to fill the disk beyond the 137GB boundary. What fun…
I hope that by posting this I can save someone else some of that trouble.
Since this adventure I’ve upgraded to the DVD version of Knoppix 5.0 and have been really impressed by it. I highly recommend you keep the CD and DVD versions in your IT toolbox.