📜 ⬆️ ⬇️

Grub 2 + VHD: install and boot Windows 7 Ultimate

Introduction


It's no secret to anyone that since the version of Windows 7 Ultimate, Microsoft's operating systems can boot by being installed on a VHD format hard disk image. However, this opportunity out of the box is available only to users of this very Windows 7 Ultimate.

I, a dedicated Arch Linux user, need to use this technology has arisen because of the need to have Windows on hand in dual block and in a real environment. 90% of the tasks for which Windows is needed are, of course, solved by virtualization, and the power of modern hardware, and the capabilities of virtual machines, allow even playing games in a virtual environment. However, it became necessary to use the “Universal Mechanism” package, which works crookedly under Vain (I admit that my hands are crooked), and in a virtual environment, understandably, it shamelessly loses its agility. In general, I needed Windows, but I didn’t want to drag partitions on the screw and change its markup for the sake of installing one program for Windows.

The solution was found in the implementation of booting from a VHD image using the Grub2 boot loader, which has become the de facto standard in many popular Linux distributions. About this actually will be discussed.
')
What are the advantages over the standard installation of Windows in dual-boot with Linux gives such a technique:



So, we proceed to the description of the method.


1. Soil preparation


To store images, we still need an NTFS partition, which can be both primary and logical, and not necessarily active. It can be created using gparted , in the same place and formatted in NTFS. I had an unallocated area reserved for various axes experiments on HDD, which I gave to this section.



Next, make this section available for VirtualBox virtual machines.

$ VBoxManage internalcommands createrawvmdk -filename ~/<  >/win7.vdmk -rawdisk /dev/<> 


that is, we create a virtual disk in the form of a file link to the real HDD partition. We connect this disk to a virtual machine with Windows 7 Ultimate - it will be useful to us to solve the problem.



2. Create a VHD image with the system


Now you need to create a VHD-HDD image. You will have to create it using the tools provided by Windows 7 Ultimate, because disks created by the same VirtualBox cause the subsequent crash of the bootable Windows to the BSOD.

We load the virtual machine with Windows. Go to Control Panel -> System and Security -> Administration -> Computer Management -> Disk Management. On the right side of the window there is a menu where we select the creation of a virtual disk.



then we specify the path to it and set its parameters



Better yet, choose a fixed image size — this will work faster.

Click OK and while the process is in progress, we will execute

3. Configure bootmgr bootloader


The bootmgr bootloader itself and the directory with its boot config are simply copied from the Windows 7 installation DVD to the root of the NTFS partition, to the same place where the folder with the VHD disks is located.



Delete the \ boot \ bcd file, because this container stores the configuration from the bootable DVD, and create a new container. For this we use a tiny utility bootice . Run it, select the “BCD edit” tab.



Next, click “Create new BCD”, select the path where the configuration file will be located and create it with the name BCD. Next, select this file and click “Easy mode” - launch the editor in the simplified mode.



The configuration file will open in edit mode, click the “Add” button and select the “New VHD boot entry” option. The editor is a boot record template and we just need to enter the path to our image.



The path to the VHD file from the root of the partition with images is written in the “File” field. After that, click “Save current system” and exit the program.

We wait until the process of creating a VHD image is over and leave the virtual seven.

4. Installing Windows 7 Ultimate on a VHD image


Implemented by means of VirtualBox. For this:



However, I must say this about what. We remember that our system is installed in the VM, and therefore some devices are defined at the installation stage and the system slipped the appropriate drivers for them. When you run on your real computer with a probability of 99%, you will get a BSOD. This is due to the fact that VirtualBox emulates an IDE controller as follows.



and this driver, working in a bootable system, conflicts with the actual one installed on the mat. board controller, when the system tries to read the image file from the disk. It is solved simply - select “Update driver”, we say that we should not search and we will specify the driver and select “Standard dual-channel IDE controller”



After that, turn off our virtual machine and make it "real"

5. Configuring the Grub2 bootloader


In the Grub2 config, you need to add a boot entry of this type

 menuentry “Windows 7 Ultimate SP1″ { set root='hd0,msdos4′ ntldr /bootmgr } 


where (hd0, msdos4) is the NTFS partition where the VHD images are located.

After that, you can reboot and try ...

Conclusion


After downloading, install the driver on our real hardware and enjoy life:



Depicted on screenshots is a full-fledged OS that runs on real hardware. But it is just a file on your hard drive. This file can be copied, deleted, moved, archived and so on. In addition, this method solves the perennial problem of the conflict of Windows vs Linux on one HDD. Now they peacefully get along with each other and do not spoil each other's life.

Source: https://habr.com/ru/post/228641/


All Articles