Skip to content

Instantly share code, notes, and snippets.

@bre7
Last active March 22, 2024 23:07
Show Gist options
  • Save bre7/0be8dafe4fb5f78318db8cf33799b30f to your computer and use it in GitHub Desktop.
Save bre7/0be8dafe4fb5f78318db8cf33799b30f to your computer and use it in GitHub Desktop.
VirtualBox - Creating virtual machine from physical machine (Windows 10)

Creating virtual machine from physical hard drive partition

  1. Use Disk2Vhd and create a VHD for the partition you want to convert. (If using VirtualBox, disable Vhdx option)

  2. Open Windows 10's native Disk Management tool (Run > diskmgmt.msc). Attach VHD (Action > Attach VHD).

  3. Convert to MBR Disk using AOMEI Partition Assistant Demo (if there's another way please post a comment)

  4. Detach VHD

  5. Once done, create a new VM in VirtualBox and select the newly created VHD

  6. Attach a Windows 10 ISO (use the Media Creation Tool to create it) to the VM

  7. Turn on VM and boot ISO

  8. Select Repair your computer and then Command Prompt

  9. Run the following commands:

diskpart
list disk
select disk 0
list partition
select partition 1
active
exit

In my case there was only 1 disk and partition.

  1. Run the following commands:

bootrec /fixmbr (this command will fix MBR)

bootrec /fixboot (this command will fix boot sector)

bootrec /scanos (this will scan for Windows installations to add)

If fixboot replied with the error Access denied, then run the following command:

bcdboot C:\windows
  1. Reboot and enjoy your fixed VM !

PRs welcome for fixes & improvements !!!1!


SEO:

  • Create virtual machine from installed Windows 10
  • Fix "Fatal: INT18: Boot failure"
  • Fix fixboot access denied

Sources:

  1. https://www.veeam.com/blog/how-to-convert-physical-machine-hyper-v-virtual-machine-disk2vhd.html
  2. https://www.diskpart.com/articles/convert-vhdx-gpt-to-mbr-4125.html
  3. https://superuser.com/a/1303238/940718
  4. https://social.technet.microsoft.com/Forums/en-US/7262c702-ce37-4853-9a12-5cafcf10342e/disk2vhd-efi-vhdx-vm-fails-to-boot-solved?forum=winserverhyperv
  5. https://forums.virtualbox.org/viewtopic.php?f=2&t=86038#p409915
@bre7
Copy link
Author

bre7 commented Oct 9, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment