![]() |
Win-6.x: Booting from a Virtual Hard Disk (VHD) - Printable Version +- Post4VPS Forum | Free VPS Provider (https://post4vps.com) +-- Forum: VPS Discussion (https://post4vps.com/Forum-VPS-Discussion) +--- Forum: Tutorials (https://post4vps.com/Forum-Tutorials) +--- Thread: Win-6.x: Booting from a Virtual Hard Disk (VHD) (/Thread-Win-6-x-Booting-from-a-Virtual-Hard-Disk-VHD) |
Win-6.x: Booting from a Virtual Hard Disk (VHD) - fChk - 06-06-2020 Prologue: This is a topic that was first published on the now defunct FreeFTPSpace Forums around 2014. I'm reposting it here, following the promise made in this post, in the hope to still be useful to others. It should be noted that even though the topic focus was on Win7, the technique is also valid to any Windows 6.x, including Win10. With windows 6.1 (Win7/Windows Server 2008 R2) [1], there is a new question that faces any sysAdmin when considering their deployment: "Do we want to install to a physical volume or a VHD?" The routine, when you install an OS, is to select a volume/partition on a hard-disk drive and let the installation process dump it there. Your system's files and folders will then be visible/accessible when you explore that volume with any NTFS-aware file manager out there. The brand new stuff that shipped with Win 6.1 is that it gives you the option of performing that installation to a VHD file instead of a physical HDD's volume and boot natively from it. 1- What Are VHDs? The virtual hard disk (VHD) format enables a single file to simulate a physical HDD, with its own volumes, file systems, and content. It was originally part of MS Virtual PC virtualization solution, which has been enhanced for use by Hyper-V, the new MS server virtualization platform. Thus, to the computer, an "online"(/mounted) VHD file appears as a separate volume that can be treated exactly as any other volume on your hard disk. And, because you can store as many VHD files as you want on a disk, you can configure any Win 6.1 system to boot into different systems that you have installed in them without any repartitioning of your HDD. Before showing how to mount and boot those VHD files, I must quickly say that for Windows 7, only the Enterprise and Ultimate editions can be configured to boot from them. 2- Mounting a VHD The easiest way to attach/detach VHDs is through the Disk Management console:
3- Booting from VHD This is really the feature that I was so delighted to find out in Windows 6.1 systems. It's very useful for multi-boot scenarios and provides an incredible ease in the portability of the operating system! As because the VHD image is a single file, you can easily back up the entire operating system environment by copying that single (+/- huge) file OR use it in a virtual environment (via HyperV, VirtualBox etc..) The booting aspect of it boils down to the possibility of configuring the "new" Windows 6.1 systems' bootloader to start Windows from a VHD file exactly as if the VHD file were a standard partition. Following are the 2 common scenarios that one might face: > Installing Windows directly into a VHD (see 3.1) and > Adding an existing VHD file (coming from another system or a virtual machine) to the boot menu so that we can boot from it (see 3.2.) 3.1- Creating a Bootable VHD Image from scratch For the step-by-step that follows, we'll suppose that we start with an unformatted disk and we wish to install Win7 directly on a VHD file. [ol] [*]Boot from the Windows 7/2008 R2 media. [*]Select the language option then click Next. [*]At the Install Now screen, press Shift + F10 to open a command prompt window. This is done to partition our disk and create the VHD file that the operating system will be installed to. [*]To select the targeted disk (in case we have many) and wipe its content do the following: Code: > diskpart Code: > create part primary size=100 Code: > create part primary Code: > create vdisk file=d:\win7-ult.vhd maximum=20000 type=expandable Code: > list vol Code: > exit [/ol] 3.2- Creating a Bootable VHD Image from an existing file Now suppose you have an existing VHD file that you wish to add to the boot menu and that you want to be able to boot from. This VHD could have come from any another system or even a virtual machine. The command sequence is as follows: Code: > bcdedit /copy {default} /d "Win7-Ultimate (SP1) VHD" 4- Things to keep in mind while working with VHDs
Authors Note for Win10: If you want to use bootable VHD for Win10, please keep in mind that you won't be able to upgrade it when the next version is released. I've already tried it, but each time Win10 refuses to do an in-place upgrade, which led me to end up with 3 consecutive Win10 versions on 3 separate VHDs. You've been warned! Recently though, I migrated a Win10 VHD to QEMU/KVM but still didn't have time to test if I will be able to upgrade it in that environment. Another possibility that I've recently tested (as of last week) is the brand new possibility to install Win10 inside an LXC/LXD VM (more on this in another topic.) [1]- Vanilla Windows 7 and Server 2008 R2 have identical version and build numbers, i.e. 6.1 (Build 7600), because they were built from the same Windows code base. RE: Win-6.x: Booting from a Virtual Hard Disk (VHD) - tryp4vps - 06-11-2020 Nice tutorial, although I rarely needs booting directly from VHD. The main reason I do not use it is that hibernation is too important for me. I need hibernation working for all Operating Systems I use. ![]() But still I realize that booting from VHD does have some good usage cases. Thank you for posting about it here. RE: Win-6.x: Booting from a Virtual Hard Disk (VHD) - fChk - 06-11-2020 (06-06-2020, 03:47 AM)fChk Wrote: [1]- Vanilla Windows 7 and Server 2008 R2 have identical version and build numbers, i.e. 6.1 (Build 7600), because they were built from the same Windows code base. This part of the OP should have raised few eyebrows, at least I hope :-) Think about it a bit... if win7 and win2k8 R2 share a common set of core system files (explaining the same build number that they have), how does the system know which version of the two and which edition of that version (Pro, Ultimate, Enterprise etc.. for Win7) has to be booted ? It's an interesting question to ask for the inquisitive minds. Well, here is the thing, the answer is entrusted in a very strategic file called the system license policy file: "tokens.dat"; it's stored in a very deep folder: "\Windows\ServiceProfiles\NetworkService\AppData\Roaming\Microsoft\Software ProtectionPlatform\". Thus the decision to take a client or server configuration as well as to enable or disable the features ad-hoc to the edition that is loading is done at boot-time by consulting "tokens.dat" file [1]. If you open your registry (by typing regedit) and take a look at the value of "ProductType" under the HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions key, you'll see that it is "WinNT". For Win 2k8 R2, that should be "LanmanNT" or "ServerNT", depending on its role (with or without Active Directory respectively.) This value (among others) is loaded into the registry based on that famous licensing policy file mentioned earlier. For the features enabled by edition of a given version, they are loaded in the value of "ProductPolicy". It's in Hex and contains a cached copy of the data inside the tokens.dat file. Now, you're in the know too... [1]- Remember that tampering with tokens.dat is a direct violation of the software license. RE: Win-6.x: Booting from a Virtual Hard Disk (VHD) - rudra - 06-11-2020 it is a really nice tutorial. i think i will find some time eventually to experiment on how to boot this vhd from within grub2 or grub 4dos. it may appear pointless to jump all this hoops to use Windows. why not install directly on a partition or usb stick if one has to keep that vhd on an ntfs partition. but i think one could think about security from isolation as a big advantage. you could do whatever you want and get you system as riddled with malwares as you want when inside it. also i see a chance to keep the default boot to lead inside one such vhd for any other user that may want to use your system. security... RE: Win-6.x: Booting from a Virtual Hard Disk (VHD) - humanpuff69 - 06-12-2020 booting to vhd is a nice feature . what i think for the use case it is great and open lot of posibility ., for example is virus testing or doing compartment so you only use vhd for browsing for example and another vhd for work . but it is unfortunate that it doesnt support windows version update . microsoft probably abandon this feature . they dont bother to add support to vhd booting RE: Win-6.x: Booting from a Virtual Hard Disk (VHD) - fChk - 02-14-2021 (06-11-2020, 07:18 PM)rudra Wrote: it may appear pointless to jump all this hoops to use Windows. why not install directly on a partition or usb stick if one has to keep that vhd on an ntfs partition. but i think one could think about security from isolation as a big advantage. you could do whatever you want and get you system as riddled with malwares as you want when inside it. also i see a chance to keep the default boot to lead inside one such vhd for any other user that may want to use your system. security... (06-12-2020, 12:55 PM)humanpuff69 Wrote: booting to vhd is a nice feature . what i think for the use case it is great and open lot of posibility ., for example is virus testing or doing compartment so you only use vhd for browsing for example and another vhd for work . but it is unfortunate that it doesnt support windows version update . microsoft probably abandon this feature . they dont bother to add support to vhd booting It's quite interesting that in both quotes above there is a misunderstanding of what booting from a VHD is all about. Thus I advice them to re-read section 1. When a VHD is used to boot from physical hardware -which is this thread's topic- then there is no sandboxing from a security perspective. Your hardware, system boot, all accessible filesystems and shared networked volumes are all exposed to whatever malware/virus you're testing. If you want the sandboxing security aspect of VHD, you then have to use it inside a VM!.. The Key-Point in using VHD is the portability ascpect, meaning you move it across physical machines as well as VMs. That's all ! RE: Win-6.x: Booting from a Virtual Hard Disk (VHD) - Sn1F3rt - 02-28-2021 Nice tutorial @fChk! This is something completely new to me and appears advantageous due to the portability factor. Your explanation in the OP as well as the last post is great for a newbie like me. Quote:Before showing how to mount and boot those VHD files, I must quickly say that for Windows 7, only the Enterprise and Ultimate editions can be configured to boot from them. Quick question, is that the same for Windows 10 too. Cuz I've Professional for both Win 7 and 10, and umm no plans of upgrading so just wondering if I'll be able to use it. Thanks again for the tutorial! RE: Win-6.x: Booting from a Virtual Hard Disk (VHD) - fChk - 03-01-2021 (02-28-2021, 04:26 PM)sohamb03 Wrote: Quick question, is that the same for Windows 10 too. Cuz I've Professional for both Win 7 and 10, and umm no plans of upgrading so just wondering if I'll be able to use it. No!.. you can perfectly boot from a VHD with Win10 Pro!.. At least that was the case when I was still using it that way!.. RE: Win-6.x: Booting from a Virtual Hard Disk (VHD) - Sn1F3rt - 03-01-2021 (03-01-2021, 08:46 AM)fChk Wrote: No!.. you can perfectly boot from a VHD with Win10 Pro!.. At least that was the case when I was still using it that way!.. Thanks for the confirmations, I'll try it out once my exams are over in the next few months. Though first I'll need a good amount of backups, I've a lot of stuff on this disk that is important and well I never saved it elsewhere including coursework material and other personal documents. |