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
  • 66,947
  • 30
  • 177
  • 264
n00b
  • 1,887
  • 9
  • 26
  • 39
  • Try [Grub Customizer](https://launchpad.net/~danielrichter2007/+archive/grub-customizer). – Mitch Mar 21 '14 at 12:35
  • 1
    Its possible but ill-advised, and your changes will get overridden. – Dan Mar 21 '14 at 13:25
  • 2
    @Mitch 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:37
  • @n00b Yup, Grub Customizer just crashed on my first attempt to use it – endolith Apr 18 '16 at 02:06
  • @n00b That's true. This tool is really good, but also very dangerous. @ endolith What was the crashing message? – Quidam Apr 27 '20 at 15:29

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,581
  • 11
  • 44
  • 70
  • 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.

Ciro Santilli OurBigBook.com
  • 26,663
  • 14
  • 108
  • 107
-3

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

tomaRv
  • 29
  • 3