Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I move a bootable NTFS partition with Windows on it to a different block offset, what needs updating to make it bootable again?

Background: I plan to write a program that performs the necessary actions, that's why I am not seeking for guides how to use Microsoft's tools by booting from a Windows DVD. Instead, I need how to modify these things myself, so that I can write a solution that's easier for the average PC user when he wants to move his Windows system to a bigger hard disk.

In particular, here's what I tried:

I have a disk with several partitions, one of which is the NTFS partition with Windows on it, and the disk uses the plain old MBR block 0 for the partitions layout (no more than 4 partitions).

Now I format and partition a new, larger, disk. There I make room for the NTFS partition and copy the contents from the old disk's NTFS Windows partition into. And I make the partition "active".

However, when I try to boot from this disk, I get a "read error" message immediately and the booting stops, the exact text is:

  A disk read error occurred
  Press Ctrl+Alt+Del to restart

I verified that both disks have the same boot sector code in block 0.

It seems to me that something else might need updating. I guess that somewhere there's a absolute block reference that I need to update, probably pointing to the next level loader or to the NT kernel.

Update: I found this article going quite into the depth of what I want to know. However, it says to modify boot.ini, but I have Windows 7 installed here, where such things appear to have changed: No boot.ini but a folder called System Volume Information with GUID and other data in it that sounds related to my problem. Going to keep digging...

Update 2: Thanks to the terrible looking but very informative website by starman, I was able to figure out the first step: The NTFS boot sector has a field for "hidden" sectors. This feld has to contain the sector number of the boot sector. This solves the "read error" message. Now, however, I get a "BOOTMGR is missing" error instead. Looks like there's another place where a block number has to be adjusted, but I can't find anything in the code listing about this.

I do find a lot of help sites suggesting Windows tools for fixing this "BOOTMGR is missing" problem, but none seem to know what goes on behind the scenes. Kind of like suggesting to re-install Windows when there's a little problem with it. At least, those fixes seem to work, mostly involving the Bcdedit and Bootrec tools. Now, who knows what they do, especially the latter, in regards to a moved partition?

Update 3: After lots of trial-and-error attempts, I believe now that the solution lies in the BCD-Template registry file, residing usually inside \Windows\System32\config. If I get this updated using the "bcdboot" command, Windows starts up from it. I am now in the middle of figuring out what information this registry contains relevant to the above question. Any pointers to the contents of this registry are welcome.

Update 4: Turns out that while the BCD-Template file gets rewritten and has different binary contents than its predecessor, the values inside do not change. So it must be something else that bcdboot.exe writes. I had previously already checked if it changes the first 32 boot blocks of the partition, but they appear to remain unchanged. Parititon map doesn't get changed, either. So what is it that bcdboot modifies besides the BCD registry? Any tips on how I can trace that? Are there low level tools that show me what files a program writes to?

Update 5: The answer seems to be: c:\Boot\BCD is also changed, and that appears to be the key file for the boot manager's process. I'll investigate this later...

Update 6: It seems to be an important detail that I had originally two partitions created when I installed Windows 7: A small partition of 204800 sectors which appears to be a bootstrap partition, followed by the actual, large, partition containing the Windows system (drive C:). When I tried to transfer this installation to a new, larger, disk, I had kept the same two partitions intact on the new drive, although they ended up at a different offset. This alone led to the "BOOTMGR is missing" message. Since then, I've used bcdboot.exe only on the Windows partition, which added the \Boot\BCD file on that partition. That file (and folder) did originally only exist on the smaller partition. Hence, this problem may be more complicated in my case as one partition (the boot strapper) referred to another partition (the one containing the OS), whereas other people may only have to deal with one partition containing both, and maybe there the solution is simpler.

Update 7: Found one more detail: The \Boot\BCD file records the MBR's serial number. If that number doesn't match, the system won't boot. Next I'll test if there's also an absolute block reference stored in there.

share|improve this question

migrated from Jan 6 '11 at 15:10

This question came from our site for professional and enthusiast programmers.

Just wondering, did you make sure the hidden system partition was moved correctly? – Colum Dec 27 '10 at 23:31
Which hidden partition do you mean? I just added update #6 which talks about the extra boot partition, and yes, I did move that, too. There was also another "hidden" area between the MBR and the start of the Windows partition(s), but that should not be of any relevance - that's just a blob of data (in my case: A HFS+ partition as I'm moving a Boot Camp installation here). The only things involved should be: The partition map (MBR plus GUID schemed partition map thereafter) and the two involved Windows partitions (the small booter and the C: partition). I updated all properly, of course. :) – SuperTempel Dec 28 '10 at 0:17
Most certainly the important stuff is stored in \BCD\Boot, and you'd normally edit that with bcdedit.exe, not bcdboot. And yes, the separate partition for boot-strapping (which is required only when you use the full-disk encryption feature, since the decryption code then has to be stored outside the main windows partition) controls the boot process, if it exists. – Ben Voigt Dec 28 '10 at 5:51
@Ben: yes, I know about bcdedit - but I do not want to edit anything, as far as I can tell as I do not want to change any of its options as they were in place before I moved the partitions to a new disk. All I want to update are any fixed block number and disk ID references, without the use of any Windows executables, if possible. – SuperTempel Dec 28 '10 at 9:22
Not a programming question. This is domain knowledge about the Windows bootloader. – Andrew Medico Dec 29 '10 at 14:30

The easier way?

Put the Windows Vista or Windows 7 installation disc in the disc drive, and then start the computer.
Press a key when you are prompted.
Select a language, a time, a currency, a keyboard or an input method, and then click Next.
Click Repair your computer.
Click the operating system that you want to repair, and then click Next.
In the System Recovery Options dialog box, click Command Prompt.
Type Bootrec.exe, and then press ENTER.

Bootrec.exe options
The Bootrec.exe tool supports the following options. Use the option that is appropriate for your situation.

Note If rebuilding the BCD does not resolve the startup issue, you can export and delete the BCD, and then run this option again. By doing this, you make sure that the BCD is completely rebuilt.

To do this, type the following commands at the Windows RE command prompt:
bcdedit /export C:\BCD_Backup
cd boot
attrib bcd -s -h -r
ren c:\boot\bcd bcd.old
bootrec /RebuildBcd

or /FixMbr or /FixBoot or /ScanOs or /RebuildBcd depending on the situation.

See: for more details.

share|improve this answer
Thanks for attempting to help, but what you say is standard knowledge, as you point out. I specifically need the "what's going on" information to accomplish this in my own written program, not by using Microsoft's software, which is still hard to handle for a trivial user. I want to be able to provide a solution to a Mac user with a Boot Camp installation, in case he needs to move this to another disk. And as a side effect of that, it'd help any other Windows user, too, as the tasks would be the same. – SuperTempel Jan 22 '11 at 12:44
If I were trying to do that... I'd dd the disk before and after and do a binary compare between the two. Good luck. – Essobi Jan 25 '11 at 1:55
I'm ahead of you, again. See, I'm the author of iBored, so I know how to do things like that, and believe me, I've tried. The new format is too cryptic for me, though, and that's why I'm asking this question here. – SuperTempel Dec 8 '11 at 15:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .