Skip to content

Instantly share code, notes, and snippets.

@666threesixes666
Last active December 14, 2015 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 666threesixes666/5114489 to your computer and use it in GitHub Desktop.
Save 666threesixes666/5114489 to your computer and use it in GitHub Desktop.
update-grub2
#!/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