2010/09/03

Generate Custom Titles for GRUB2 Menu

Backup first

sudo cp /etc/grub.d/10_linux /etc/grub.d/10_linux.bak
sudo cp /etc/grub.d/30_os-prober /etc/grub.d/30_os-prober.bak
sudo chmod -x /etc/grub.d/*.bak

Changing Linux Entry Titles

gksudo gedit /etc/grub.d/10_linux
### Do not show device.
# From line 73 replace:
    title="${description}, ${version} (${GRUB_DEVICE_BOOT})"
# with: 
    title="${description}, ${version}"
### Do not show "-generic" after kernel version.
# The list of variables in 10_linux begins at approximately line 129. Add the following:
  version_no_generic="`echo ${version} | cut -d "-" -f 1-2`"
# Original Menu Entry: This should be located at approximately line 144:
linux_entry "${OS}, Linux ${version}" \
# Replace with:
linux_entry "${OS} ${version_no_generic}" \
# Regenerate grub menu configuration:
sudo update-grub
# Check the titles generated:
sudo cat /boot/grub/grub.cfg | grep "menuentry" | cut -d '"' -f 2

Change Windows entry title

### Place Windows as first menu entry:
sudo mv /etc/grub.d/30_os-prober /etc/grub.d/09_os-prober
gksudo /etc/grub.d/09_os-prober
### Do not show "(loader)" and device.
# Below line 136:
  LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`"
# add this line:
  LONGNAME2="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' ' | sed 's/(loader)//g'`"
# Then replace line 152:
menuentry "${LONGNAME} (on ${DEVICE})" {
# with:
menuentry "${LONGNAME2}" {