Grub 2 Menu entries can be added to grub.cfg automatically or manually,and grub.cfg is updated when update-grub is run.
Manually adding entries to Grub 2

Entries to grub.cfg can be manually inserted by creating a file in the /etc/grub.d folder.

  • The name of the file determines the order in the menu. 30_os-prober entries will be placed before 40_custom entries, which will be placed before 50_my-sample entries.
  • Any created file must be made executable. This can be done as root by running “sudo chmod +x /etc/grub.d/filename“.
  • The files in the /etc/grub.d folder will be read and the contents included in grub.cfg when the “update-grub2” command is executed as root.

A sample entry. This file creates a menu item for running the SystemRescueCD (previously installed) from a partition created on sda10. Folders and files must have been copied to the correct location in accordance with the SystemRescueCD if you wish to actually use this entry.

Quote:

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
echo "Adding SystemRescueCD" >&2
menuentry "System Rescue CD" {
set root=(hd0,10)
linux   /sysrcd/rescuecd subdir=sysrcd setkmap=us
initrd  /sysrcd/initram.igz
}

Tip: If you want to have your custom entries at the top of the menu (say you want custom titles), create a new file and name it “07_xxxx”. Since the files in /etc/grub.d/ are read sequentially, those in “07_custom” will be placed before those of “10_linux”. I recommend not naming a custom menu file lower than 06 so that any theme run from 05_debian_theme is allowed to run before any custom menu is created. After creating the file, run sudo update-grub and then check the value of “DEFAULT” in /etc/default/grub. If it doesn’t point to the correct menuentry, change the value of DEFAULT to the correct menuentry value.
Removing entries
* To remove a user-created menu entry, remove the applicable file from the /etc/grub.d folder.
* If a custom file contains multiple entries, individual items may be removed and others retained.
* Once the file has been removed or edited, run “update-grub2″ to update grub.cfg.

Read: Original text