This is a set of scripts and configurations to succesfully install and boot Windows 7 and 10 from GPT-partitioned drive on a system with BIOS. This may be convenient if you benefit from GPT features such as partition labeling, unique GUIDs and raised partition count/size limits.
Windows does not permit this by default, the solution is to create a small MBR-partitioned virtual drive and place boot-related files to it, so that Windows will treat this virtual drive as real boot drive and perform all the boot configuration there. The drive then gets attached automatically at every boot so all boot-related configuration tasks which are run after installation (BCD specialization step, updates etc.) complete succesfully.
Setup can be accomplished in the following way:
(parted) mklabel gpt
(parted) mkpart primary 0% 10MB
(parted) mkpart primary ext4 10MB 210MB
(parted) mkpart primary ntfs 210MB 100%
(parted) set 1 bios_grub on
This will create small 10MB primary partition at the very beginning with flag necessary to install GRUB into GPT drive, and also 200MB ext4 partition where GRUB root directory will reside.
Also here we create third NTFS partition for Windows which spans to the end of the drive (change this for your needs).
Format and mount your GRUB root partition.
Install GRUB to your hard drive using grub-install
and partition formatted
in the previous step as boot directory.
Install grub.cfg
and MEMDISK from SysLinux into boot directory.
You need Windows PE bootable image with ImageX installed into it (does not come by default) and Windows setup DVD. Boot your computer to Windows PE to get access to PE command prompt.
Format third partition of your hard drive, for example using DiskPart (assuming disk #0 is your hard drive):
DISKPART> select disk 0
DISKPART> select partition 3
DISKPART> format label="Windows 7" quick
DISKPART> assign letter=c
X:\> imagex /apply D:\sources\install.wim 1 c:
Copy boot/
directory from this repository to C:\boot (for example
using Samba share).
Execute C:\boot\create.cmd
. This will create VHD drive
and place all necessary boot files in it.
The next step is crucial for the whole setup. You should reboot your
machine into new Windows installation and mount the boot VHD drive manually
before Windows starts to specialize BCD which is located on the VHD.
To do this, wait until "Windows is installing devices" message appears and
then press Shift+F10
to get command prompt window. Then type this:
> C:\boot\mount.cmd
This may take some time as the script waits until the drive actually appears
as a volume, and keeps trying to assign it for 10 minutes. You can check
if everything went right by reading C:\boot\mount.log
after installation
(and after every boot).
If you get this message: "Windows Setup could not configure Windows to run on this computer's hardware", then probably you did this too late and you need to repeat the procedure from step 5.
This has to be done only once during setup. Later we will configure a service to mount boot volume automatically at startup.
If setup process continues without errors then all went OK and now we need
to configure the system to mount VHD drive at startup in order to allow it
correctly handle BCD during updates. You may do this by installing Windows
Resource Kit Tools (reg files in this repository assume that Windows Server
2003 Resource Kit Tools are installed). After you install this, you may simply
add bootmgr.reg
to the registry. This will install the
service named bootmgr
via srvany.exe
utility from the Resource Kit. You
can then check if this works by starting this service and looking if the
volume B: appears. If all is OK and B: shows in the Explorer you can check
if BCD utilities work correctly by e.g. executing bcdedit
without args in
elevated command prompt and looking for output (it should dump current
configuration and not give errors such as "store could not be opened"). If
all is OK you can reboot now and see if the service succesfully mounts the
boot volume at system startup.
Optionally you may wish to hide drive B: from the Explorer window as there
is little benefit from it there. Simply merge hide.reg
into the registry and reboot (probably relogin will be sufficient).
Once in a while Windows installs updates that, presumably, need to modlfy data on a boot partition. These updates go through reboot and run at early stages of system boot, where VHD mount service is not activated yet. As a result, such updates may fail to install.
You may temporarily move boot partition from a VHD inside of Windows machine to separate physical (or virtual, in case where Windows runs inside a VM) drive, proceed with update installation, and then move boot drive back to VHD inside Windows. Follow there steps:
bootmgr
service, this can be done from command line with> sc stop bootmgr
> sc config bootmgr start= disabled
> C:\boot\unmount.cmd
C:\boot\bootmgr.vhd
file to some other machine.bootmgr.vhd
from VHD to RAW format, this can be done withqemu-img convert
:$ qemu-img convert -f vpc -O raw bootmgr.vhd bootmgr.raw
bootmgr.raw
to separate physical or virtual disk and attach this> C:\boot\create.cmd
bootmgr
service back:> sc config bootmgr start= auto