Steps to run a Windows machine on Ubuntu based Digital Ocean Droplet
Open the terminal and SSH into the droplet (VM1) using the below command. Replace the <VM1_IP> with the public IP assigned to your droplet.
$ ssh root@<VM1_IP>
After login to your droplet in Step 2, use the below commands and install the required packages
$ apt-get update && apt-get upgrade -y
$ apt-get install xfce4 firefox xrdp gzip -y
$ apt-get install qemu qemu-utils qemu-system-x86 -y
$ echo xfce4-session > ~/.xsession
$ reboot
In case of error while installing Qemu in the 3rd command, use the below command. Or Google it to get the similar command for installing that.
$ sudo apt-get install qemu-system-x86 qemu-utils qemu-kvm -y
– Linux: If you are using Linux in your host machine and you have Remmina application installed, then skip the below Remmina installation (next three) commands for Ubuntu. Otherwise first install Remmina using below commands (Below commands are for Ubuntu/Debian, you can find similar commands for your Linux distro):
$ sudo apt update
$ sudo apt install remmina
$ sudo apt install remmina remmina-plugin-rdp remmina-plugin-vnc remmina-plugin-secret
and then proceed with further steps for Linux.
root
, Password: VM1 password– Windows: If you are using Windows OS in your host machine, then simply follow below steps:
Open Remote Desktop Connection → Enter VM1 IP → Username: root
→ Click Connect.
In xrdp session, enter the Username: root
and Password: VM1 password
After login into the droplet, open the browser and download the following iso in the machine (it will be downloaded in /root/Downloads
). I am preferring Windows 10 Pro for this blog. You can download any Windows of your requirement. Also make sure your droplet VM1 (created in Part 1) should have that minimal requirements specifications (RAM and CPU) for your preferred Windows:
In case the download failing or any issue, close the RDP session and simply download these in your local PC. After downloading both in your local machine, follow next step.
If you are unable to download the files directly in the droplet in Step 5, you can download those iso files in your local PC and copy those into the droplet using below commands. The same commands will work for Windows users too. Replace the <VM1_IP> with your droplet public IP:
$ scp virtio-win-0.1.271.iso root@<VM1_IP>:/root/Downloads
$ scp Windows_10.iso root@<VM1_IP>:/root/Downloads
PS: This will take little longer based on your Internet Speed.
Open the terminal and SSH to your droplet (VM1) as done in Part 1 (Step 2). Run the below commands and create a virtual disk of the required size. This disk size will be the System Directory (Local Disk C) for installing Windows. You can give the required size as per the requirements for your preferred Windows you want to install. In my case I am installing Windows 10 Pro, where 80 GB
is good enough to install it. Later on, the extra storage remaining out of 120 GB can be used for creating new disk from the installed Windows in further steps.
$ cd Downloads
$ qemu-img create -f raw wins_harddisk.raw 80G
$ ls
Check whether that all the three files are in this Downloads directory:
To install Windows in this Virtual Hard Disk, run the Qemu Emulator using the below command. Replace the <windows.iso> and <virtio.iso> with the corresponding iso file names:
$ qemu-system-x86_64 \
-m 3000M \
-cpu host \
-enable-kvm \
-boot order=d \
-usbdevice tablet \
-drive file=wins_harddisk.raw,format=raw,if=virtio \
-drive file=/root/Downloads/<windows.iso>,media=cdrom \
-drive file=/root/Downloads/<virtio.iso>,media=cdrom \
-vnc :1
Note: You can see that I have used 3000M in above command, that represents I will be using 3000MB (out of 4GB) of RAM for QEMU to help me install Windows in that wins_harddisk.raw file. You have to be careful, for choosing this RAM size depends on your Windows version you are installing, as some part of RAM is also reserved by the droplet for itself. So, it may kill the running QEMU.
PS: This command will not print anything on the terminal, it will simply run without any output. But if you see warning or error as below. Simply ignore.
[W][07182.032853] pw.conf | [ conf.c: 1031 try_load_conf()] can't load config client.conf: No such file or directory
[E][07182.033604] pw.conf | [ conf.c: 1060 pw_conf_load_conf_for_context()] can't load config client.conf: No such file or directory
For,
<VM1_IP>:5901
→ Hit Enter<VM1_IP>:5901
→ Hit EnterReplace <VM1_IP> with public IP of the droplet. It will take some time to load the installation screen for proceeding with further installation steps. Keep checking in case Qemu which was running is still running. In case, it may be killed you have to rerun it with different RAM size. Qemu should be running till the complete installation and configuration of Windows in next few steps.
Follow the on screen steps and choose the Custom: Install Windows only (advanced) method and reach to the screen of disk creation. You will not see any disk over there. We have to first install few drivers and then we will get the empty wins harddisk 80 GB
which we created in previous step.
Click Load Driver
→ Click Browse → Enter the VirtIO CD (shown in SS) → Select Balloon
→ Select w10 (Select according to your version of windows you are installing) → Select amd64 → Click OK → Remove the check from Hide drivers that aren’t compatible with this computer’s hardware from the bottom.
→ select first path → Click Next to install
– Repeat this Step 9 for remaining drivers listed below from VirtIO CD:
Balloon
NetKVM
vioRNG
VioSCSI
VioStor
– After installing all the above drivers, the virtual disk will be displayed as shown below.
→ Select the disk → Click Next to install
→ Complete the installation and give a Username for your Windows machine and select a STRONG password (Use combination of alphabets, numbers, special symbols). Remember both the Username and Password.
PS: Strong Username and Password for Windows Machine will help protect from active scans and attacks.
After installing the Windows, configure the below settings:
Go to Start menu, and search Remote Desktop Settings (as in System Settings), hit Enter. Toggle it on.
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp
Login to the droplet using SSH as done in Part 1 (Step 2), in case you close the logged in SSH. Go to the Downloads folder where you have your wins_harddisk.raw file.
Compress the wins_harddisk.raw file and give a name as shown in below command. Give proper name for the .gz
file in the below command replacing
$ dd if=wins_harddisk.raw status=progress | gzip -c > <windows>.gz
Be patient, this will take time to complete.
.gz
the compressed file to Web DirectoryWe will use Apache to download this compressed disk file to the droplet where we want to install and run Windows.
$ apt install apache2
$ ufw allow 'Apache'
$ cp windows2010.gz /var/www/html/
Check if you are able to download the compressed Windows file using the below URl from any different PC. Replace <VM1_IP> and <windows> as per your VM1 IP and your compressed filename you have given in previous step respectively.
$ curl http://<VM1_IP>/<windows>.gz
You can preserve this file, store it in your local by downloading or any web location from where can easily download for later use anytime you want a Windows machine on Cloud. Because later on we are going to delete this droplet VM1.
This is crucial step where we are actually going to uncompress the .gz
windows disk and start using Windows.
Select the minimum requirements according to your Windows version you chose in previous step. Since I used Windows 10 Pro. The following specs was good enough for me to run it. The same steps to be followed as in Part 1 (Step 1) for creating droplet.
Press 6 to get bash prompt for Interactive Shell.
Check disk name:
Run the below command and check the disk name whether its vda or sda. In my case, its vda.
$ ls -la
$ lsblk
Download and write Windows disk:
Replace the <vda/sda> with vda or sda depends on you disk name.
$ wget -O- http://<VM1_IP>/windows2010.gz | gunzip | dd of=/dev/<vda/sda>
Be patient, sit back and relax! Its almost done. This step gonna take time in this new droplet VM2. When its done, close the console.
After the download finishes, you are done:
Switch back to Boot from Hard Drive
To configure internet in the Windows machine on droplet VM2, follow the below steps:
Go to Access tab and click Launch Recovery Console to open Windows in recovery mode.
Go to Internet Protocol Version 4 (TCP/IPv4) > Properties and give the IPs and Gateway manually, same as displayed at the bottom.
Note: You can keep the DNS same as shown in the SS. That is Google DNS IP 8.8.8.8 and alternate DNS as 8.8.4.4
ip:port
which you had configured for RDP on Windows Machine. Hit Enter.ip:port
which you had configured for RDP on your Windows Machine.Start using your Windows on the droplet VM2. You can preserve that windows10.gz file for later use and you can remove the droplet VM1 which you created in Part 1 for preparing Windows Disk.
Finally, we have successfully configured the Windows 10 on the Digital Ocean droplet from scratch. The same procedure can be followed for running any version of Windows.
Thank you and Stay tuned for more blogs