4

It always used to be possible to transfer a Windows installation (NT/2000/XP/2003) to a new boot medium by:

  • Recreating the partition table and MBR
  • Copying the partitions using ntfsclone
  • Tricky part: The disk geometry had to remain the same and the partition where ntldr resided had to start at the same LBA sector as before

Is this still possible with Windows (Vista/7/2008)? Would such a procedure work?

  • Copy partition table, with disk signature (!) and MBR
  • Possibly resize partitions to fit the harddrive
  • Ntfsclone "System Reserved Partition" and "Boot Parition".
  • Do one or both still have to start at the same sector on old and new hard disk?

Can you explain how bootmgr and bcd really work under the hood, as opposed to e.g. grub or ntldr? Is there a first and second stage? Does it keep block lists somewhere?

Update: My original problem turned out to be hardware related. Question rephrased to address the broader issue.

1 Answers1

3

bootmgr is not aware of "drive letters", that's something Windows does late in the boot process (and is configured in the registry, absolutely nothing to do with the physical disk configuration).

Using Linux to clone a system is not supported by Microsoft. In short, the official answer is Don't Do That. You should use Windows PE. DISM can create and apply WIM image files, which is Microsoft's preferred format (the same one used by Windows Setup).

Cloning a machine generally follows:

  1. Setup reference machine. Run sysprep.
  2. Boot WinPE. Use dism to capture the drive. Something like this batch file:

    @ECHO OFF
    IF %1 == "" GOTO DIE:
    CHKDSK /X C:
    CHKDSK /X D:
    IF NOT ERRORLEVEL 0 GOTO DIE:
    DISM /Capture-Image /ImageFile:Z:\Path\To\Images\%1.wim /Name:Boot   /CaptureDir:C:\ /Compress:fast
    DISM /Append-Image  /ImageFile:Z:\Path\To\Images\%1.wim /Name:Windows /CaptureDir:D:\
    :DIE
    

    This may need to be modified if you have a non-standard partition layout.

  3. Boot the destination computer to WinPE. Use diskpart and dism to apply the image:

    Standard diskpart script to configure partitions:

    SEL DISK 0
    CLEAN
    CREATE PART PRI SIZE=350
    ACT
    FORMAT QUICK
    ASSIGN LETTER=M
    CREATE PART PRI
    FORMAT QUICK
    ASSIGN LETTER=O
    EXIT
    

    Standard dism batch file to write image:

    @ECHO OFF
    IF %1 == "" GOTO DIE:
    DISKPART /s Diskpart-Standard.script
    IF NOT ERRORLEVEL 0 GOTO DIE:
    DISM /Apply-Image /ImageFile:%1 /Index:1 /ApplyDir:M:\
    DISM /Apply-Image /ImageFile:%1 /Index:2 /ApplyDir:O:\
    IF NOT ERRORLEVEL 0 GOTO DIE:
    BCDEDIT -STORE M:\BOOT\BCD -set {bootmgr} device partition=M:
    BCDEDIT -STORE M:\BOOT\BCD -set {memdiag} device partition=M:
    BCDEDIT -STORE M:\BOOT\BCD -set {default} device partition=O:
    BCDEDIT -STORE M:\BOOT\BCD -set {default} osdevice partition=O:
    :DIE
    ECHO Script ended...
    

Your process might work, but you likely are missing those last four bcdedit lines from the script.

Note this does not configure WinRE, but you shouldn't need it if you have WinPE around anyway.

Chris S
  • 6,124