VM running from portable drive


  1. Posts : 18,433
    Windows 11 Pro
       #1

    VM running from portable drive


    Just for fun, I wanted to see if I could run a VM from a portable drive with a "Windows To Go" install on it. So this is what I did:
    I have an M.2 NVMe SSD drive in a USB-C enclosure. I partitioned the drive as MBR, created a 100 MB FAT32 partition on it marked as active, followed by an NTFS partition filling the rest of the drive. Apply a Windows 10 image to the NTFS partition using DSM (I chose Windows 10 Pro but any edition of Windows 10 should work). Then used the bcdboot command to write the boot files for both UEFI and BIOS to the FAT32 partition. This drive is now bootable on both UEFI and legacy BIOS computers, and I can boot directly into it and run it from the USB SSD.

    Then I ran the diskpart offline disk command on the drive to take it offline.

    Then create your standard Generation 2 (probably Generation 1 would work too) VM in Hyper-V, but when it asks for a Virtual Hard Drive, select the option to add one later. After the VM is created, go back to settings for it, and select the SCSI controller and add a hard disk to it - this is where you can now select your USB drive as long as it is offline in Windows. Go up to the firmware settings and move the new hard drive entry to the top of the list. Turn off all checkpoints. VIOLA, the VM will boot from and use the Windows installed to the SSD, without any .vhdx file at all!

    I can't think of any real use for this, but a neat experiment, IMHO.
      My Computer


  2. Posts : 15,499
    Windows10
       #2

    NavyLCDR said:
    Just for fun, I wanted to see if I could run a VM from a portable drive with a "Windows To Go" install on it. So this is what I did:
    I have an M.2 NVMe SSD drive in a USB-C enclosure. I partitioned the drive as MBR, created a 100 MB FAT32 partition on it marked as active, followed by an NTFS partition filling the rest of the drive. Apply a Windows 10 image to the NTFS partition using DSM (I chose Windows 10 Pro but any edition of Windows 10 should work). Then used the bcdboot command to write the boot files for both UEFI and BIOS to the FAT32 partition. This drive is now bootable on both UEFI and legacy BIOS computers, and I can boot directly into it and run it from the USB SSD.

    Then I ran the diskpart offline disk command on the drive to take it offline.

    Then create your standard Generation 2 (probably Generation 1 would work too) VM in Hyper-V, but when it asks for a Virtual Hard Drive, select the option to add one later. After the VM is created, go back to settings for it, and select the SCSI controller and add a hard disk to it - this is where you can now select your USB drive as long as it is offline in Windows. Go up to the firmware settings and move the new hard drive entry to the top of the list. Turn off all checkpoints. VIOLA, the VM will boot from and use the Windows installed to the SSD, without any .vhdx file at all!

    I can't think of any real use for this, but a neat experiment, IMHO.
    One use is to install Insider versions as WTG. Only problem is you cannot upgrade vhds from Host Windows ut yiu can when attached in HyperV.

    I had been doing this for several years now and then. It used to be easy and free using wintousb to install in a vhd on a USB drive but now they charge for it.

    Rufus will create a WTG drive but not sure how to install in a VHD. I guess it is a case of creating vhd, then mounting that and installing there.

    I have a script of installing OS to vhds and would like to extend it to a usb drive install.

    Can you provide the exact bcd commands you used?

    Edit - just reread post. Is WTG in a vhd on USB drive. If so, you can easily attach it to HyperV. Gen 1 is easier.

    I see what you have done i.e. you are directly booting from usb drive by going offline.
      My Computer


  3. Posts : 18,433
    Windows 11 Pro
    Thread Starter
       #3

    Correct, there is no vhd file at all. The USB SSD contains two partitions - a FAT32 system partition followed by an NTFS partition containing a full Windows install on it. So, I can either boot the computer directly from the USB SSD, or I can boot a VM from the USB SSD. I was just experimenting to verify that you can run a VM that uses a physical drive and it isn't limited to only virtual drives.
      My Computer


  4. Posts : 31,692
    10 Home x64 (22H2) (10 Pro on 2nd pc)
       #4

    NavyLCDR said:
    ...I can't think of any real use for this, but a neat experiment, IMHO.
    NavyLCDR said:
    ...I was just experimenting to verify that you can run a VM that uses a physical drive and it isn't limited to only virtual drives.

    Neat trick

    I can't think of a use for it either, but I regularly go to the other extreme - running a Hyper-V VM that has its parent virtual drive located on a virtual drive.

    All my machines have a Macrium image on an internal D: data partition for convenience. For security I then make a Macrium image of the whole machine including the Data drive to an external HDD.

    Sometimes I can't be bothered to physically restore one of my Test Machine's images, so I mount the Macrium image of its Data drive as a virtual drive then use viBoot to run one of the images from it as a VM.
      My Computers


  5. Posts : 15,499
    Windows10
       #5

    NavyLCDR said:
    Correct, there is no vhd file at all. The USB SSD contains two partitions - a FAT32 system partition followed by an NTFS partition containing a full Windows install on it. So, I can either boot the computer directly from the USB SSD, or I can boot a VM from the USB SSD. I was just experimenting to verify that you can run a VM that uses a physical drive and it isn't limited to only virtual drives.
    You can most certainly boot from physical drives in HyperV. I have never tried booting from a usb drive directly.

    However, unless in enhanced mode, you have to take a drive offline to access it.

    Right now I am trying to install WTG on a vhd on usb drive as an experiment using Rufus.
      My Computer


  6. Posts : 18,433
    Windows 11 Pro
    Thread Starter
       #6

    cereberus said:
    You can most certainly boot from physical drives in HyperV. I have never tried booting from a usb drive directly.

    However, unless in enhanced mode, you have to take a drive offline to access it.

    Right now I am trying to install WTG on a vhd on usb drive as an experiment using Rufus.
    I would think the process would be the same without Rufus.

    1. Create a 100 MB (or so) system partition on the USB drive. Assign it a drive letter such as S:.
    2. Create an NTFS partition on the remainder of the drive (or however big you need it to be). Give it a temp drive letter like Z:.
    3. Create the VHD/VHDX file in the NTFS partition on the USB drive.
    4. Mount the VHD/VHDX file as a virtual drive, I used diskpart. Create an NTFS partition, format it and give it a drive letter such as T:.
    5. Using DISM, apply a Windows 10 image to the virtual drive from a Windows ISO file.
    6. Use the bcdboot command to write the boot files. Given the drive letters in steps 1 and 4, the command would be:
    bcdboot T:\Windows /s S: /f ALL.

    That should do it, I would think.
      My Computer


  7. Posts : 15,499
    Windows10
       #7

    NavyLCDR said:
    I would think the process would be the same without Rufus.

    1. Create a 100 MB (or so) system partition on the USB drive. Assign it a drive letter such as S:.
    2. Create an NTFS partition on the remainder of the drive (or however big you need it to be). Give it a temp drive letter like Z:.
    3. Create the VHD/VHDX file in the NTFS partition on the USB drive.
    4. Mount the VHD/VHDX file as a virtual drive, I used diskpart. Create an NTFS partition, format it and give it a drive letter such as T:.
    5. Using DISM, apply a Windows 10 image to the virtual drive from a Windows ISO file.
    6. Use the bcdboot command to write the boot files. Given the drive letters in steps 1 and 4, the command would be:
    bcdboot T:\Windows /s S: /f ALL.

    That should do it, I would think.
    Yeah. I did this a couple of years ago like this - thanks.

    Rufus fell over but I did not work that hard at doing it.

    Interestingly, wintousb now have a free WTG version again BUT will only install Home not Pro.

    The free version will install to a vhd but not vhdx but this is not that important (unless really huge).

    However, I think I should then be able to upgrade to Pro using a generic key as my mobo already has a digital licence for Pro.

    (Let's not get into a discussion over EULA terms for activation of a WTG drive - I am only trying to do proof of concept).
      My Computer


  8. Posts : 11,247
    Windows / Linux : Arch Linux
       #8

    Hi folks
    Most VM systems allow the use of "Physical drives"

    for example on a USB WTG type of thing (actually these WTG things are great if you want different languages etc for your Windows system without having to change main or work computers stuff) I have a Linux VM with 4 "physical" HDD's . I'm running from a standard SSD connected to USB 3.1 port via SATA->USB adapter.

    VM running from portable drive-vma.png

    Using the OS's own file system especially if you can pass thru the device / hardware to the OS is far better than using "paravirtulised I/O". The main reason that paravirtualised hardware is used primarily in VM's is that you can run a load of different VM's running various different OS's on the same host concurrently using standard shared host hardware -- allocating pass thru devices to the VM of course means that the hardware is only available to that particular VM.

    If you have the hardware then it's the best way to run VM's --you can get with some systems almost near native performance --you must have though dedicated HDD/SSD, and graphics - a 2nd port on a graphics card is good enough for pass thru. Networking shouldn't be a problem though as a network card can be shared quite efficiently although if you do have a separate ethernet port then no problem again in using it.

    Note also latest version of VMWare allows you to specify NVMe drives as virtual disks - if you have a bog standard SSD then using the NVMe version also works better !!!

    VM running from portable drive-nvme.png

    @cereberus -- performance of a decent WTG running Windows 10 Workstation pro (latest dev build) through USB 3.1 SATA-adapter on SSD is almost as good as the host windows on the machine !!!! I've some spare licenses so activation isn't an issue -- but confirming your POC is fine --works very well indeed.

    I've done the same thing also with a Linux OS running a Windows VM --also very good -- this method is actually easier because Linux can boot from USB devices and of course the OS is free. Response times in this case also excellent (Windows running on KVM/QEMU).

    My problem with HYPER-V is decent remote access to the VM -- RDP is terrible and a HYPER-V VM doesn't seem to like things like tight / tiger VNC. Perhaps those using HYPER-V have some decent suggestions for access remotely to a VM with other than RDP. Putty / SSH perhaps looks a good bet or to create some sort of private VPN.

    With LAN and Internet speeds of up to 10Gb/s I shouldn't have to put up with the hideously slow screen performance of RDP !!!! there must be faster ways to run remote VM's with HYPER-V.

    Cheers
    jimbo
    Last edited by jimbo45; 02 Aug 2020 at 03:01.
      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 20:20.
Find Us




Windows 10 Forums