I am taking about the naming of existing/default GRUB boot entry. Currently I’ve the following options at GRUB screen:
Trisquel GNU/Linux Advanced options for Trisquel GNU/Linux Trisquel GNU/Linux, with Linux-Libre 3.13.0-39-lowlatency (recovery mode) Windows 7 (loader) (on /dev/sda1) Edubuntu ISO
Where First three entries are default with Trisquel GNU/Linux, 4th is for Windows boot loader and 5th is custom entry defined at /etc/grub.d/40_custom.Now suppose I want to change the name/text of say 4th entry Windows 7 (loader) (on /dev/sda1), then which is the right way?
I found above menu entries at /boot/grub/grub.cfg. Example for that I want to change:
### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows 7 (loader) (on /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-chain-0A7072DF7072D145' {
insmod part_msdos
insmod ntfs
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 0A7072DF7072D145
else
search --no-floppy --fs-uuid --set=root 0A7072DF7072D145
fi
parttool ${root} hidden-
chainloader +1
}
### END /etc/grub.d/30_os-prober ###
So, Can I safely replace the name/text 'Windows 7 (loader) (on /dev/sda1)' with which I want and then update-grub2?
Briefly I want to know How do I change the name of GRUB boot entry?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You can change /boot/grub/grub.cfg directly, but this file gets overwritten by update-grub2. If your configuration does not change often, this may be the easiest way for you.
Or take a look at:
Alternatively have a look at this folder /etc/grub.d. From there update-grub2 generates the /boot/grub/grub.cfg file.
You can change the way the auto-generation labels the Windows entries, especially as you only got one Windows installed, by overwriting the specific menuentry command in the 30_os-prober script.
Go to /etc/grub.d/30_os-prober and look for menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows .... Replace the ' ' part with your label, but keep the other options the same.
e.g. on my system:menuentry 'My Windows 7 system' --class windows --class os $menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' {
EOF
But there is a catch to that: firstly there are two of these entries in 30_os-prober: one for chain), another for efi), thus you should change both. Secondly I guess these changes will be overwritten, once there is an update to these files / to grub.
Another approach:
You can disable the windows part in the 30_os-prober script by commenting # those menuentry ...commands in the windows sections chain) and efi). That will remove the auto-generated windows entry. Then take your current windows bootentry from /boot/grub/grub.cfg and copy it into the custom menu file /etc/grub.d/40_custom.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0