Advertisement
LocalSt0arge

wininstall

May 4th, 2025
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.12 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. echo "=== WINDOWS ISO INSTALLER FOR LINUX BY CHATGPT, ROMAN AMOGUS ==="
  4.  
  5. echo "Available disks and partitions:"
  6. lsblk
  7.  
  8. read -p "Enter the FULL path to the Windows ISO: " iso_path
  9. read -p "Enter the device/partition where Windows should be installed (e.g., /dev/sda2): " win_partition
  10. read -p "Enter the disk where GRUB should be installed (e.g., /dev/sda): " grub_disk
  11.  
  12. if [[ $EUID -ne 0 ]]; then
  13.     echo "This script must be run as root (use sudo)."
  14.     exit 1
  15. fi
  16.  
  17. echo "Mounting ISO and partition..."
  18. mkdir -p /mnt/winiso /mnt/winpart
  19.  
  20. mount "$iso_path" /mnt/winiso
  21. mount "$win_partition" /mnt/winpart
  22.  
  23. echo "Copying ISO contents to the Windows partition..."
  24. cp -rT /mnt/winiso /mnt/winpart
  25.  
  26. echo "Installing GRUB to disk $grub_disk..."
  27. grub-install --target=i386-pc "$grub_disk"
  28. update-grub
  29.  
  30. echo "Adding Windows installer entry to GRUB..."
  31. cat >> /etc/grub.d/40_custom << EOF
  32.  
  33. menuentry "Install Windows from HDD" {
  34.     insmod ntfs
  35.     search --no-floppy --file /bootmgr --set=root
  36.     chainloader +1
  37. }
  38. EOF
  39.  
  40. update-grub
  41.  
  42. echo "Done! Reboot and select 'Install Windows from HDD' in GRUB."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement