forked from brianmok888/Windows-Server-Contabo-VPS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindows-install.sh
More file actions
93 lines (56 loc) · 1.74 KB
/
Copy pathwindows-install.sh
File metadata and controls
93 lines (56 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
apt update -y && apt upgrade -y
apt install grub2 wimtools ntfs-3g -y
#Get the disk size in GB and convert to MB
disk_size_gb=$(parted /dev/sda --script print | awk '/^Disk \/dev\/sda:/ {print int($3)}')
disk_size_mb=$((disk_size_gb * 1024))
#Calculate partition size (25% of total size)
part_size_mb=$((disk_size_mb / 4))
#Create GPT partition table
parted /dev/sda --script -- mklabel gpt
#Create two partitions
parted /dev/sda --script -- mkpart primary ntfs 1MB ${part_size_mb}MB
parted /dev/sda --script -- mkpart primary ntfs ${part_size_mb}MB $((2 * part_size_mb))MB
#Inform kernel of partition table changes
partprobe /dev/sda
sleep 30
partprobe /dev/sda
sleep 30
partprobe /dev/sda
sleep 30
#Format the partitions
mkfs.ntfs -f /dev/sda1
mkfs.ntfs -f /dev/sda2
echo "NTFS partitions created"
echo -e "r\ng\np\nw\nY\n" | gdisk /dev/sda
mount /dev/sda1 /mnt
#Prepare directory for the Windows disk
cd ~
mkdir windisk
mount /dev/sda2 windisk
grub-install --root-directory=/mnt /dev/sda
#Edit GRUB configuration
cd /mnt/boot/grub
cat <<EOF > grub.cfg
menuentry "windows installer" {
insmod ntfs
search --set=root --file=/bootmgr
ntldr /bootmgr
boot
}
EOF
cd /root/windisk
mkdir winfile
wget -O win10.iso --user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" https://bit.ly/4aCjkM2
mount -o loop win10.iso winfile
rsync -avz --progress winfile/* /mnt
umount winfile
wget -O virtio.iso https://bit.ly/4d1g7Ht
mount -o loop virtio.iso winfile
mkdir /mnt/sources/virtio
rsync -avz --progress winfile/* /mnt/sources/virtio
cd /mnt/sources
touch cmd.txt
echo 'add virtio /virtio_drivers' >> cmd.txt
wimlib-imagex update boot.wim 2 < cmd.txt
reboot