0

I have recovered Windows7 from rescue DVD, that came together with my laptop. The recovery re-partitions the SSD drive as to factory defaults, but I would like to change that. More exactly, after recovery was completed the partitions are the following:

root@ubuntu:~# fdisk -l /dev/sda

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048   419432447   209715200   27  Hidden NTFS WinRE
/dev/sda2   *   419432448   419637247      102400    7  HPFS/NTFS/exFAT
/dev/sda3       419637248   839067647   209715200    7  HPFS/NTFS/exFAT

Comments:

  • /dev/sda2 is small partition that has bootmgr and Boot.
  • Windows7 is installed on /dev/sda3, which does not have bootmgr on that partition.

Now I would like to copy Windows7 from /dev/sda3 to /dev/sda1 and make it bootable. As partitions have the same size, this is very simple in Linux:

root@ubuntu:~# dd if=/dev/sda3 of=/dev/sda1 bs=4096

After that I have changed the partition type:

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048   419432447   209715200    7  HPFS/NTFS/exFAT
/dev/sda2   *   419432448   419637247      102400    7  HPFS/NTFS/exFAT
/dev/sda3       419637248   839067647   209715200    7  HPFS/NTFS/exFAT

Then I have rebooted. Windows7 boots from /dev/sda3 (which becomes C:) and /dev/sda1 becomes D:. Now I make Windows7 copy bootable (see Switching my Windows 7 Boot Disk from D to C with BCDBoot and Is it possible to copy all Windows 7 files from one HD to another?):

C:\> bcdboot d:\windows /s d:
Boot files successfully created.

C:\> bootsect /nt60 d: /mbr
Target volumes will be updated with BOOTMGR compatible bootcode.
F: (\\?\Volume{b6e65e71-6179-11e5-82c7-806e6f6e6963})
Successfully updated NTFS filesystem bootcode.
\??\PhysicalDrive0
Successfully updated disk bootcode.
Bootcode was successfully updated on all targeted volumes.

Doublecheck:

C:\> bcdedit

Windows Boot Manager
--------------------
identifier              {bootmgr}
device                  partition=\Device\HarddiskVolume2
description             Windows Boot Manager
locale                  en-US
inherit                 {globalsettings}
default                 {current}
resumeobject            {0b9ac05e-6182-11e5-b742-8dbb81fd6d74}
displayorder            {current}
toolsdisplayorder       {memdiag}
timeout                 30

Windows Boot Loader
-------------------
identifier              {current}
device                  partition=C:
path                    \Windows\system32\winload.exe
description             Windows 7
locale                  en-US
inherit                 {bootloadersettings}
recoverysequence        {0b9ac060-6182-11e5-b742-8dbb81fd6d74}
recoveryenabled         Yes
osdevice                partition=C:
systemroot              \Windows
resumeobject            {0b9ac05e-6182-11e5-b742-8dbb81fd6d74}
nx                      OptIn

C:\> bcdedit /store D:\Boot\BCD

Windows Boot Manager
--------------------
identifier              {bootmgr}
device                  partition=D:
description             Windows Boot Manager
locale                  en-us
inherit                 {globalsettings}
default                 {default}
resumeobject            {f38db522-680d-11e5-829a-18f46ae2d7b0}
displayorder            {default}
toolsdisplayorder       {memdiag}
timeout                 30

Windows Boot Loader
-------------------
identifier              {default}
device                  partition=D:
path                    \windows\system32\winload.exe
description             Windows 7
locale                  en-us
inherit                 {bootloadersettings}
osdevice                partition=D:
systemroot              \windows
resumeobject            {f38db522-680d-11e5-829a-18f46ae2d7b0}
nx                      OptIn
detecthal               Yes

After I have booted Linux and marked the partition bootable (one can do that on Windows, but I use the tools I am familiar with):

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   419432447   209715200    7  HPFS/NTFS/exFAT
/dev/sda2       419432448   419637247      102400    7  HPFS/NTFS/exFAT
/dev/sda3       419637248   839067647   209715200   27  Hidden NTFS WinRE

The contents of /dev/sda1 is the following (doublecheck):

root@ubuntu:~# ls -l /mnt/sda1
total 10749077
drwxrwxrwx 1 root root       4096 Sep 25 06:11 Boot
-rwxrwxrwx 1 root root     383786 Nov 20  2010 bootmgr
drwxrwxrwx 1 root root          0 Sep 23 21:50 Config.Msi
lrwxrwxrwx 2 root root         60 Jul 14  2009 Documents and Settings -> /mnt/sda1/Users
-rwxrwxrwx 1 root root 4717092864 Sep 23 21:50 hiberfil.sys
-rwxrwxrwx 1 root root 6289461248 Sep 23 21:50 pagefile.sys
drwxrwxrwx 1 root root          0 Jul 14  2009 PerfLogs
drwxrwxrwx 1 root root       4096 Sep 23 20:35 ProgramData
drwxrwxrwx 1 root root       8192 Sep 23 21:26 Program Files
drwxrwxrwx 1 root root      12288 Sep 23 21:12 Program Files (x86)
drwxrwxrwx 1 root root       4096 Sep 22 22:00 $Recycle.Bin
drwxrwxrwx 1 root root      20480 Sep 23 21:50 System Volume Information
drwxrwxrwx 1 root root       4096 Sep 23 21:05 Temp
drwxrwxrwx 1 root root          0 Sep 23 21:50 Update
drwxrwxrwx 1 root root       4096 Sep 22 21:58 Users
-rwxrwxrwx 1 root root       4112 Jul 19  2011 version
drwxrwxrwx 1 root root      24576 Sep 23 21:02 Windows

Looks good. Unfortunately when I boot I get Bootmgr is missing. Press Ctrl+Alt+Del to restart.

I have installed Grub to /dev/sda1 (overwrites default boot loader):

grub-install --force --no-floppy --boot-directory=/mnt/sda1/Boot /dev/sda1

with the following /mnt/sda1/Boot/grub/grub.cfg:

menuentry "Windows 7" {
    insmod ntfs
    insmod ntldr
    ntldr (hd0,msdos1)/bootmgr
}

Grub passed the control to bootmgr correctly, but it persistently boots from /dev/sda3. When I remove the partition /dev/sda3, the initial boot screen is shown but then nothing happens (booting just hangs).

Next I have installed ntldr to /dev/sda1 (copied NTDETECT.COM, NTLDR from 64ntfile.zip) with "native" boot sector:

C:\> bootsect /nt52 d:

and this boot.ini:

[Boot Loader]
timeout=30
Default=multi(0)disk(0)rdisk(0)partition(1)\Windows

[Operating Systems]
multi(0)disk(0)rdisk(0)partition(1)\Windows="Windows 7 (boot.ini)" /fastdetect

After boot it displays "A disk read error occurred". For sure SSD drive is unlikely to fail like that, so I think that the problem is in boot bytecode / logic that cannot correctly handle addressing / layout of the drive. I have installed Grub (as above) with this config:

menuentry "Windows 7" {
    insmod ntfs
    insmod ntldr
    ntldr (hd0,msdos1)/ntldr
}

and then I could see my menu as to boot.ini above. When I continue, the computer reboots without any error message (so I got in the loop).

How to fix the problem? Any solution to boot Windows from 1st partition is welcomed.

Other posts on the subject that I have inspected:

P.S.: No other drives or USB sticks are connected to notebook when testing.

  • When you are using linux / Windows dual boot i would recomend using grub boot manager. – Ivan Viktorovic Sep 29 '15 at 10:04
  • I am not using Windows/Linux dual boot. I have only Windows. – dma_k Oct 2 '15 at 8:49
  • You're doing it wrong. Start again. This time delete the second partition after you've copied it and do not boot back into Windows. Update your boot entries from a WinRE disk or recovery. – qasdfdsaq Oct 9 '15 at 12:06
  • That's the point – I don't have recovery disk. What you say means that I cannot recover without bootrec /rebuildbcd or so. Finally after days of trying I gave up and let Windows leave on 3rd partition (/dev/sda3 in my example), however I was able to copy bcdboot from hidden partition to that one. The space in the beginning of drive I have allocated for drive D:. If you can explain why I couldn't boot from first partition (/dev/sda1) I will appreciate. Nevertheless as a last resort I have used the restore function. It has created the hidden partition again, however boot has failed. – dma_k Oct 17 '15 at 21:25
0

After you have copied sda3 to sda1 there are still some "pointers" in registry of Windows on sda1 which point to sda3. Check contents of HKLM\SYSTEM\MountedDevices\DosDevices\C: and D: if they point to correct partition. (\DosDevices\C: value is partition signature - should be signature for sda1)

To create boot files for sda1: (when booted to sda3 mapped to c:, sda1 mapped to d:)

  1. bootsect /nt60 d: /mbr - to set sda1 partition boot code (does not harm to write Windows boot code to MBR)

  2. bcdboot d:\windows /s d: - to create BCD on sda1

You don't have to edit existing System BCD on sda2 and BCD on sda1!!!

At last change active partition to sda1.

Reboot.

See How to move Windows 7 boot files to another drive/partition for help.

  • I did bcdboot d:\windows /s d: and bootsect /nt60 d: /mbr as you suggested (also I have updated the question with some extra information, namely with bcdedit output). I still get Bootmgr is missing. I think that is produced by code in boot sector – it cannot access Windows registry. Any further advice is welcomed. – dma_k Oct 2 '15 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.