Editing Grub2 menu entries manually in Linux Mint

Thinker
  11 years ago
  18

Although grub can be edited using a software Grub Customizer but if you want more control and do it manually in a text editor, here are the steps:

 

1. For removing memtest, open terminal and type:

sudo chmod -x /etc/grub.d/20_memtest86+

This can also be done graphically by opening /etc/grub.d, right click on 20_memtest86+ and disabling/unchecking “Allow executing file as program”. User must have administrative permissions to do this action. To get administrative rights, type in terminal:

gksudo nautilus

A new window will open which will have administrative rights. Browse the location from this window and perform reguired operations.

 

2. To remove grub recovery option, open file /etc/default/grub as administrator and uncomment GRUB_DISABLE_RECOVERY="true" by removing # in front of it. To open this file as administrator, right click on file and select "Open as Administrator".

 

3. To change default timeout, change the value of GRUB_TIMEOUT="10" to "30 or any other value (in seconds) whichever is required in the same file which is mentioned in step 2. Grub Timeout determines how long the grub menu is displayed before the default entry is loaded.

 

4. Then run in terminal:

sudo update-grub

This command is necessary for implementing changes made in step 1 , 2 and 3.

 

5. For editing/removing boot entries, edit grub.cfg file present in /boot/grub/. To remove extra operating system entry (say Linux Mint 12 installed on sda8) remove these lines from grub.cfg file:

menuentry "Linux Mint 12 32-bit, 3.0.0-12-generic (/dev/sda8) (on /dev/sda8)" --class gnu-linux --class gnu --class os {
insmod part_msdos
insmod ext2
set root='(hd0,msdos8)'
search --no-floppy --fs-uuid --set=root 8d535868-a72d-4b53-93da-9e83e1d8b7f3
linux /boot/vmlinuz-3.0.0-12-generic root=UUID=8d535868-a72d-4b53-93da-9e83e1d8b7f3 ro quiet splash vt.handoff=7
initrd /boot/initrd.img-3.0.0-12-generic
}

 

6. To remove memtest, recovery option and other extra operating systems, first follow step 1 and 2, then run command update-grub. Then remove any extra entries from grub.cfg.

 

7. By default Operating system is listed something like this:

Linux Mint 12 32-bit, 3.0.0-12-generic (on /dev/sda8)

To change its name ie suppose you want this operating system to be listed as "Lisa", edit the name which is written inside quotes after menuentry (see 5th step) to Lisa. On next boot, this operating system will be listed with name "Lisa".

 

8. If no key is pressed within timeout, the latest installed operating system is selected by default. To change default operating system to start after timeout, change the value in below highlighted text in "set default" from 0 to 1 or 2 according to your choice (do a little bit experiment).

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  set have_grubenv=true
  load_env
fi
set default="0"
if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

 

Note: 1. Do not run command update-grub after editing/removing/renaming entries in grub.cfg file as this command reconfigures grub.cfg file and will again include all operating systems present on system.

2. If two Mint or Linux operating systems are installed, step 1 and 2 has to be done for both operating systems. Command chmod -x /etc/grub.d/20_memtest86+ works for main/latest operating system as for previous operating system, sometimes file name is changed by grub. For secondary/previous operating system, open /etc/grub.d and find exact name of file 20_memtest... and run above command.

 

Please don't demote this tutorial on basis of method of root permissions. This tutorial is basically for editing grub entries, not about root permissions. Methods of taking root permissions I have mentioned may not be appropriate but I have adopted easiest methods I know.

Comments
vdbhb59 2 years ago

Helped me in editing my entries, as there were few leftover from last 2 OS, which somehow did not get removed by Grub, default. Took me less than 5 minutes to get everything done. :)


a_steidl 8 years ago

I was dual-booting Windows 7 and Linux Mint 17.1 Rebecca, and didn't want Windows anymore. Too many headaches, and with my old-ish machine, instability while running that OS. Mint has not failed me yet. Anywho, I simply backed up the whole windows disk into an image, then ran gparted, deleted the entire Windows disk (in my case, sda), formatted it to ext4, and then ran update-grub. I haven't rebooted my machine yet, but the output from update-grub showed that it did what I wanted, which was to remove Windows, and gain a HDD, and have grub reflect this.


bces0605 10 years ago

Best Solution (Linux Mint 15 cinnamon) : First of all the above method doesn't work. If it works, it is not a good way of doing this. The best way to this is described in Grub2 tutorial at "http://www.dedoimedo.com/computers/grub-2.html". Read it thoroughly if you want to be advanced user of grub2 but if you only want to change the boot order here is how I did this. I had my window 7 in C and then installed Linux Mint 15 and there was no Windows 7 loader.
1. type in terminal "sudo update-grub". It will get the windows 7 bootloader in the boot menu of linux mint during.
2. Now suppose I want window 7 to boot first. In the /etc/grub.d directory there will be different files starting with numbers (i.e. 00_header, 10_linux, 30_os-prober (window 7 loader) etc). The principal is simple, 10_linux will boot first as its number is less then 30_os-prober. Rename the file 30_os-prober to 09_os-prober. You will not be able to rename it directly. Enter following commands in the terminal to rename it.
sudo mv /etc/grub.d/30_os-prober /etc/grub.d/09_os-prober
sudo update-grub
3. Now restart your computer and window 7 will boot first by default.

The grub.cfg reads from grub.d folder.
If you have any problem related to this comment, post it in your comment.


Thinker 10 years ago

I have already mentioned this in Note 1. Edit grub.cfg after executing command 'sudo update grub'