[Script] Automatically Install Windows Server into Linux VPS/Server using Shell script

Status
Not open for further replies.

sohom

Active Member
1,206
2012
411
520
Open Source Github Project/Repository URL :
https://github.com/mediabots/Linux-to-Windows-with-QEMU

A Shell Script for Auto installation of Windows Server into a Linux Server.

A Shell Script to Auto install Windows Server on your Linux System. [Right now, it supports 2012 R2 < evaluation/180 days trial > copy]

Script would use QEMU-KVM portable software for Virtualization purpose. Since QEMU is a portable s/w, so it can reside in temporary RAM.

Actually script is semi-automatic. All Linux commands part(such as downloading Windows ISO image, gathering system info, choosing disk/partition, managing RAM , attaching required windows s/w in CDROM) would be handled by script automatically.

And rest of the windows part(clicking, selecting, setting Administrator password ) need to be done manually by any Free VNC windows software.

After Windows Installation completed, you would find a Power Shell script under CD-ROM, called "EnableRDP.ps1". By running it you would be able to enable Remote Desktop on your Windows server, so after that you would be able to connect your Windows server through Windows "Remote Desktop Application" App :)

I also attached Firefox App on CD-ROM, install that, so you don't need to face "Internet Explorer" horrible setting experience!


Requirements


A SSH client such as Putty : https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

A VNC software such as RealVNC : https://www.realvnc.com/en/connect/download/viewer/

A VPS or Dedicated server with Ubuntu OS Installed.

At least 30GB Free disk space in your system.

Virtualization of your VPS or Server must be enabled. Run below coammnd :

Code:
echo $(egrep '^flags.*(vmx|svm)' /proc/cpuinfo | wc -l)

if output is greater than 0, then Virtualization is enabled :D

Either should have access of root user OR run with su (super user)

How to Run the Script

Just run below five commands one after another :
Code:
su

mkdir /media/script && mount -t tmpfs -o size=1m tmpfs /media/script

wget -P /media/script https://raw.githubusercontent.com/mediabots/Linux-to-Windows-with-QEMU/master/mediabots_Ubuntu-to-Windows.sh

chmod +x /media/script/*

/media/script/mediabots_Ubuntu-to-Windows.sh

Screen-shots step by step

1) Download Putty(SSH client) from here : https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
2) Run Putty.exe file and connect to your Linux Server IP address (with port 22)
lPVhvhm.png

Login with your Linux Server Credential.
3) Run the Script. [ Read -> "How to Run the Script" section of this topic ]
KGejlQu.png

4) If your Server/VPS RAM size > 5 GB
Script would ask , whether you would like to delete existing Linux OS or not
-> I opted for [No]
LFwowrx.png

Script has done its work
5) now Download & install VNC [ https://www.realvnc.com/en/connect/download/viewer/ ]
and open your VPS/Server IP with port 0
Tc6NAGt.png

in my case my VPS IP was 51.15.229.233
4) Now you would see, Windows installation is on the process
k2tLHAR.png

5) Click/Choose options which I highlighted
5m02t3j.png

mpixbrf.png

Choose "Windows Server 2012 R2 SE (with GUI)"
Qk8W93v.png

yllbhw7.png

PRydybd.png

eksRoWZ.png

KOdQxNn.png

Set password for user : Administrator
Create a 16 to 20 Character long strong password
VsEPiSI.png

dLJze9n.png

login to Windows Server with your password
v9zWnwj.png

tR6CXfk.png

Windows Server installed successfully :D
W7olVM3.png

Enable Remote Desktop through ebableRDP.ps1 power shell script
Also install Firefox for browsing
TXKbKTX.png

In case .ps1 script prompt like this
BT2bQOz.png

press Y and Enter
---
Job Done :)
Enjoy
-------------------------------------------------------

Demo Video



or

https://bit.ly/Linux-to-Windows

Disclaimer

For few cases, due to RAID configuration of the hard disk, if you had chosen to delete existing Linux OS & install Windows OS on entire hard disk. On your VNC , you might see, Windows installation failing.

If you are facing such issue; Exit from the script & Re-run it & in this time just opt for installing Windows OS without deleting Linux OS. And it would work :D

In case, portable QEMU-KVM app stopped/closed, your Widows-Server would not be accessible. To access it again, you require to run the QEMU-KVM app again with proper parameters.

Run below command :

Code:
cat /details.txt

Copy the Output of the above result and Paste it & press Enter button. It would run the QEMU-KVM again. So your Windows Server would be accessible again :D

If you required a reboot of your Windows Server, just reboot it from Windows Server reboot option. Don't reboot your server from Server Hosting Control-panel. Otherwise QEMU App would get stopped.

If you had opted for removing your old Linux OS, you would get Windows server with full HDD capacity. But RAM would not be full, because QEMU resides on RAM.

Updates

Right now, Script supporting Ubuntu Distro only.

But very soon I would add the support for all popular Linux Distros too.

So stay tuned.

--
Hope you guys like it.
If you are a developer, you are welcome to contribute in the project

Feel free to ask any question

Don't forget to share your thoughts

Thank you
 
Last edited:
3 comments
How Script works?

CASE - 1

Your Server/VPS Free RAM size > 5 GB

If your system comes with more than 5GB free RAM, script would ask, whether do you want to delete your existing Linux OS(Ubuntu in this case).

Go with that option only if "Rescue Boot" option is available in your Server Hosting Control-panel.

Case - 1.a

Suppose you proceed with that option, in that case, script would download Windows-ISO image & other stuffs in your system RAM.

Case - 1.b

Suppose you dont go with that option.

Script would first check, how many Disk are attached with your VPS/Server.

Case - 1.b.i

If there are multi Disk.

Winodws-OS would be installed on your second Disk.

Case - 1.b.ii

If only one Disk attached, then it would check how many partitions(size > 25 GB) are present there.

If there are multi partitons(size > 25 GB). Windows-OS would be installed on second partition.

Else

If only one partion exist, and that partition has more than 30 GB free space. In that case ,it would create a "disk.img" file of 25 GB size for installing Windows-OS on that file.

CASE - 2

Your Server/VPS Free RAM size < 5 GB

start from <Case - 1.b>



---

Best Regards
 
**UPDATE**

CentOS Distro support added (tested on CentOS 7.4 , CenstOS 7.6)

So this Script is working for Linux Distros : Ubuntu,Debian, CnetOS :)

I also linked a fast(1Gbps) Windows server ISO image url into the script, so 4.2 GB would be downloaded within few minutes :D

[Note]
Since I got portable version of "QEMU-KVM" only for Ubuntu.
So if you had opted for completely deleting existing Linux OS, it would work only on Ubuntu.

Regards
 
Status
Not open for further replies.
Back
Top