{"id":1920,"date":"2016-11-30T17:01:20","date_gmt":"2016-11-30T22:01:20","guid":{"rendered":"http:\/\/swildow.darktech.org\/wp\/?p=1920"},"modified":"2016-11-30T17:01:20","modified_gmt":"2016-11-30T22:01:20","slug":"how-to-turn-a-physical-disk-to-a-bootable-vhd","status":"publish","type":"post","link":"http:\/\/www.wildow.com\/blog\/?p=1920","title":{"rendered":"How to turn a physical disk to a bootable VHD"},"content":{"rendered":"<div class=\"postHeader\">\n<h1 class=\"postTitle\"><a title=\"Permalink to How to turn a physical disk to a bootable VHD\" href=\"http:\/\/blog.mark-mann.co.uk\/index.php\/2010\/10\/how-to-turn-a-physical-disk-to-a-bootable-vhd\/\">How to turn a physical disk to a bootable VHD<\/a><\/h1>\n<div class=\"bottom\">\n<div><span class=\"postDate\">October 31, 2010 at 10:05 am<\/span><span class=\"postAuthor\"><a title=\"Posts by mark\" href=\"http:\/\/blog.mark-mann.co.uk\/index.php\/author\/admin\/\" rel=\"author\">mark<\/a><\/span><a class=\"postCommentLabel\" href=\"http:\/\/blog.mark-mann.co.uk\/index.php\/2010\/10\/how-to-turn-a-physical-disk-to-a-bootable-vhd\/#comments\">Comments off<\/a><\/div>\n<\/div>\n<\/div>\n<div class=\"postContent\">\n<p>My 160GB hard disk is running out of free space. Seriously low\u2026 It\u2019s amazing that I\u2019ve managed to fill it up with so much stuff and it\u2019s all work stuff too. Now normally I rebuild my laptop every 4 months or so (yes I really do) but this time, I don\u2019t necessarily have the luxury of spending a couple of days because I\u2019m up to my armpits on a project.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"My Computer - creaking along\" src=\"http:\/\/blog.mark-mann.co.uk\/wp-content\/uploads\/2011\/06\/20101012vhd2disk01.png\" alt=\"My Computer - creaking along\" width=\"525\" height=\"167\" border=\"0\" \/><\/p>\n<p>So my normal setup is to have my one physical disk partitioned into two: one for the native operating system and the other for my data. I\u2019ve always favoured split partitions, since configuration means that if I ever need to do a rebuild, I don\u2019t have to spend overnight backing up all my work data before the drive gets obliterated. Even though it only takes about 45-60minutes to reinstall Windows 7, it does take a while to install Microsoft Office, Visual Studio, SQL Server and a plethora of other programs and tools. It\u2019s probably a couple of days before I\u2019m comfortably back into a situation where everything is back to how I want it to be.<\/p>\n<p>Thing is, I don\u2019t have a couple of days and ultimately it\u2019s not going to solve my space issue. So I have a cunning plan with Windows 7 because I\u2019ve discovered that it\u2019s now got the inbuilt capability that allows it to <strong>mount and boot <\/strong>from Virtual Hard Disks (VHDs). Effectively a portable, logical disk that <strong>runs natively<\/strong> on the hardware \u2013 not in a virtual machine.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"Where does a VHD sit?\" src=\"http:\/\/blog.mark-mann.co.uk\/wp-content\/uploads\/2011\/06\/20101012vhd2disk02.png\" alt=\"Where does a VHD sit?\" width=\"482\" height=\"213\" border=\"0\" \/><\/p>\n<p>Basically, a VHD is a large contiguous file structure that can be recognised as a hard disk, yet it\u2019s a virtual one sitting on your physical hard disk. I can backup my existing physical disk partitions to a VHD but it has to sit on a larger disk than the original, because there is an amount of hidden space used by the operating system to host the file. VHD\u2019s are a bit clever in that they can be setup as \u201cdynamic\u201d and expand as necessary when data is added to it \u2013 there is no compression involved, but the free space is squeezed out in an attempt to minimise the overall footprint of the VHD \u2013 a 160GB partition with 50% free space will result in a VHD file with a 80GB footprint. Alternatively, VHDs can be set to \u201cfixed\u201d and remain that size regardless of its mounted state \u2013 a 160GB VHD remains 160GB. If you want faster performance then select \u201cfixed\u201d, if you are scrimping on space then select \u201cdynamic\u201d but beware that someday you\u2019ll need that full expanded space available if you fill it up!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"Seagate Hybrid Technology\" src=\"http:\/\/blog.mark-mann.co.uk\/wp-content\/uploads\/2011\/06\/20101012vhd2disk03.png\" alt=\"Seagate Hybrid Technology\" width=\"212\" height=\"96\" align=\"left\" border=\"0\" \/>So, after crooning after a range of Solid State Disks (SSDs) which are blisteringly fast, very expensive but ultimately too small in capacity, I decided to try a 500GB <a title=\"Seagate Momentus XT Solid State Hybrid Drive\" href=\"http:\/\/www.seagate.com\/www\/en-us\/products\/laptops\/laptop-hdd\/\" target=\"_blank\">Seagate Momentus XT Solid State Hybrid Drive<\/a>. Best of both worlds really, optimised for speed, not so expensive and big capacity. <em>Rather ironic, that EMC is one of the largest disk suppliers yet we don\u2019t put high performance disks in our consultancy laptops!<\/em><\/p>\n<p>&nbsp;<\/p>\n<div><span style=\"font-size: medium;\"><span style=\"color: #ff0000;\"><strong>DISCLAIMER:<br \/>\n<\/strong>THIS IS MY JOURNEY FROM DISK TO VHD.<br \/>\n<strong>IF YOU FOLLOW ANY OF THESE STEPS, THEN YOU DO IT AT YOUR OWN RISK!<\/strong><\/span><\/span><\/div>\n<p>&nbsp;<\/p>\n<h3>Creating your VHD<\/h3>\n<p>First thing to get your hands on is <a title=\"Disk2VHD download page\" href=\"http:\/\/technet.microsoft.com\/en-us\/sysinternals\/ee656415.aspx\" target=\"_blank\">Disk2VHD<\/a>. This is a neat little <a title=\"SysInternals website\" href=\"http:\/\/technet.microsoft.com\/en-us\/sysinternals\/default\" target=\"_blank\">SysInternals<\/a> tool from <a title=\"Microsoft website\" href=\"http:\/\/www.microsoft.co.uk\/\" target=\"_blank\">Microsoft<\/a> (just recently had a revamp) which will create you a VHD file for use in Microsoft Virtual PC or for an Hyper-V virtual machine. Unlike some other tools out there, <a title=\"Disk2VHD download page\" href=\"http:\/\/technet.microsoft.com\/en-us\/sysinternals\/ee656415.aspx\" target=\"_blank\">Disk2VHD<\/a> can backup a disk\/volume that is currently operational. YES, that means that you can transpose that disk\/volume that you\u2019ve currently booted from!<\/p>\n<ol>\n<li>Download and install<\/li>\n<li>Run \u201cDisk to VHD converter\u201d as administrator.<\/li>\n<li>The following dialog will pop up, telling you what you can convert and how much space you need to complete the operation.<\/li>\n<li>Specify a destination file name for your VHD.<\/li>\n<li>Tick the partitions that you want to include into the VHD.<\/li>\n<li>Click \u201cCreate\u201d and the tool will take a snapshot and proceed to transfer data.<\/li>\n<li>Depending on the sizes of the partitions you clicked, wait\u2026.<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"DISK2VHD\" src=\"http:\/\/blog.mark-mann.co.uk\/wp-content\/uploads\/2011\/06\/20101031vhd2disk04.png\" alt=\"DISK2VHD\" width=\"417\" height=\"335\" border=\"0\" \/><\/p>\n<p>Couple of things to note:<\/p>\n<ul>\n<li>If you are transferring relatively big partitions (&gt;20GB) then be prepared to wait a while! When I Disk2VHD\u2019ed my laptop, it estimated a 115GB VHD file so I left the tool running overnight!<\/li>\n<li>Disk2VHD can backup your currently operational drive onto a disk in that archive \u2013 I could have cloned the C:\\ and E:\\ partitions to a file on the E:\\ partition. BUT, for performance reasons, this is not optimal.\u00a0 Either plug in a spare USB hard disk or connect to a network drive.<\/li>\n<li>Don\u2019t think that you have to keep all your partitions on the same VHD. If you want to share a partition amongst different instances, then just backup the minimum to each VHD.<\/li>\n<li>Only the booting VHD is guaranteed to be mounted on restart; additional VHDs need to be mounted manually or by script since Windows 7 will not remember on reboot.<\/li>\n<\/ul>\n<p>With my 160GB laptop hard disk backed up to VHD on a network drive, I can now swap my old physical hard disk for my new shiny 500GB <a title=\"Seagate Momentus XT Solid State Hybrid Drive\" href=\"http:\/\/www.seagate.com\/www\/en-us\/products\/laptops\/laptop-hdd\/\" target=\"_blank\">Seagate Momentus XT Solid State Hybrid Drive<\/a>. I decided to continue with my usual split of the drive, by creating a first partition with 80GB for my native booting operating system and a second partition with the remaining available space for my data. This way, if I ever end up needing to rebuild my laptop, I can leave the \u201cdata partition\u201d alone and just blow away the \u201coperating system partition\u201d.<\/p>\n<p>&nbsp;<\/p>\n<h3>Mounting your VHD<\/h3>\n<p>In Windows 7, mounting a VHD could not be simpler. The VHD is better off located on a locally attached drive so if you used a network drive as the destination for Disk2VHD, you\u2019re better off copying it back to either the native physical disk or to USB attached storage. Windows 7 won\u2019t stop you attaching to a remote VHD but it\u2019s much slower \u2013 I guess that it\u2019s because dragging large chunks of a file across the network is a drain on performance.<\/p>\n<p>So, from the \u201cStart\u201d taskbar, search for \u201cDisk Management\u201d or \u201cCreate and format hard disk partitions\u201d. This will pull up the following control panel with details of your current system. <span style=\"color: #ff0000;\">Be careful with any of these options!<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"Disk Management console\" src=\"http:\/\/blog.mark-mann.co.uk\/wp-content\/uploads\/2011\/06\/20101031vhd2disk05.png\" alt=\"Disk Management console\" width=\"630\" height=\"369\" border=\"0\" \/><\/p>\n<p>Now before I go further\u2026 pay heed to the warning from DISK2VHD:<\/p>\n<div><em><span style=\"color: #ff0000;\"><strong>NOTE:<\/strong> do not attach to VHDs on the same system on which you <strong>created them<\/strong> if you plan on booting from them. If you do so, Windows will assign the VHD a new disk signature to avoid a collision with the signature of the VHD\u2019s source disk. Windows references disks in the boot configuration database (BCD) by disk signature, so when that happens Windows booted in a VM will fail to locate the boot disk.<\/span><\/em><\/div>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"Attaching a VHD\" src=\"http:\/\/blog.mark-mann.co.uk\/wp-content\/uploads\/2011\/06\/20101031vhd2disk06.png\" alt=\"Attaching a VHD\" width=\"202\" height=\"170\" align=\"left\" border=\"0\" \/>Since I\u2019ve swapped physical disks and reinstalled Windows, I\u2019m not in danger of that rule. Phew.<\/p>\n<p>Mounting a VHD is very straightforward. From the menu bar, select Action | Attach VHD.<\/p>\n<p>Your VHD will then appear as another row in the disk management matrix and all logical partitions will be identified and assigned a new drive letter for your current session. Once there are drive letters, you\u2019ll get access to the drive through Windows Explorer and be able to access folders and files as you would any other drive. Of course, that also means that any tightened security that was applied (particularly if NTFS formatted) might be a bit of a problem since you\u2019ll have to get permission (elevating to administrator normally helps) to just navigate the file system.<\/p>\n<p>Once mounted, the Disk Management console now looks like below. Be careful, but right click the separate drives and take a look at various tasks \u2013 these allow you to change aspects of the the individual drives to customise your system.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"Disk Management - with mounted VHD\" src=\"http:\/\/blog.mark-mann.co.uk\/wp-content\/uploads\/2011\/06\/20101031vhd2disk07.png\" alt=\"Disk Management - with mounted VHD\" width=\"632\" height=\"415\" border=\"0\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3>Booting your VHD<\/h3>\n<p>The last step. Got a backed-up VHD of my original system and I\u2019ve mounted it to check that it\u2019s all there, however this is not good enough for actually running anything because it\u2019s not the boot device. It\u2019s a law of computing nature \u2013 all the system files and registry settings have to be on the booted partition. Enter the world of GUIDs and <a title=\"BCDEDIT on MSDN\" href=\"http:\/\/technet.microsoft.com\/en-us\/library\/cc709667(WS.10).aspx\" target=\"_blank\">BCDEDIT<\/a>. <span style=\"color: #ff0000;\">Pay heed to my disclaimer above and read all this section before you proceed!<\/span><\/p>\n<p>Gone are the days of boot.ini, autoexec.bat and config.sys (remember them?). Windows now keeps the boot settings within Boot Configuration Data (BCD) stores and <a title=\"BCDEDIT on MSDN\" href=\"http:\/\/technet.microsoft.com\/en-us\/library\/cc709667(WS.10).aspx\" target=\"_blank\">BCDEDIT<\/a> allows you to configure these settings via command line. Since I\u2019ve reinstalled Windows onto my physical drive, I\u2019ll have a good BCD store already configured, otherwise Windows would not have booted up!<\/p>\n<p>From the command line (run as Administrator) execute the following code to copy the existing\/current BCD to a cloned BCD, giving it a new name of your choice:<\/p>\n<p><strong>bcdedit \/copy {current} \/d \u201c<span style=\"color: #008000;\">My new VHD<\/span>\u201c<\/strong><\/p>\n<p>That command will return a message containing a GUID that identifies the key of the new BCD created. Make a note of your GUID, copy it to notepad or something, but don\u2019t lose it, it will be needed in the next couple of steps. Next, change the new BCD to point to the new VHD. Most of it is self explanatory, but note that the <strong><span style=\"color: #008000;\">drive<\/span><\/strong> parameter is the currently assigned drive letter \u2013 the tool just wants to be sure of locating the file:<\/p>\n<p><strong>bcdedit \/set {<span style=\"color: #008000;\">guid<\/span>} device vhd=[<span style=\"color: #008000;\">drive<\/span>:]\\<span style=\"color: #008000;\">folder-path<\/span>\\<span style=\"color: #008000;\">vhd-filename<\/span>.vhd<br \/>\nbcdedit \/set {<span style=\"color: #008000;\">guid<\/span>} osdevice vhd=[<span style=\"color: #008000;\">drive<\/span>:]\\<span style=\"color: #008000;\">folder-path<\/span>\\<span style=\"color: #008000;\">vhd-filename<\/span>.vhd<br \/>\nbcdedit \/set {<span style=\"color: #008000;\">guid<\/span>} detecthal on<\/strong><\/p>\n<p>Two extra commands of note:<\/p>\n<p><strong>bcdedit \/v<\/strong>\u00a0\u00a0\u00a0 \u2014 this will display all the BCD configuration for your perusal.<\/p>\n<p><strong>bcdedit \/delete {<span style=\"color: #008000;\">guid<\/span>} \/cleanup<\/strong>\u00a0 \u2014 cleans out the BCD data for the GUID key supplied<\/p>\n<p>&nbsp;<\/p>\n<p>Just to give you an example, my personal configuration used the following commands:<\/p>\n<p><strong>bcdedit \/copy {current} \/d \u201c<span style=\"color: #408080;\">Windows 7 EMC VHD<\/span>\u201d<\/strong><\/p>\n<p><strong>bcdedit \/set {<span style=\"color: #408080;\">f83d7c67-2b5c-11e0-8cda-e442eeb247bc<\/span>} device vhd=[<span style=\"color: #408080;\">e<\/span>:]\\<span style=\"color: #408080;\">vhd<\/span>\\<span style=\"color: #408080;\">win7-emc<\/span>.vhd<br \/>\nbcdedit \/set {<span style=\"color: #408080;\">f83d7c67-2b5c-11e0-8cda-e442eeb247bc<\/span>} osdevice vhd=[<span style=\"color: #408080;\">e<\/span>:]\\<span style=\"color: #408080;\">vhd<\/span>\\<span style=\"color: #408080;\">win7-emc<\/span>.vhd<br \/>\nbcdedit \/set {<span style=\"color: #408080;\">f83d7c67-2b5c-11e0-8cda-e442eeb247bc<\/span>} detecthal on<\/strong><\/p>\n<p><strong>bcdedit \/v <\/strong><strong>\u00a0<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>Now, <strong>reboot<\/strong>. Fingers crossed that if you followed all these steps, you\u2019ll be marvelling at the extra boot option before Windows spins up. I now get to choose between my native Windows 7 partition or my new \u201c<span style=\"color: #408080;\">Windows 7 EMC VHD<\/span>\u201d which is running from the VHD file. If you need to tweak the system start-up settings,\u00a0 then open the \u201cStartup and Recovery\u201d \u2013 the new instance from the VHD will show up because of the updated BCD records.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"Startup and Recovery options\" src=\"http:\/\/blog.mark-mann.co.uk\/wp-content\/uploads\/2011\/06\/20101031vhd2disk08.png\" alt=\"Startup and Recovery options\" width=\"444\" height=\"257\" border=\"0\" \/><\/p>\n<h3><\/h3>\n<h3>In Summary<\/h3>\n<p>Does it seem any faster? Probably not, at least not noticeably but that has not been my concern, space is. Maybe my new <a title=\"Seagate Momentus XT Solid State Hybrid Drive\" href=\"http:\/\/www.seagate.com\/www\/en-us\/products\/laptops\/laptop-hdd\/\" target=\"_blank\">Seagate Momentus XT Solid State Hybrid Drive<\/a> has helped because of it\u2019s newer electronics and bigger I\/O cache, I\u2019m not fussed. My laptop can breathe now, plus this was all done on a lazy weekend rather than spending a whole week of blowing away my existing Windows instance and reloading all that software and digging out all the licence keys that I\u2019ve accumulated over time and that I actually need to do my job. By the way\u2026 this could be done faster than a weekend since much of the time was creating and copying the VHD up and down from my NAS and that was done overnight.<\/p>\n<p>Hang on though, have I not just moved the problem into a VHD? Well no. I can turn up to work the next day and still be productive, but I\u2019ll systematically remove those really old applications I no longer use and move my local archive folders either to one of my native data partitions or to NAS so that any future Windows instance can see them (native or VHD).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"My Computer - now it can breathe\" src=\"http:\/\/blog.mark-mann.co.uk\/wp-content\/uploads\/2011\/06\/20101031vhd2disk09.png\" alt=\"My Computer - now it can breathe\" width=\"527\" height=\"290\" border=\"0\" \/><\/p>\n<p>This has also proved to be a convenient means of backing up my work. Basically once this is done once, I just reboot into my native Windows instance find the VHD file and copy it to my NAS (with a timestamp in the filename). If I manage to corrupt anything, swap laptop, or run up that VHD in Virtual PC, I just copy it back and change the filename to that in the BCD record (so it always remains as \u201c<span style=\"color: #408080;\"><strong>win7-emc.vhd<\/strong><\/span>\u201d on my laptop). Gives me great flexibility\u2026 although VHDs also have the ability to have support <a title=\"TechNet FAQ: Virtual Hard Disks in Windows 7 and Windows Server 2008 R2\" href=\"http:\/\/technet.microsoft.com\/en-us\/library\/dd440865(WS.10).aspx\" target=\"_blank\">differencing disks<\/a>too, which might help to reduce the constant large footprint (why I have a big NAS!).<\/p>\n<p><strong>A mention about \u201cbooting VHDs from USB Hard Drives\u201d.<\/strong> There\u2019s been some mention of this on the forums and blogs that I came across while researching this topic. Seems to be some sort of holy grail for which I think it\u2019s a stupid idea. Sure, it\u2019s useful to stash VHDs to separate disks, but USB HDDs have one flaw for me\u2026 they are attached to the end of a cable \u2013 have you tried sitting on the sofa with a USB HDD dangling off the side? Tried moving around the airport or the office with your precious HDD swinging about? <strong>DON\u2019T DO IT. BUY A BIGGER DISK<\/strong>. The techniques I\u2019ve described above are there for convenience.. don\u2019t bother tying yourself down again. Disk is cheap!<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>How to turn a physical disk to a bootable VHD October 31, 2010 at 10:05 ammarkComments off My 160GB hard disk is running out of free space. Seriously low\u2026 It\u2019s amazing that I\u2019ve managed to fill it up with so &#8230; <a class=\"more-link\" href=\"http:\/\/www.wildow.com\/blog\/?p=1920\">Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,4],"tags":[],"class_list":["post-1920","post","type-post","status-publish","format-standard","hentry","category-hyperv","category-windows"],"_links":{"self":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1920","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1920"}],"version-history":[{"count":1,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1920\/revisions"}],"predecessor-version":[{"id":1921,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1920\/revisions\/1921"}],"wp:attachment":[{"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1920"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1920"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wildow.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1920"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}