======================================= Windows Machine to VirtualBox VM ======================================= Convert a windows machine to a VirtualBox VM on FreeBSD --------------------------------------- 1. Download the guest additions iso version onto the host vboxmanage --version cd /export/iso wget https://download.virtualbox.org/virtualbox/6.1.50/VBoxGuestAdditions_6.1.50.iso 2. Download virtio drivers for windows # https://github.com/virtio-win/virtio-win-pkg-scripts/blob/master/README.md cd /export/iso wget https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso 3. Download Disk2vhd from microsoft and save it to the windows machine desktop # https://learn.microsoft.com/en-us/sysinternals/downloads/disk2vhd # Run Disk2vhd as administrator and select the drive to convert and save the .vhd # knowing the existing hardware setup of your working machine will help to set up the virtual machine # run as administrator # [ ] prepare for use in virtualpc # [ ] use vhdx # [x] use volume shadow copy # select all volumes on the disk 4. Copy the .vhd to your VirtualBox host machine and convert it to .vdi mkdir /export/vm/wino cd /export/vm/wino mv windows-pc.vhd . vboxmanage clonehd windows-pc.vhd wino-disk1.vdi --format VDI vboxmanage showmediuminfo wino-disk1.vdi 5. Create a vm using the windows disk .vdi and boot vboxmanage createvm --name wino --ostype Windows10_64 --register vboxmanage storagectl wino --name SATA --add sata vboxmanage storagectl wino --name IDE --add ide vboxmanage storageattach wino --storagectl SATA --port 0 --device 0 --type hdd --medium /export/vm/wino/wino-disk1.vdi vboxmanage storageattach wino --storagectl IDE --port 0 --device 0 --type dvddrive --medium /export/iso/VBoxGuestAdditions_6.1.50.iso vboxmanage modifyvm wino --nictype1 virtio --nic1 bridged --bridgeadapter1 igb0 vboxmanage modifyvm wino --memory 4096 --cpus 2 --vram 256 vboxmanage modifyvm wino --pae on --hwvirtex on --nestedpaging on --pagefusion on --apic on --acpi on --audio none --usb off vboxmanage modifyvm wino --vrde on --vrdemulticon off --vrdeport 5901 --vrdeproperty VNCPassword=secret_password vboxmanage startvm wino --type headless 6. Install guest additions # Connect to the vm with a vnc client aimed at your VirtualBox host machine ip and guest port # Open the CD and run VBoxWindowsAdditions and restart 7. Install virtio drivers vboxmanage storageattach wino --storagectl IDE --port 0 --device 0 --type dvddrive --medium /export/iso/virtio-win.iso # Open the CD and run setup 8. Now that you are done, Windows activation might start nagging you ======================================= If it does not boot then fixing boot might help --------------------------------------- # Download or create a bootable windows installer .iso and save it on the VirtualBox host machine # https://support.microsoft.com/en-us/windows/create-installation-media-for-windows-99a58364-8c02-206f-aa6f-40c3b507420d mv Win10_22H2_English_x64v1.iso /export/iso vboxmanage controlvm wino poweroff vboxmanage storageattach wino --storagectl IDE --port 0 --device 0 --type dvddrive --medium /export/iso/Win10_22H2_English_x64v1.iso vboxmanage startvm wino --type headless # quickly press any key to boot from cd # for newer windows with EFI shift+F10 open a command prompt when the Windows Setup screen appears diskpart run diskpart list vol identify the raw EFI system partition select vol # select the volume where # is the volume number format quick fs=fat32 label="System" format the volume exit quit diskpart bcdboot C:\Windows create the boot configuration where C is the drive letter # for older windows with MBR Repair your computer > Troubleshoot > Advanced options > Command prompt diskpart run diskpart to verify the partitions list disk select disk 0 list partition exit quit diskpart bootrec /fixmbr bootrec /fixboot bootrec /scanos bootrec /rebuildbcd chkdsk D: /f /r if the above has errors, do this where D is the drive letter, then try again bootsect /nt60 ALL /mbr if the above fails, try this ======================================= If it still does not boot then try changing the firmware to efi --------------------------------------- vboxmanage controlvm wino poweroff vboxmanage modifyvm wino --firmware efi vboxmanage startvm wino --type headless ======================================= End =======================================