Created
August 22, 2022 07:30
-
-
Save alexbodn/3cfdf1d56a9a0efbcadc7f34e1d6876a to your computer and use it in GitHub Desktop.
Revisions
-
alexbodn created this gist
Aug 22, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,162 @@ #!/bin/sh #first install linux (i like debian) and ensure you have 3 #bootable partitions, with the disk partitioned as mbr. #ext4 partition holding debian, with about 20GB free for downloads. #ntfs with at least 32GB to install windows in. #ntfs of about 32GB for preparing a bootable rescue disk. #the default partitioning mode is gpr, with one linux partition that #takes the whole disk. you may repartition the disk while booting a #rescue debian, and convert to mbr as explained here: #https://www.techwalla.com/articles/how-to-convert-gpt-to-mbr-on-linux. #i bought custom boot images space at contabo, and installed debian #from it's net iso media. the only special thing was giving your vps #ip as the ethernet address. #https://www.debian.org/CD/netinst/. installation_image=6 #pro menuentry_file=/etc/grub.d/45_custom #put here the foloowing 2 files: iso_loc=/usr/local/winfiles-dl #see full instructions at: https://pve.proxmox.com/wiki/Windows_VirtIO_Drivers, #and download the drivers iso at the link named "download the latest stable" on that page #of course, you may prefer "download the most recent" virtio_iso=${iso_loc}/virtio-win.iso #choose what to download in the browser at: #https://www.microsoft.com/en-us/software-download/windows10ISO #you'll get a temporary link and wget the iso in your VPS. win_iso=${iso_loc}/Win10_21H2_English_x64.iso tmp_wim=/tmp/wim subdir_virtio=${tmp_wim}/virtio wim_log=/tmp/wim-log win_mnt=/mnt wim_part_no=3 wim_device=/dev/sda${wim_part_no} eval $(blkid -o export ${wim_device}) wim_uuid=${UUID} win_part_no=2 win_device=/dev/sda${win_part_no} eval $(blkid -o export ${win_device}) win_uuid=${UUID} adddate() { while IFS= read -r line; do printf '%s %s\n' "$(date -u)" "$line"; done } virtio_wim() { echo "preparing ${1}.wim part ${2}" | tee -a ${wim_log} mkdir -p ${tmp_wim} wim_file=${win_mnt}/sources/${1}.wim wimlib-imagex mountrw ${wim_file} ${2} ${tmp_wim} echo "before:" | adddate >> ${wim_log} ls -l ${wim_file} | tee -a ${wim_log} du -s ${tmp_wim} | tee -a ${wim_log} # wiminfo ${wim_file} ${2} >> ${wim_log} mkdir -p ${subdir_virtio} 7z x ${virtio_iso} -o${subdir_virtio} echo "after:" | adddate >> ${wim_log} du -s ${tmp_wim} | tee -a ${wim_log} wimlib-imagex unmount ${tmp_wim} --commit ls -l ${wim_file} | tee -a ${wim_log} # wiminfo ${wim_file} ${2} >> ${wim_log} echo "------------------" | tee -a ${wim_log} } unpack_win() { echo "umount ${wim_device}" umount ${wim_device} echo "mkfs.ntfs ${wim_device} --fast" mkfs.ntfs ${wim_device} --fast echo "mount ${wim_device} ${win_mnt}" mount ${wim_device} ${win_mnt} echo "7z x ${win_iso} -o${win_mnt}" 7z x ${win_iso} -o${win_mnt} } grub_menuentry() { cat > ${menuentry_file} << EOM #!/bin/sh exec tail -n +3 \$0 # This file provides an easy way to add custom menu entries. Simply type the # menu entries you want to add after this comment. Be careful not to change # the 'exec tail' line above. menuentry 'Windows Recovery / Install (on ${wim_device})' --class windows --class os { insmod part_msdos insmod ntfs insmod ntldr set root='hd0,msdos${wim_part_no}' ntldr /bootmgr boot } menuentry "Windows 10" --class windows --class os { insmod part_msdos insmod fat if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root 7A03-CA46 else search --no-floppy --fs-uuid --set=root 7A03-CA46 fi chainloader /efi/Microsoft/Boot/bootmgfw.efi } menuentry "Windows 10" --class windows --class os $menuentry_id_option 'osprober-efi-' { insmod part_msdos insmod fat insmod ntfs set root='hd0,msdos2' # search --no-floppy --fs-uuid --set=root CE922B2D922B198B # chainloader /efi/Microsoft/Boot/bootmgfw.efi ntldr /bootmgr boot } EOM chmod +x ${menuentry_file} } rm -f ${wim_log} unpack_win virtio_wim "boot" 1 virtio_wim "boot" 2 virtio_wim "install" ${installation_image} grub_menuentry update-grub #grub-mkconfig #boot the vps from the windows menuentry. #start the installation. #when the program will ask for the installation media, #select the installation disk X:\virtio\amd64\w10, found and took scsi drivers. #continue the installation flavour, like the installation image above. #in the window with the partition selection, install in the 32GB ntfs partition above, #and additional drivers may be loaded. #load the X:\virtio\NetKVM and X:\virtio\Balloon \w10\amd64. #better explained here: https://pve.proxmox.com/wiki/Windows_10_guest_best_practices. #i should have installed qxl video drivers, will do that later. #windows will reboot, and let you continue the installation. #shut down windows and run debian rescue again, to reactivate the dual boot menu. #mount the first (linux) device: mount /dev/sda1 /mnt. #reinstall grub: #grub-install --directory=/mnt/usr/lib/grub/i386-pc --boot-directory=/mnt/boot /dev/sda #my solution was based on study of the following sources, though i wasn't able to apply, #due to my clumsiness: #https://erisa.dev/install-windows-on-a-contabo-vps/ #https://savepearlharbor.com/?p=294698 #https://www.whatuptime.com/community/technical-support/windows-10-on-contabo-ssd-vps/ #see another approach: #https://medium.com/@pistol.air32/running-windows-10-at-contabo-vps-1a0f6a82dfdb