8

I wish to change a menu entry in grub.cfg, for example:

From

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Ubuntu is wonderful'

To

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Ubuntu is world famous'
Braiam
  • 67,791
  • 32
  • 179
  • 269
n00b
  • 1,897

3 Answers3

12

Edit /etc/grub.d/10_linux instead and run sudo update-grub when you are done. This is a more reliable method, otherwise every time you upgrade to a new kernel your /boot/grub/grub.cfg will be overwritten and you will lose your changes.

Or you can use Grub Customizer. To install it:

sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install grub-customizer
Danatela
  • 13,243
  • 11
  • 45
  • 72
  • 1
    @edwin I did consider Grub Customizer but there are many users who report having issues with it. One user even lost his ability to boot up the OS. – n00b Mar 21 '14 at 13:38
  • 2
    then use the first method. You can post your /etc/grub.d/10_linux if you unsure what lines to change. – Danatela Mar 21 '14 at 13:41
  • Isn't it rather 40_custom, and 10_linux is for proxy? – Quidam May 07 '20 at 01:01
2

How to do it from an emulator to learn how GRUB works, without the risk of breaking anything.

  • create a Multiboot hello world main.elf file. GRUB knows how to boot those files (GRUB also knows how to boot the Linux kernel, even though it is not Multiboot)

  • create a iso/boot/grub/grub.cfg file containing:

    menuentry "main" {
        multiboot /boot/main.elf
    }
    

    Place main.elf under iso/boot/

  • Generate an image and run it:

    grub-mkrescue -o main.img iso
    qemu-system-x86_64 -hda main.img
    

This will boot into GRUB, and you will see an entry called main.

Now edit grub.cfg like menuentry "newmain", and upon a reboot the new option name is newmain. So your change would work.

I have posted the exact code for this example at: https://github.com/cirosantilli/x86-bare-metal-examples/tree/d217b180be4220a0b4a453f31275d38e697a99e0/multiboot/hello-world

As others said, don't do it in practice, since that is normally an output file and will get overwritten on update-grub.

-3

yes you can edit this file /boot/grub/grub.cfg

tomaRv
  • 29
  • 3