I spent a big part of yesterday manually moving a Vista NTFS partition. It was frustrating but I learnt something.
The obvious part is moving the data. The new and old positions didn't overlap, so I could just create a new partition and copy the data. I booted a Ubuntu CD in single user mode, created a partition with fdisk and copied the data with dd, specifying a large block size to speed up the copy. I made the new partition active (boot flag), the old partition un-active and I hid the old partition by changing its type to 0x17. This results in a readable but unbootable partition.
The first issue boot issue is the Vista boot configuration data store (which may be edited with bcdedit in Vista). Booting off a Vista DVD and running the automated startup repair can fix this; Vista will add the partition as a "(recovered)" entry to the boot menu. However, Partition Saving seems like a better choice because it will allow you to alter all the entries. After this is fixed, Vista would appear to boot ok but after logging in practically nothing would work because the moved partition is mounted as something other than C:.
Vista's automated startup repair doesn't seem to be able to fix the drive letter issue, but it may be fixed manually by running regedit, loading the system hive and editing entries in MountedDevices. Partition Saving can quickly and easily fix the problem, and so I recommend it for both of these problems. After this, everything may seem to work, but that's deceptive because the boot is still using parts of the old partition. If the partitions get out of sync, mysterious boot problems can occur. If you're lucky, you'd get "A disk read error occurred" followed by "Press Ctrl+Alt+Del to restart", but the boot could simply hang with no error message.
In order to fix the boot sector problem, I looked at information about the XP boot sector and considered trying to understand where it might be failing or even trace through the code. After I learnt that the boot sector loads additional sectors following it and noted that some error messages aren't used by the boot sector itself I realized that the code it loads might be failing and just using the error messages in the boot sector. I found a blog post about avoiding "disk read error occurred" after resizing. That was not it; the geometry was correct. However, it drew my attention to "Number of Hidden Sectors" at offset 0x1C in the boot sector. This had to be the sector number that the boot sector is at. It was still pointing to the old partition. After fixing that with a disk editor, everything seemed fine.
There was one remaining issue I remembered: there was a backup boot sector. I ran TestDisk and it found that the boot sector differed from its backup now. I then told it to copy it to the backup. (TestDisk is great utility for undeleting partitions. The boot sector backup saved me once when an attempt to install MS-DOS 6.22 started reformatting the HD and overwrote the boot sector.)
While doing all this I also learnt about Bootrec on the Vista DVD and bootsect.exe. While both of these Microsoft utilites can rewrite the boot sector, they don't seem to fix the sector number at offset 0x1C. Chkdsk is also useless here; it won't notice that anything is wrong. All this makes me very disappointed about Microsoft's automated repair tools. They did do one thing right however: the Vista recovery environment is like a LiveDVD which allows you to use some standard Vista tools like regedit.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment