Moving Windows to a Virtualbox

Is anyone aware of a guide for moving Windows to a Virtualbox running under FreeBSD?

I want to do this on a ThinkPad X220 which has 8GB ram and is running Windows 7 on a 256GB mSata disk.

Here are the steps I think I need to perform...

1. Backup the disk using Clonezilla

2. Delete as much as I can from the current Windows installation

3. Backup the disk using Clonezilla again (in case I've deleted too much)

4. Shrink the current Windows partition as much as possible.

5. Create a Windows VHD (or whatever I need to load Windows in a Virtualbox)

6. Install FreeBSD on the mSata disk

7. Install all the required pkgs in FreeBSD

8. Run Virtualbox

9. Setup Vitualbox to run Windows

I'm a bit hazy about the specifics of some of these tasks, but have I missed anything out?

Any comments would be appreciated.
 
If I'm right VMWare has a tool to convert a fully functional Windows on physical hardware to virtual machine. You could search and try it.
 
Can I download a copy of VMware Workstation? And what do I run it on? Is it available for FreeBSD?
 
Since you haven't decided yet...
2.5 years ago I stopped using VirtualBox and completely switched to bhyve(8). I'm running a Windows domain workstation (Win7) in a corporate environment 24/7. Everything is fast and smooth. The only thing which is not implemented yet is the USB device pass-through. However, mass storage device can be easily mapped via xfreerdp(1) client.
The migration from physical to virtual was straight forward with sysprep (Windows command), you may not need it (I switched the host hardware). The physical disk image created with dd(1) can be used directly. Of course, you can shrink Windows partition before dd using the standard MS Disk Manager.
 
I'll have to have a good look at bhyve(8) - it's something I've never investigated. Thanks for suggesting it.

Is there a useful guide for setting it up?
 
Is that GUI based or CLI based? I get the impression its CLI based.
Yes, your impression is correct. It's a command line tool. Really easy to use though.
Is there a great GUI based bhyve manager?
The only one I can think of is sysutils/cbsd. I tried it a long time ago and it was rather tricky to set up. This may have been improved now though, it was a really long time ago. For me a simple command line tool suffices for my purposes.
 
It depends, Virtualbox does have a nice GUI and works really well. Bhyve is nice too as it's FreeBSD's own hypervisor. Why don't you try them both? Note however that you cannot use them simultanously.

I'm personally quite happy with bhyve, it's been running on an older dual Xeon Supermicro and I now have a number of VMs running (all FreeBSD) running a variety of services to play with (Gitlab, Zabbix, ElasticSearch/Kibana, Puppet).
 
One thing I'm not sure about is whether I should backup the whole Windows disk (ada1) or the two Windows partitions (ada1s1 & ada1s2) ..

Code:
root@S09:/mnt/ntfs# gpart show ada1
=>       63  500118129  ada1  MBR  (238G)
         63       1985        - free -  (993K)
       2048     204800     1  ntfs  (100M)
     206848  499908608     2  ntfs  [active]  (238G)
  500115456       2736        - free -  (1.3M)
 
You should copy the whole disk, the other partition is probably the recovery partition. A VM is, for all intents and purposes, exactly the same as a "real" machine.
 
I tried following the guide suggested by scottro

https://github.com/churchers/vm-bhyve/wiki/Quickstart

I rebooted after step 4 to see if my /etc/rc.conf entries were OK but got a boot up error:-

vmx_init: VMX operation disabled by BIOS
module_register_init: MOD_LOAD (vmm, 0xffffffff82a51a50, 0) error 6

I'm trying this on a Lenovo ThinkPad T500, so am hoping I recognise the correct options in BIOS. Does anyone know exactly what I should be looking for?
 
You definitely need the vmx_init. That is what is needed for any virtual guest. (that is if it was running Linux and you wanted KVM, or if you use VirtualBox, VMWare or any of the forms of virtualization.

I'm afraid I don't know where it would be on your laptop but there should, be if you go through the menu, a section on virtualization that is usually disabled by default. You have to change its no to yes or enabled or whatever the menu says. On my yoga2 which *might* be similar, but I really don't know, it's under Configuration=>Intel Virtual Technology. Hit the space bar to focus, hit enter (you may just need that and not bother with the space bar, and choose enabled.
Again that's on a yoga2 also made by Lenovo but no idea how similar or dissimilar the BIOS'S are.
 
You may also want to research your CPU as not all are capable of virtualization regardless of the BIOS options, just to be sure.... While I can't remember which CPU/motherboard combo I had at the time, the motherboard BIOS had the options for virtualization, the CPU did not...
 
I couldn't find any way to make my ThinkPad T500 work, but eventually found the required option in the BIOS of my X1 Carbon and have now ticked off steps 5 and 6 in this list:-

Code:
1. pkg install vm-bhyve [grub2-bhyve uefi-edk2-bhyve]
2. zfs create pool/vm
3. sysrc vm_enable="YES"
4. sysrc vm_dir="zfs:pool/vm"
5. vm init
6. cp /usr/local/share/examples/vm-bhyve/* /mountpoint/for/pool/vm/.templates/
7. vm switch create public
8. vm switch add public em0
9. vm iso ftp://ftp.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/10.3/FreeBSD-10.3-RELEASE-amd64-bootonly.iso
10. vm create myguest
11. vm [-f] install myguest FreeBSD-10.3-RELEASE-amd64-bootonly.iso
12. vm console myguest

My ethernet interface is ue1 and I'm hoping to use windows.img as a guest. I have this file on another disk so am not sure how to proceed from here step 6.
 
Is there a great GUI based bhyve manager?
Why yes there is.
deskutils/virt-manager
The setup method is different as it uses devel/libvirt and its XML format.
So if you have existing VM configs they have to be converted to XML.
If new to bhyve VM's then you simply need to buff up on libvirt.
 
I couldn't find any way to make my ThinkPad T500 work, but eventually found the required option in the BIOS of my X1 Carbon and have now ticked off steps 5 and 6 in this list:-

Code:
1. pkg install vm-bhyve [grub2-bhyve uefi-edk2-bhyve]
2. zfs create pool/vm
3. sysrc vm_enable="YES"
4. sysrc vm_dir="zfs:pool/vm"
5. vm init
6. cp /usr/local/share/examples/vm-bhyve/* /mountpoint/for/pool/vm/.templates/
7. vm switch create public
8. vm switch add public em0
9. vm iso ftp://ftp.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/10.3/FreeBSD-10.3-RELEASE-amd64-bootonly.iso
10. vm create myguest
11. vm [-f] install myguest FreeBSD-10.3-RELEASE-amd64-bootonly.iso
12. vm console myguest

My ethernet interface is ue1 and I'm hoping to use windows.img as a guest. I have this file on another disk so am not sure how to proceed from here step 6.

Well I managed to get to step 12 and have booted up a boot-only installation image of FreeBSD but have no idea what to do with it.

How do I go about booting from my Windows image file?
 
Usually you have to be quick to hit f12 after reboot. It should use the disk you select. For example, the new F12 disk or the old Windows disk.
 
Usually you have to be quick to hit f12 after reboot. It should use the disk you select. For example, the new F12 disk or the old Windows disk.

Not sure I understand... What would I need to do install a Windows image? I'm talking about steps 9, 11 in the instructions you provided.
 
I'm a bit confused myself now. When you are booting, if you have an available disk, if you hit F12, said disk should be visible in the menu.

But I don't believe I have ever done what you are doing that is move Windows to VirtualBox. It is possible that you 'd receive better help from the VirtualBox forums, as I haven't done, and don't know how to do what you're trying to accomplish.
 
Back
Top