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 hasbootmgr
andBoot
.- Windows7 is installed on
/dev/sda3
, which does not havebootmgr
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:
- What utility can move my Windows boot partition over to another hard drive?
- Build a Bootable BCD from Scratch with Bcdedit
- Should device and osdevice parameters be the boot or windows partition?
- Fixing Windows7 Bootmgr
- Can I fix error 0xc0000225 without reinstalling Windows?
P.S.: No other drives or USB sticks are connected to notebook when testing.
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 copybcdboot
from hidden partition to that one. The space in the beginning of drive I have allocated for driveD:
. 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.