Saturday 3 January 2004

Don't store data you need later in a place you're about to destroy

I made - or rather, encountered - a bit of a howler at work yesterday.

I was trying to resize the clusters on my hard disk with PartitionMagic 8.0. The system is not exactly the fastest in the world (an 850MHz Duron, which only has 64KB of cache, and a hard disk I can only describe as glacial) - if you try right-clicking the task bar when you've not done this for a while, it can take over ten seconds to bring up the pop-up menu. Windows 2000 installs with a default cluster size of 512 bytes on an NTFS partition (for a reason I'll describe shortly), which requires 8 separate reads to fill a single memory page (4KB on x86 systems). I'm not sure if the disk driver subsystem can actually do a multiblock transfer for this or not.

Anyway, PM indicated it would need to reboot to resize the clusters on the system partition. Where did it place the temporary file of commands? In C:\WINNT\TEMP. That's right, on the partition to be converted, along with the program itself.

So the conversion proceeded perfectly, right up to 100% - at which point, it generated a number of errors (which I should have written down), and said 'Press any key to reboot'. OK, reboot - nothing.

Great.

So I boot up with the PM Rescue disks I've created, check partition for errors: brings up a number of errors, none of which it can fix (starting with 'MFT Mirror in wrong place' or some such). OK, let's try CHKDSK: put Windows 2000 CD in drive, reset BIOS settings to boot from CD, go to Recovery Console. Run CHKDSK /P because the disk is marked clean.

To cut a long story short [too late - Ed] CHKDSK took all afternoon and got stuck on 50%. After leaving it for about an hour, I rebooted and tried PM Rescue again. More errors, this time fatal. I examined the drive information, and discovered that the cluster size was still set to 512 bytes in the filesystem metadata. I assume that PM had managed to do all the conversion, apart from the critical step of updating the cluster size. Thanks a bunch, guys. This probably means that CHKDSK in fact corrupted the whole disk, rather than fixing the problem. I figure that PM failed because it either couldn't find the batch script or that it couldn't find the programs any more (duh! you just rewrote all the metadata for the disk!).

Of course, I didn't take a backup, but I'd concluded that a) there wasn't anywhere I could write 20GB of stuff and b) most of it was programs - 3 editions of Visual Studio takes up a whole load of space. Everything that was actually work-related was already backed up to the network.

So I guess I'll see if I can persuade my boss to let me have Windows XP now.

Oh yes: why does Windows 2000 install to a 512 byte cluster size? If you create a new partition for installing and select Format using NTFS, it doesn't. It actually formats the disk as FAT, installs on that, then converts the disk and applies security settings. The FAT-to-NTFS converter ignores the cluster size configured for the FAT partition; it always uses the disk's sector size, normally 512 bytes. All versions of NT up to Windows XP did this, which is why you can't create a system partition greater than 2GB in Windows NT 4.0 setup - FAT16 didn't support it.

Windows XP and Server 2003 do it properly - they actually do format as NTFS to start with. I assume that the reason for the FAT installation was that the NTFS version of format couldn't be fitted onto the NT 4.0 boot disks, and it didn't get changed for Windows 2000 for whatever reason.

No comments: