Fun trying to convert an existing install to a vhd!

Page 1 of 2 12 LastLast

  1. Posts : 15,444
    Windows10
       #1

    Fun trying to convert an existing install to a vhd!


    This is not specifically windows 10 but I thought it might be of interest.

    I currently have dual boot 10 home and 10 pro, and it leaves the partitions decidely non-optimal. I decided I would create a virtual hard disk of the Home drive partition and delete the home partition.


    My drive is 1000 GB - partitioned as 3 drives (approx) 250 Home, 250 Pro, 500 Data.


    The Home drive only actually uses around 40 GB.


    So I used disktovhd to convert home drive (ignoring all others) to an expandable vhd (only 40 GB) on Data drive (over 400 GB free).


    I then used bcdboot command to enable booting from it, and rebooted.


    But it would not boot complaining not enough space on host (data) drive!


    I rebooted to windows, attached the vhd from disk management and I was surprised - disk to vhd nominally maps all partitions from the whole drive (ie 1000 TB) even if you do not want them! After quite a bit of googling, I discovered when you use an expandable vhd, it only loads if there is enough space to fit whole of original disk (so it can expand to that in future).


    So the vhd had nominally 750 GB of unallocated space1 More googling, and there is a tool vhdresizer which will reduce it in size. However, tool is so old, and requires a really old version of .Net, I could not get it working.


    So I thought, i will just image the Home drive partition only to the Data drive using Macrium Reflect, and convert that to a vhd. I was gob smacked to see the MRF image exhibited similar behaviour and the vhd still thought drive was 1000 GB!


    So I thought I would try creating a virtual disk and use Macrium to clone the Home drive partition to a new vhd, bbut it looked ok but would not boot.


    So, after trial an error, I finally did it using a smaller 150 GB drive in a usb caddy as follows.


    1) Image backup Home drive to Data Drive


    2) Restore backup to 150 GB drive


    3) Create image backup of 150 GB drive and convert to vhd on Data drive (I probably could have used disk2vhd for this step ie 1 action only).


    Then it worked. OK - maybe there are quicker ways but this did the job. So I was now able to wipe the home drive, and assign the space to data drive.


    The home drive vhd is on the data drive and only takes 40 GB but can expand up to 150 GB over time.
      My Computer


  2. Posts : 5,478
    2004
       #2

    What you could do if you wanted a smaller maximum size (which you are right is the size allocated when you native boot) is make an empty vhdx max size 40GB (or whatever maximum you want), mount it and use macruim to restore the image to that. This has worked for me so I'm not sure why yours would not boot.

    Anyway good you got it working
      My Computer


  3. Posts : 15,444
    Windows10
    Thread Starter
       #3

    lx07 said:
    What you could do if you wanted a smaller maximum size (which you are right is the size allocated when you native boot) is make an empty vhdx max size 40GB (or whatever maximum you want), mount it and use macruim to restore the image to that. This has worked for me so I'm not sure why yours would not boot.

    Anyway good you got it working
    Thanks - I'll try again- maybe it glitched or I made a mistake.

    Basically, I did the same thing with a real drive and took the scenic route .
      My Computer


  4. Posts : 5,478
    2004
       #4

    I broke the laptop I used for work and rather than get a new one moved it onto vhd (it had a 500GB drive and as I only needed OS and programs I put it on vhd with maximum size 20GB). Works well for me but in retrospect 20GB might have been a bit optimistic. I do find that vhds grow and shrinking them never really works very well - after time the vhd is always much bigger than the space used so it is good to limit it if you can.

    One other thing to bear in mind you can't upgrade systems on vhd. You'll have to connect the vhd to Hyper-V or VirtualBox or something to do the upgrade but that is a project for next year :)
      My Computer


  5. Posts : 15,444
    Windows10
    Thread Starter
       #5

    lx07 said:
    I broke the laptop I used for work and rather than get a new one moved it onto vhd (it had a 500GB drive and as I only needed OS and programs I put it on vhd with maximum size 20GB). Works well for me but in retrospect 20GB might have been a bit optimistic. I do find that vhds grow and shrinking them never really works very well - after time the vhd is always much bigger than the space used so it is good to limit it if you can.

    One other thing to bear in mind you can't upgrade systems on vhd. You'll have to connect the vhd to Hyper-V or VirtualBox or something to do the upgrade but that is a project for next year :)
    Yeah I tried again, and for some reason it fails whilst trying bcdboot command.
    Not a big deal.

    I was aware of vhd restriction re. build upgrades. It seems funny you can do it in hyper-v but not natively but easy enough to do but just a nuisance.
      My Computer


  6. Posts : 5,478
    2004
       #6

    cereberus said:
    Yeah I tried again, and for some reason it fails whilst trying bcdboot command.
    Not a big deal.
    Do you have UEFI or BIOS? With UEFI you use bcdboot, with bios you use bcdedit... Solved Can't native boot Hyper-V generation 2 vhdx - Windows 10 Forums

    If bcdboot isn't working you could try bcdedit...

    cereberus said:
    I was aware of vhd restriction re. build upgrades. It seems funny you can do it in hyper-v but not natively but easy enough to do but just a nuisance.
    It is a nuisance and considering you can clean install to vhd it seems odd. There is some complicated technical reason I'm sure.

    I use the same vhd for both native boot and Hyper-V and it is activated with a separate license on the Hyper-V machine. When booting native it picks up the digital entitlement of the underlying hardware. When switching between Hyper-V and native boot though I do have to re-authenticate my MS ID (put in my pin) or all the store apps crash. Like you said a nuisance.

    Probably you could upgrade using Hyper-V (and Windows would be deactivated if you don't have a separate key as the machine ID is different) and it would become activated again when you native boot again but I'm not sure about that. Perhaps upgrading using Hyper-V with the virtual switch disconnected if you don't have a separate key for the Hyper-V VM would be wise.
      My Computer


  7. Posts : 15,444
    Windows10
    Thread Starter
       #7

    lx07 said:
    Do you have UEFI or BIOS? With UEFI you use bcdboot, with bios you use bcdedit... Solved Can't native boot Hyper-V generation 2 vhdx - Windows 10 Forums

    If bcdboot isn't working you could try bcdedit...

    It is a nuisance and considering you can clean install to vhd it seems odd. There is some complicated technical reason I'm sure.

    I use the same vhd for both native boot and Hyper-V and it is activated with a separate license on the Hyper-V machine. When booting native it picks up the digital entitlement of the underlying hardware. When switching between Hyper-V and native boot though I do have to re-authenticate my MS ID (put in my pin) or all the store apps crash. Like you said a nuisance.

    Probably you could upgrade using Hyper-V (and Windows would be deactivated if you don't have a separate key as the machine ID is different) and it would become activated again when you native boot again but I'm not sure about that. Perhaps upgrading using Hyper-V with the virtual switch disconnected if you don't have a separate key for the Hyper-V VM would be wise.
    MIne is uefi. It is odd bcdboot works fine with a vhd created from an MRF image or disktovhd, but when I create a new smaller one and restore partition, it falls over. I am wondering if this is connected to the disk id in some way?

    Thinking about it, how does Hyper-v handle a vhd from a native boot? Aren't all the drivers mixed up or is it clever to change to hyper-v emulated drivers. More importantly, how does it work in reverse?
      My Computer


  8. Posts : 5,478
    2004
       #8

    cereberus said:
    MIne is uefi. It is odd bcdboot works fine with a vhd created from an MRF image or disktovhd, but when I create a new smaller one and restore partition, it falls over. I am wondering if this is connected to the disk id in some way?
    What matters is whether the vhd is formatted mbr or gpt.

    cereberus said:
    Thinking about it, how does Hyper-v handle a vhd from a native boot? Aren't all the drivers mixed up or is it clever to change to hyper-v emulated drivers. More importantly, how does it work in reverse?
    It works just the same as if you clean install windows or if you pull a real disk out of one PC and stick in another. When it boots the first time it says "Getting devices Ready"... With Hyper-V all the drivers already exist in the Windows image so you don't need to load any. If you do it the other way around (make a Hyper-V VM and then native boot it) you'll need to load your drivers for display, networking and what not.

    Are they mixed up? No, not really. If you boot both ways the drivers for your real hardware and for the virtual hardware are both installed. When you boot Windows it starts the drivers based on the hardware ID (something like PCI\VEN_blablabla) so it starts only the drivers for the hardware that it finds. This will be either real hardware (native boot) or virtual (Hyper-V). The other drivers are installed but not used so you lose a (small) amount of disk space but that is all. The "Getting devices ready" message only happens the once.

    Hope that makes sense..
      My Computer


  9. Posts : 15,444
    Windows10
    Thread Starter
       #9

    lx07 said:
    What matters is whether the vhd is formatted mbr or gpt.

    It works just the same as if you clean install windows or if you pull a real disk out of one PC and stick in another. When it boots the first time it says "Getting devices Ready"... With Hyper-V all the drivers already exist in the Windows image so you don't need to load any. If you do it the other way around (make a Hyper-V VM and then native boot it) you'll need to load your drivers for display, networking and what not.

    Are they mixed up? No, not really. If you boot both ways the drivers for your real hardware and for the virtual hardware are both installed. When you boot Windows it starts the drivers based on the hardware ID (something like PCI\VEN_blablabla) so it starts only the drivers for the hardware that it finds. This will be either real hardware (native boot) or virtual (Hyper-V). The other drivers are installed but not used so you lose a (small) amount of disk space but that is all. The "Getting devices ready" message only happens the once.

    Hope that makes sense..
    Re. vhd - I use gpt as uefi for sure.

    RE, drivers - that makes sense. Thinking about it that is sort of how wintousb works when you move a bootable usb drive to another PC (works fine for 8/10 but less so for 7 as its default drivers are getting quite long in the tooth now).

    I wonder if it would be so slick in vmware or virtualbox?
      My Computer


  10. Posts : 5,478
    2004
       #10

    cereberus said:
    I wonder if it would be so slick in vmware or virtualbox?
    I migrated a Windows 8 install from virtualbox to hyper-v and it worked fine simply by attaching the vhd to a new hyper-v vm. I had to re-activate it obviously. Not sure if you use Linux at all but Hyper-V drivers have been built into the kernel for the last few years also so it is similarly easy to move from virtual to actual hardware.

    Don't know about going the other way (i.e to VBox or VMware). I bet it would work - maybe I'll try it out when I have a bit of time.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 10:28.
Find Us




Windows 10 Forums