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
./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.
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:)
bootsect /nt60 d: /mbr - to set sda1 partition boot code (does not harm to write Windows boot code to MBR)
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 wrote up some steps I took to resolve this issue and it worked for me, so I am hoping it will help future readers as well, and maybe even the OP even though it's been awhile.
Procedure I used to migrate Windows 7 from one partition on a smaller, slower hard drive to a faster hard drive partition in a Dell OptiPlex 780 MT
startx
to get into the GUI
testdisk
and create/reset the boot sector of the new Windows 7 partition (Don't know if this step is necessary, but it's just what I did)
mkdir
mount
command
mount /dev/hdb1 /mnt/Dell
mount /dev/hda4 /mnt/Win7
mkdir
cp
commandcp /mnt/Dell/boot.sdi /mnt/Win7/
cp /mnt/Dell/Boot/BCD /mnt/Win7/Boot/
G:
cd Boot
bcedit /store BCD
bcdedit /store /copy {d57db94d-450e-11e5-a383-b8ac6f1ac098} /d "Win7 Debug"
bcdedit /store BCD /enum /v
(To view the GUIDs for reference)bcdedit /store BCD /set {bootmgr} device partition=G:
bcdedit /store BCD /set {c15e345e-9c47-11ea-a7d8-b8ac6f1ac098} device partition=G:
bcdedit /store BCD /set {c15e345e-9c47-11ea-a7d8-b8ac6f1ac098} osdevice partition=G:
bcdedit /store BCD /displayorder {c15e345e-9c47-11ea-a7d8-b8ac6f1ac098} {d57db94d-450e-11e5-a383-b8ac6f1ac098}
bcdedit /default {c15e345e-9c47-11ea-a7d8-b8ac6f1ac098}
If you made no mistakes and had no difficulties or errors with any of the steps, then you like me have successfully migrated both the Windows 7 partition and the Windows 7 boot manager from one partition on the original hard drive to a new partition on a different hard drive, without using a Windows 7 recovery disk (which OEM resellers do not issue with a PC), and without using questionable third-party apps. A pleasant surprise is that if you had any EFS-encrypted files or folders before the migration, then they will still be accessible on the new partition without having to decrypt first. DiskMgmt.MSC now shows the new Windows 7 partition as C:, and the old Windows 7 partition without a drive letter.
Once booted to the new Windows 7 partition completely independent of the original hard drive, then you can explore how to clean up the boot loader on that partition to point everything to it instead of to the old Windows 7 partition. If you have a Windows XP partition on the new drive like I do, then you can add an entry to boot that using bcdedit as well. After you are confident that things are stable, then you can wipe the old partition and use it for other purposes. I truly hope this helps someone else to accomplish similar endeavors.
W7 Disk Mgmt After Migration:
User contributions licensed under CC BY-SA 3.0