Skip to content

Instantly share code, notes, and snippets.

@yrps
Created August 10, 2014 08:00
Show Gist options
  • Save yrps/d68aab09da99b6505172 to your computer and use it in GitHub Desktop.
Save yrps/d68aab09da99b6505172 to your computer and use it in GitHub Desktop.
bash script for Pete
#!/bin/bash
# script to set the default boot partition to Windows
# intended for Fedora20 with Grub2
# https://ask.fedoraproject.org/en/question/9257/dual-boot-fedora-16-windows/
# the configuration file of the bootloader
conf=/boot/grub2/grub.cfg
echo "Examining $conf..."
windowsentry=$(sudo grep 'menuentry .* windows' $conf)
windowsentry=$(echo $windowsentry | grep -o "'Windows[^']*'")
echo
if [ ! "$windowsentry" ]; then
echo "Error: $conf has no windows entry. Exiting."
exit 1
fi
echo "Setting the default to $windowsentry..."
sudo grub2-set-default $windowsentry
echo
echo "Regenerating $conf..."
sudo grub2-mkconfig $conf
echo
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment