IGNORE THIS POST: OCI now officially supports exporting Windows Instances, so you no longer need to do any of this trickery 🙂
Most instances (VMs and Bare Metal) can be exported, so that they can be copied/transferred to other regions or other Cloud Accounts. One type of instance does not support this, these are the instances created based on Oracle provided Windows. This has to do with the licensing deal between Oracle and VMware. So is it really not possible to move you your Windows VMs??? Of course you can 🙂 Here is a method on how to move / copy / duplicate your Windows instances between regions / tenants.
Prepare the destination:
Create on the destination, where you want to move your Windows VM to, a new Windows Instance. After it is provisioned, stop the instance and wait for the instance to be stopped. Go to the Boot Volume and Detach the boot disk from the Instance Create a (temporary) Linux VM on the destination side, I tested this with Ubuntu 18.04. Make sure the Linux VM is in the same Availability Domain as the Destination Windows VM. Goto attached block volumes on the Destination Linux VM and add the Destination Windows Boot disk, as paravirtualized and with read/write permissions.
Prepare the source:
Stop the Original Windows VM you wan to move. When it is stopped, also detach it’s boot volume. Create also on the source side a Linux VM and attach the Original Windows boot volume to this VM as paravirtualized, but you can give it just READ ONLY permission (to be on the safe side).
Block level copying:
Open a SSH / Putty session to both source and destination Linux VMs. The default username is: ubuntu We are going to use the linux dd command to copy over the source disk, block by block (very low level) and overwrite the destination disk. This is done over the network, so this can be done to anywhere you like. While the dd command is very powerful, it’s “interface” is pretty shitty as there is no displayed output. I do like to know what is going on, so we need to install a small utility called pv. Run the following commands in both your Linux VMs:
sudo apt install pv
There are a few options on how we can send over the data. You can use SSH, which is slow but encrypted or use Netcat which is fast but unencrypted. Here an interesting blog post about the difference between the 2 options: https://www.ndchost.com/wiki/server-administration/netcat-over-ssh Below the example of using Netcat. You can use any port number for the traffic, just make sure you modify your security list for the destination target, that is allows that port as incoming traffic. In my example, I will use port 1900. Important: also disable the firewall inside the Destination Linux VM by running the command:
sudo iptables -F
Now we start NetCat listening on the Destination Linux VM:
nc -l 1900 | pv | sudo dd of=/dev/sdb bs=100M
Then we start the copying process on the Source Linux VM:
sudo dd if=/dev/sdb bs=100M | pv | nc 184.108.40.206 1900
Depending on the size of the Boot disk and the speed of the public internet, this can take “some time”.
f you are worried about your ssh session disconnecting during the transfer, you can first run the command screen in both sessions. The Netcat session will stay for ever, so you need to stop is manually by control-C when you see that the transfer is done. All you need to do, to complete this operation: Stop the linux VMs and detach the Attached boot volumes Re-attach the Windows Boot disks to the Windows instances. The new Windows instance will now be an exact copy of the orginal Windows instance. This method leaves you with a “new” official OCI Windows VM, that has the contents of your source VM. It runs in the same native mode and you will still be paying for a Windows VM.