Adding custom boot target to GRUB2

      No Comments on Adding custom boot target to GRUB2

In GRUB2 one doesn’t alter the main configuration file /boot/grub2/grub.cfg manually any more. Boot menu entries are automatically determined by the grub2-mkconfig script.

To add a custom menu entry, edit /etc/grub.d/40_custom

[...]
menuentry 'Custom Entry' {
  set root='hd0,msdos2'
  echo    'Loading Linux'  
  linux   /vmlinuz
  echo    'Loading initial ramdisk ...'
  initrd  /initramfs.img
}

Note that GRUB2 partition numbering starts with 1 (not 0 like GRUB) but disk numbering starts with 0, e.g. if your kernel and inital ramdisk are located on /dev/sda2, this translates to hd0,2.

On MS-DOS type partitions (which currently is the majority of partitions out there) hd0,2 and hd0,msdos2 are interchangeable.

To recreated grub.cfg with the added boot menu entry, invoke

grub2-mkconfig -o /boot/grub2/grub.cfg

Resources:
http://home.roadrunner.com/~computertaijutsu/grub2.html

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.