Advertisement
LocalSt0arge

grubconf

May 4th, 2025
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.83 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. echo "=== GRUB CONFIGURATOR ==="
  4.  
  5. echo "Available disks and partitions:"
  6. lsblk
  7.  
  8. read -p "Enter the partition where Windows is installed (e.g., /dev/sda2): " win_partition
  9.  
  10. if [[ $EUID -ne 0 ]]; then
  11.     echo "This script must be run as root (use sudo)."
  12.     exit 1
  13. fi
  14.  
  15. echo "Removing old 'Install Windows from HDD' entry from GRUB..."
  16. sed -i '/menuentry "Install Windows from HDD"/,/^}/d' /etc/grub.d/40_custom
  17.  
  18. disk=$(echo "$win_partition" | sed 's/[0-9]//g')
  19. partition=$(echo "$win_partition" | sed 's/[^0-9]//g')
  20.  
  21. echo "Adding new Windows entry to GRUB..."
  22. cat >> /etc/grub.d/40_custom << EOF
  23.  
  24. menuentry "Windows" {
  25.     insmod ntfs
  26.     set root=(hd0,$partition)
  27.     chainloader +1
  28. }
  29. EOF
  30.  
  31. echo "Updating GRUB..."
  32. update-grub
  33.  
  34. echo "Done! Windows entry has been added. Please reboot to apply changes."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement