How to install Windows on a VHD virtual hard disk. How to install Windows on a VHD virtual hard disk Installing OSes on a virtual disk

First of all, this post is for those who would like to try Windows 7 on their computer, but for some reason do not risk doing so - for example, they do not want to repartition the partitions on the hard drive, there are doubts about its further performance or compatibility with existing installed OS. But thanks to some new features in Windows 7, this is no longer a problem. Now you can install a new Windows 7 OS next to your existing one, without in any way affecting its basic functionality, disk layout or file structure. In addition, you can safely install several independent copies of Windows 7 on one partition and successfully switch between them.

All this is now implemented very, very simply - .VHD files, known as virtual disks, are now treated by Windows 7/Windows Server 2008 R2 as separate partitions and support loading the OS installed inside these files. But, I want to note, this case has nothing to do with virtualization - the system inside the VHD boots in the same way as if its files were simply on a “regular”, familiar to us, disk partition of type C: or D:. That is, we create a .VHD file of the required size on an already existing file system of a particular disk, during the installation of Windows 7 or Windows Server 2008 R2, we mount this VHD file as a separate disk partition, install the OS into it... Everything... We can repeat the procedure M, no, better N times, until you run out of space on the “parent” partition and install as many OSes as you can fit. In this case, both the OS installed on the “parent” partition and the OS in other .VHDs will remain untouched.

The prospects, as you understand, are colossal, both for ensuring accelerated deployment and for ensuring fault tolerance and dynamic load distribution using the same virtualization. Now any virtual machine, if it needs increased hardware resources, can be transferred to a “physical” state by simply redirecting the physical host loader to the .VHD file of this virtual machine, and, conversely, any OS running on a physical host can be immediately turned into a virtual one . The prospects are tempting... Until the imminent implementation of "Rise of the Machines" and "The Matrix"... :)

Well, now - to the point... Theory without practice is empty... Let's say you have at hand a modest PC or laptop, the hard drive of which has only one partition C:, and there is 50GB of free space on it. You want to install Windows 7 beta here, but at the same time keep the same Windows Vista installed on the disk.

So, installing Windows 7 or Windows Server 2008 R2 on VHD. It's simple:

  • Download the required Windows 7 image
  • We burn the “downloaded” ISO image to disk or make a bootable USB from the image with the installation of Windows 7 (very useful for netbooks)
  • We boot our PC from the received disk/USB
  • We confirm the installation, select the language and edition, agree to the license and all that... Don't be afraid, everything will be fine with your current system...
  • We reach the installation wizard step, where we are asked to select or create the disk partition on which Windows 7 will be installed.

Now attention! Follow the instructions... Trick!

Press the key combination Shift + F10, the wizard launches the command line CMD.EXE. In the CMD.EXE window, run the program. We wait a little and receive an invitation DISKPART>

Next are several steps - creating the .VHD file itself, the future disk for installing a new copy of Windows 7, selecting and mounting this file as a “real” disk, from the point of view of the installation wizard.

At the DISKPART> prompt, enter the command

create vdisk file="C:\Win7.vhd" type=FIXED maximum=30720

This command creates a .VHD file on drive C: with the name Win7.vhd (the drive, location folder and file name depend only on your system and imagination), the maximum size of the future virtual disk is defined as 30GB, while the .VHD type is defined as “fixed” size", i.e. the file will initially occupy 30GB on the “parent” file system. This will provide better performance and less chance of crashes, because if you specify the type as "dynamically expandable" (type=EXPANDABLE), then firstly, it will require additional disk operations as the actual size of the .VHD increases, and secondly, if “suddenly” the space on the parent partition runs out before such a file reaches its maximum size, then no one is responsible for the consequences for the OS using this file :) On the other hand, 30GB of disk space is more than enough to install the system, especially that the user's files can be stored on the file system of the "physical" disk, which will also be accessible by the OS installed on the .VHD. And here the dynamic type allows you to save disk space. The choice, as they say, is yours. For a more complete overview of the create vdisk parameters, I recommend that you familiarize yourself by executing the command in the DISKPART> line

After successfully executing the create command (the process can take a long time when creating a fixed file with a large maximum size value), run the following commands:

DISKPART> select vdisk file="C:\Win7.vhd"

Selecting the created .VHD for further operations within the diskpart utility

Mount the selected .VHD disk as a new disk in the system

After successful completion of all operations by the team exit exit the diskpart utility, and once again the command exit- already in the CMD.EXE prompt to close the command line.

We returned to the installation wizard window with the selection of a disk to install Windows 7. In it, click the Refresh button located under the list of disks. We see our new disk, select it, click Next.

That's it, the process of installing Windows 7 on the .VHD disk that we just created has begun... This will not only install a new OS, but also replace the bootloader on the “physical” system partition for a successful start from .VHD. By the way, when installing Windows 7/Windows Server 2008 R2 on a bare machine, the installation wizard automatically creates a 200MB system partition on the disk, on which the boot loader is placed, and a separate partition is created for the system itself.

And one more, far from idle, question. How to boot from an existing VHD file in which Windows 7 is installed, for example, transferred from another PC. Everything is very simple - you need to replace the bootmgr/bcdedit.exe bootloader files on the system partition with versions taken from an already installed Windows 7. Please note that this type of bootloader and the ease of replacing it are supported only for Windows Vista/Windows Server 2008, and you will have to tinker with Windows XP (dig in the direction of bootsect). Next, having received the bootloader from Windows 7 on the “physical” OS, we launch the “new” bcdedit, whose device and osdevice parameters now support values ​​like vhd=C:\Win7migrated.vhd. In general, it will look something like this: bcdedit /set (boot_record_GUID) device vhd=C:\Win7migrated.vhd (read documents on the Internet for more details). After such experiments, we reboot the system and see the bootloader menu, supplemented by a new item and transferring control to the transferred .VHD file

4. Install Windows 7 on a virtual disk in a VHD file.

By installing the system on a virtual disk, in one VHD file, you get the following advantages compared to a regular system:

You can make a copy of the operating system simply by copying the VHD file

You can test beta versions of programs without worrying about the system

You can study the system, experiment with the registry, without fear of ruining it.

1) Insert the Windows 7 installation disk into the drive, boot from it

2) Get to the installation wizard step, where you are asked to select or create the disk partition on which Windows 7 will be installed.

3) Press the key combination " Shift+F10".

This keyboard shortcut will give you access to the command line. Type Diskpart in it and press Enter.

The command line will look like this: DISKPART>. This indicates that the DiskPart interpreter is running.

3) Enter the following command into DISKPART:

create vdisk file="E:\VHD\win7.vhd" type=expandable maximum=30000

It means creating a win7.vhd file of an expandable type, limiting the maximum size to 30 Gigabytes. Replace E: with the name of the drive where you want to store the created file.

4) Mount the VHD file so that it is available to the installer:

select vdisk file="E:\win7.vhd" attach vdisk

5) After successfully completing all operations, type the command exit to exit the utility diskpart, and again the command exit– already at the CMD.EXE prompt to close the command line.

6) You will find yourself in the window again Select partition to install.

7) Click the button Update located under the list of disks and you will see your new disk

8) Since there are no sections on it yet, it will be written Unallocated disk space...

9) Select it and click Disk setup

10) Click on the " button Create", specify the volume of the section to be created and click on the button " Apply".

11) Make sure once again that you have selected the virtual disk you created and click Next, ignoring the warning: Windows cannot be installed on disk...

The Windows 7 installation process on the VHD partition will continue as if it were a regular logical hard drive partition. In this case, not only will a new OS be installed, but the bootloader on the “physical” system partition will also be replaced for a successful start from the VHD. When installing Windows 7 on a “clean” system, the installation wizard will automatically create a 100MB system partition on the disk on which the boot loader is placed, and will create a separate partition for the system itself.

From time to time the need arises to install Windows 7 or Windows 8. Everything would be fine, but there is not always the desire and opportunity to allocate an entire partition for the new system, and then play with bootloaders for a long time.

Luckily, Windows 7 and Windows 8 support installation on a virtual hard disk (VHD). By and large, a virtual hard disk is a fairly large file that can be connected to the system as another hard drive. Everything that is contained on that disk is stored in that file.

The advantages of this approach are:

  1. The system runs much faster on physical hardware than on a virtual machine. This is one of the main advantages of installing the system on a VHD compared to installing the system on a virtual machine;
  2. The VHD will act like a physical disk. In other words, you can easily access all the data on your hard drive;
  3. The VHD is stored in a single file and you can "clone" the system by simply copying the VHD file;
  4. You can test new programs, games, etc. without fear for your main system;
  5. You can use new versions of Windows without uninstalling the main one. In light of the release of Windows 8, this is especially relevant.

And so, let's start installing Windows 7 or 8 on a virtual hard disk.

Installing Windows on a virtual hard disk

To install Windows we need

  1. Pre-installed Windows 7 or 8. This is assumed to be your main OS.
  2. Bootable DVD or flash drive with Windows 7 or 8 (depending on what you want to install). What it is and where to get it is described in the manuals: and.

There are two ways to create a VHD:

  1. in running Windows;
  2. using the command line during Windows installation

Let's consider the first method along with the system installation process.

1. Creating a VHD file in a Windows environment and installing the system on it

Click on the item Computer on the menu Start right-click, then select Control. If everything is done correctly, you should see something like this:

Choose Disk Management on the left, then in the menu Action choose Create a virtual hard disk. The following dialog box will appear on the screen:

Specify the name and location of the VHD file, as well as the maximum size. It's best to choose Dynamic expansion since in this case the VHD file will take up exactly as much space as the information on the virtual hard disk contains. In this example, I created a virtual hard disk file with a size of 25 GB and the name win7.vhd on drive D:\.

That's it, the file is created. Now insert a boot disk or USB flash drive with Windows and reboot the system.

Let's start the Windows installation:

In order for us to be able to install Windows on a virtual hard disk, we need to connect (mount) it. To do this, click Shift and F10 to call Command line:

We need to enter the following commands:

Discpart

attach vdisk

In quotes we indicate the path to your VHD file that you created earlier. Next we close Command line and continue with the installation.

When selecting an installation disk, ignore the warning:

Let's now consider creating a VHD disk during the Windows installation process.

2. Create a VHD during Windows installation

We boot from a flash drive or DVD with Windows and start the installation. How to do this is described in the articles linked above. At the beginning of the installation, a window similar to this should appear:

Now we need to somehow create a virtual hard disk so that we can install the system on it. To do this, click Shift and F10, and then enter:

Discpart
create vdisk file="D:\win7.vhd" type=expandable maximum=30000

Using this command we will create a virtual hard disk file wind7.vhd in the root folder of the section D:\ with maximum size 30 000 megabyte or approximately 30 GB.

The virtual hard disk file was created, but Windows Installer knows nothing about it. In order for the created virtual hard disk to appear in the list of partitions, you need to “mount” it. To do this, enter the command:

Select vdisk file="D:\win7.vhd"
attach vdisk

After this, we continue the installation as usual. When you get to selecting the partition to install, select the hard drive you created. If after entering the commands the virtual hard disk does not appear, then click on the button Update.

Upon completion of the installation, you will be able to choose which system to boot during boot: the main OS or Windows, which is installed on the virtual hard disk.

Let's look at how you can rename the name of the new system in the boot list so that it can be easily distinguished from the installed system.

Editing the Windows Boot Loader

To edit the bootloader it is convenient to use a standard utility bcdedit.exe. Run Command Prompt as Administrator. To do this, find it in the Start menu, right-click and select the appropriate item in the menu.

If you have a booted system that is installed on VHD, enter:

Bcdedit /set (current) /d "Windows 7 VHD"

Here "Windows 7 VHD" is the desired name in the boot list for the system on the virtual hard disk, and (current) is the identifier of the bootloader for which the name is changing. The entire list of identifiers can be viewed by running bcdedit without parameters.

For me it looks like this:

Most likely you will have an ID default, if not, then notice the default in your code. This is done like this:


bcdedit /set (default) description "Windows 7 VHD"
bcdedit /default (current)

Here the system (default) is given the name "Windows 7 VHD". Specify that the current OS should be loaded by default. I was running Windows 7 from the "main" physical media.

How to remove Windows already installed on VHD

This can be done in many ways, but we will use the most primitive and easiest in my opinion.

To do this, we need to go to the "System Configuration" window; to do this, select "Control Panel" in Start, then find "Administration" and "System Configuration" in the window that appears, find the "Download" tab. The entire path is shown in the picture below:

And thus you should have a window like this:

And so you can see that there are controls here like "Delete" and "Use as default." So you can with bcdedit rename the new system, and will assign the desired system as the main one in this window.

That's all for me. Thank you for your attention!

Don't judge strictly, this is my first article. I'm waiting for your suggestions and comments!

Creating a virtual hard disk in Windows 10 (VHDX or VHD) is the process of creating a file that can use the extension ".vhdx" or ".vhd" and acts like a physical hard disk, but with the difference that it is stored on an actual hard drive. Using any format (.vhdx or .vhd) for the virtual drive, you can store any files, including documents, images, videos, boot files and the entire OS installation. The only differences between the two formats are that the .vhdx file supports a maximum size of 64 TB, is resilient to power failure, and provides better performance. Typically, a VHD comes in handy for adding additional storage to a Hyper-V virtual machine, and with its ability to support other OS installations, this storage virtualization technology can be used to create a dual-boot system without modifying an existing partition.

Working with virtual disks in Windows.

As more and more data began to be stored on a computer, tablet or phone, replacing filing cabinets, bookshelves, photo albums and CD holders, we quickly had to face the fact that there may not be enough space on the device for all information, including a collection of films or games. One solution is a hard drive. Virtual hard drive partitions take digital data storage to the next level. First, we'll look at what we're talking about when we mean a virtual image. And one of the most important points: the terms “virtual disks” and “virtual machines” can be used interchangeably. The digital storage space and high demand for it will continue to grow. Many web services that offer virtual imaging in the cloud come under scrutiny for their privacy policies. Unlike storing all your files on your own computer or a physical external drive, with a virtual drive you upload your files to a server. This means that technically you won't be the only one who has access to them.

A virtual disk is a type of logical partition that is used in virtualization solutions. It is similar to the regular one, but installed on a virtual machine or virtual server. A virtual image performs the same task as a hard drive does for a computer, except that it does it for a virtual machine. It is created by the virtualization manager, logically dividing and distributing space among one or more virtual machines. A virtual disk can be used to install guest operating systems, applications, and virtual machine data. The capacity of the virtual drive depends on the basic capacity requirements of the physical drive. In memory virtualization, a virtual disk is a logically isolated drive on top of a storage network. A cloud storage solution installed on a local computer is also used as a virtual hard drive.

Creating a laserdisc image

You can create a virtual disk image on Windows 7 using one of the many applications for working with images and virtual drives. Let's look at the process using PowerISO, WinISO and WinCDEmu as an example.

How to make an ISO image of a CD, DVD or Blu-ray disc with PowerISO

PowerISO can create an ISO file from a CD, DVD or Blu-ray by copying it step by step. All information, including download data, will be copied. You can launch ISO maker using the main program or the shell context menu. ISO file using the main program:

  1. Launch PowerISO.
  2. Click the "Copy" button on the toolbar, then select "Make CD/DVD/BD Image File..." from the pop-up menu.
  3. PowerISO will open the ISO Maker dialog box.
  4. Create and select a virtual drive containing the disk you want to copy.
  5. Click OK to start the ISO file creation process.

ISO file via shell context menu:

  1. Open My Computer and select the drive you want to copy.
  2. Right-click on the selected drive and a shell context menu will appear.
  3. Select the "Make Image File" menu.
  4. The ISO Maker dialog box will open.
  5. Select the output file name and set the output format to ISO.
  6. Click "OK" to start the process.

WinISO can meet your needs for working with all image formats such as .ISO, .BIN, .CUE, .NRG (Nero), .MDF, .MDS, .CCD, .IMG and .DVD.

  • Step 1. Install and launch the software. Firstly, download WinISO for free from the official website, install and run it. After installation, launch the program.
  • Step 2: Click the "Tools" button. Click the “Tools” button on the toolbar, and then “Make image from CD/DVD/BD”. Or you can simply click "Create". Creating a virtual disk for Windows 10 is done in a similar way.
  • Step 3. Selecting and setting the recipient. A dialog box will appear. Select the drive containing the CD/DVD/BD and at the destination, select the desired output format, then enter the "File Name". After this, you can click the OK button to start creating the ISO file.

You can optimize the storage of data, applications, and anything else that can be burned onto a CD/DVD by creating ISO images and storing them on your hard drive. Installing a program from an ISO image is much faster than using a real optical disc. Double-clicking an image to mount it is faster than inserting it into the drive, and finding the right image using Windows Search is much more convenient than searching for the right CD on the shelf. To create an ISO image using WinCDEmu, follow these steps:

  • insert the CD you want to rip into the optical drive;
  • open the “Computer” folder in the “Start” menu;
  • Right-click the CD icon and select Create ISO Image.
  • Select a file name for the image. This is similar to saving a newly created document or image. Click "Save".
  • Wait until the image is created. Once it's created, you can remove the physical CD from the drive and mount the image whenever you need it.

Virtual hard disk

In Windows 7, Microsoft introduced a new way to back up your data called Backup and Restore. It allows you to backup all your data to another location and provides the ability to create a system image. A system image is a large document with a VHD extension. It can be used to restore the entire system. In Windows 7, the image creation program was so popular that it remains in Windows 8 and Windows 10. There is a tool in the control panel - Backup and Restore (Windows 7). The convenience of backing up your computer using this method, in addition to the ability to completely restore it later, is that you can transfer the file to any Windows 7, 8 or 10 computer and access the data in the same way as from a regular hard drive. Therefore, if you only need to copy a few files from your backup, it is much easier to make a virtual hard disk using a VHD, rather than restoring a backup, which will first completely delete the data and then copy the data stored in the image.

Mounting VHD

To mount the image in Windows, click “Start” and type “Computer Management” in the search box. You can also go to Control Panel, then System and Security, then click Administrative Tools and then Computer Management. If you're in Icons view, click Administration. Now, in the menu on the left, click “Disk Management” and wait for the list of disks and partitions to appear. Then right-click Disk Management and select "Mount VHD". In the dialog box, click Browse, navigate to the location of the file you want to include, and click OK.

ATTENTION. If you do not select the Read Only checkbox, you will be able to add, edit, or delete files/folders from the VHD. This is really useful because you can attach your file, add some more data that you want to copy, and then just extract it.

Once the system finishes mounting, you will see the drive appear as a new device in My Computer. Windows will automatically assign a drive letter. Otherwise, right-click on Primary Partition and select Change Drive Letter. To remove a VHD, right-click on the gray area with the drive name and select "Eject VHD".

You can save a copy of the operating system and all personal data in a document using a free Microsoft tool. Go to Computer Management, click Disk Management, and then right-click Disk Management. Instead of selecting Mount, click Create VHD. This will bring up a window asking you to specify the document size, format, and location. It is recommended to choose the VHDX file format as it is less prone to hacking and can support larger sizes. If you select the VHD file format, it will recommend a fixed size. If you select VHDX, you will be offered dynamic expansion. It's better to leave the default settings. Be sure to enter the size of your virtual disk. You can change it to GB or TB in the dropdown.

Now another device will appear in disk management – ​​marked “Unallocated”. In the gray section for the new image, right-click and select Enable Disk. Then you need to choose whether to use MBR or GPT. For compatibility with versions of Windows older than Vista, select MBR. For new features and larger hard drives, use GPT. Now right-click on the unallocated area and select New Simple Volume. This will bring up the New Volume Wizard. First, you must select the size of the new volume. This cannot be the size of the unallocated space.

Click Next and select a drive letter to assign to the partition. Then choose a formatting method. By default it is set to NTFS, but FAT32 can also be selected. Select NTFS if you are using virtual media to back up files from your computer. Click "Next" and "Done" and that's it! The new device will now appear in Disk Management.

Using a VHD in a virtual machine

The extension stands for virtual hard drive. This is a format that is structured to represent a standard hard drive and allows you to encapsulate the operating system and data into a single file. This document supports all standard operations. The document is located on our hard drive, but all content is written inside the document. All partitions, data, and the entire file system are saved in the document that is used for loading. Please note that the extension may include the operating system and/or data. The name can be selected during the setup process, but its extension will always be .vhd. You can create a new document using the available disk space.

The image looks like an unused hard drive. After creating a VHD, you can create one or more partitions in it and format them using the FAT, ExFAT or NTFS file system. When it comes to size, a VHD can be fixed in size or it can expand dynamically. A fixed VHD has a predetermined amount of space that is reserved on the physical media. This reservation also includes white space. It takes longer to create a VHD, but it performs better because the whole thing is a single block. A dynamically expanding VHD allocates physical disk space as virtual memory is used by the virtual machine. This means that the size of the .vhd file grows as our virtual machine is used. Additionally, dynamically expanding VHD files do not become smaller when files are deleted.

The existing image can be mounted (mounted) so that it appears on our existing operating system. You can also mount the image as a readable disk. Thus, the contents of the image cannot be changed. Mounted images can be extracted (unmounted) or deleted. The advantage of using VHD is the ability to download and configure multiple versions of the operating system. When setting up multiboot using standard parameters, you need to create a new partition and install Windows there. When using images, a new VHD is simply created. This means that you can have one partition with multiple files (multiple operating systems). Installing a virtual disk also offers greater flexibility when it comes to disaster recovery. We can copy an image from one computer that has been damaged to another with similar hardware. Users will have access to the same OS and data as on the old computer.

Management Tools

You can use DiskPart, Windows Disk Management, WIM2VHD, and BCDEdit to manage VHDs. The Disk Management MMC allows you to create, mount, and extract images. With DiskPart you can create, mount, extract, compress, expand and view image details. Common diskpart commands used for a virtual disk:

  • create vdisk – creates an image with a VHD file size expressed in MB (the file name must have the extension .vhd);
  • mount vdisk – mounts the image;
  • extract vdisk – extracts the image;
  • compress vdisk – reduces the image size;
  • increase vdisk – expands the maximum size available in the image;
  • vdisk details – displays information.

The Windows Automated Installation Kit (Windows AIK) includes a WIM2VHD emulator utility that you can use to create an image from a Windows installation source. Using WIM2VHD, you can create a new image of the specified type and size, apply the WIM, use the Unattend file to automate the Out Of Box boot portion of Windows when you first launch the generic image, and apply updates to it.