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'
share|improve this question
    
Try Grub Customizer. – Mitch Mar 21 '14 at 12:35
1  
Its possible but ill-advised, and your changes will get overridden. – dan08 Mar 21 '14 at 13:25
1  
@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 2:06

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
share|improve this answer
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

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.

share|improve this answer

You just have to edit grub.cfg like you did (sudo [textEditor] /boot/grub/grub.cfg), save and reboot. Don't run sudo update-grub, it will overwrite grub.cfg.

share|improve this answer
5  
update-grub is run by the system, for instance, when the kernel get updated. So if the OP follow your recommendation, he will loose his customization at some point in time. – Benoit Mar 21 '14 at 12:47
    
@Benoit That is what I read on the internet too. I will lose the customization at some point when the kernel is updated. Are there any other solutions? I just wish to change menu entries in grub.cfg – n00b Mar 21 '14 at 13:41
    
@n00b: if you really want to make permanent change, even you or the system run update-grub, I think that the only solution is to look into the scripts under /etc/grub.d and to do modification there. – Benoit Mar 21 '14 at 13:46
    
@Benoit: Thanks for your tip. I am new to Linux and do not have enough IT knowledge to do the necessary modifications of the scripts under /etc/grub.d – n00b Mar 21 '14 at 14:37

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.