Last active
December 14, 2015 16:19
-
-
Save 666threesixes666/5114489 to your computer and use it in GitHub Desktop.
update-grub2
This file contains 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 characters
#!/bin/bash | |
#make sure boot is mounted to load the kernel | |
mount | grep "/boot" /proc/self/mounts > /dev/null | |
if [ $? -ne 0 ]; then | |
mount /boot | |
fi | |
#make sure you have a grub2 directory in boot | |
if [ ! -d "/boot/grub2" ]; then | |
mkdir /boot/grub2 | |
fi | |
#dynamically assign the drive to install grub2 to | |
DRIVE=$(cat /proc/self/mounts | grep boot | awk '{print $1}' | sed 's/[0-9]*//g') | |
echo "installing grub2 to $DRIVE" | |
/usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg | |
/usr/sbin/grub2-install $DRIVE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment