<SOLVED> Quik, easy, reliable way to edit grub menu?

Questions about Grub, the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Linny
Level 2
Level 2
Posts: 66
Joined: Mon Apr 21, 2014 10:35 am

<SOLVED> Quik, easy, reliable way to edit grub menu?

Post by Linny »

Is there a quick, easy, and reliable way to edit the grub menu? I need to remove, disable, or rename the last item which is to launch Windows 7 in recovery mode. I need to make sure that my wife doesn't accidentally make this selection. Delete or disable would be best. Her hands shake a lot so that even renaming the selection could still permit a disasterous accident.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
Flemur
Level 20
Level 20
Posts: 10097
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Quik, easy, reliable way to edit grub menu?

Post by Flemur »

Linny wrote: Wed Jun 16, 2021 3:23 pm Is there a quick, easy, and reliable way to edit the grub menu? I need to remove, disable, or rename the last item which is to launch Windows 7 in recovery mode. I need to make sure that my wife doesn't accidentally make this selection. Delete or disable would be best. Her hands shake a lot so that even renaming the selection could still permit a disasterous accident.
If you don't get a better answer (like update-grub with option to omit an OS would be nice..?), you can as root (sudo) edit
/boot/grub/grub.cfg and find that windows entry.

Each entry look like:

Code: Select all

    menuentry 'What you see in the grub menu' a bunch of stuff {
... about 5 to 20 lines more stuff
    }
Find the chunk for windows and delete that section of text; it'll come back when you get a new kernel, etc, so if there's an update-grub method, use that instead.
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
ajgringo619

Re: Quik, easy, reliable way to edit grub menu?

Post by ajgringo619 »

Linny wrote: Wed Jun 16, 2021 3:23 pm Is there a quick, easy, and reliable way to edit the grub menu? I need to remove, disable, or rename the last item which is to launch Windows 7 in recovery mode. I need to make sure that my wife doesn't accidentally make this selection. Delete or disable would be best. Her hands shake a lot so that even renaming the selection could still permit a disasterous accident.
Can you post your /boot/grub/grub.cfg?
Linny
Level 2
Level 2
Posts: 66
Joined: Mon Apr 21, 2014 10:35 am

Re: Quik, easy, reliable way to edit grub menu?

Post by Linny »

Can do, but it may be a couple of hours or so. My wife's sick and I'm in the middle of some housework.
User avatar
all41
Level 19
Level 19
Posts: 9498
Joined: Tue Dec 31, 2013 9:12 am
Location: Computer, Car, Cage

Re: Quik, easy, reliable way to edit grub menu?

Post by all41 »

Linny wrote: Wed Jun 16, 2021 4:47 pm Can do, but it may be a couple of hours or so. My wife's sick and I'm in the middle of some housework.
Wishing all the best and for a speedy recovery.

When this happens:
My wife's sick
and this happens:
I'm in the middle of some housework
one gains new perspective and appreciation--just sayin
Everything in life was difficult before it became easy.
Linny
Level 2
Level 2
Posts: 66
Joined: Mon Apr 21, 2014 10:35 am

Re: Quik, easy, reliable way to edit grub menu?

Post by Linny »

Thankyou for your well wish. Here is my grub.cfg. Drag and drop didn't work. I keep getting the message "Invalid file extension", so here's the text:

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

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

if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
else
menuentry_id_option=""
fi

export menuentry_id_option

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

function savedefault {
if [ -z "${boot_once}" ]; then
saved_entry="${chosen}"
save_env saved_entry
fi
}
function load_video {
if [ x$feature_all_video_module = xy ]; then
insmod all_video
else
insmod efi_gop
insmod efi_uga
insmod ieee1275_fb
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
fi
}

insmod part_msdos
insmod ext2
set root='hd0,msdos9'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 b7008ffe-883b-4947-bafd-a2eafa8ba7f8
else
search --no-floppy --fs-uuid --set=root b7008ffe-883b-4947-bafd-a2eafa8ba7f8
fi
if loadfont /boot/grub/fonts/UbuntuMono16.pf2 ; then
set gfxmode=auto
load_video
insmod gfxterm
set locale_dir=$prefix/locale
set lang=en_US
insmod gettext
fi
terminal_output gfxterm
insmod part_msdos
insmod ext2
set root='hd0,msdos9'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 b7008ffe-883b-4947-bafd-a2eafa8ba7f8
else
search --no-floppy --fs-uuid --set=root b7008ffe-883b-4947-bafd-a2eafa8ba7f8
fi
insmod gfxmenu
insmod png
set theme=($root)/boot/grub/themes/linuxmint/theme.txt
export theme
if [ "${recordfail}" = 1 ] ; then
set timeout=30
else
if [ x$feature_timeout_style = xy ] ; then
set timeout_style=menu
set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
set timeout=5
fi
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
function gfxmode {
set gfxpayload="${1}"
}
set linux_gfx_mode=
export linux_gfx_mode
menuentry 'LMDE 4 Debbie' --class linuxmint --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-b7008ffe-883b-4947-bafd-a2eafa8ba7f8' {
load_video
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
set root='hd0,msdos9'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 b7008ffe-883b-4947-bafd-a2eafa8ba7f8
else
search --no-floppy --fs-uuid --set=root b7008ffe-883b-4947-bafd-a2eafa8ba7f8
fi
echo 'Loading Linux 4.19.0-16-amd64 ...'
linux /boot/vmlinuz-4.19.0-16-amd64 root=UUID=b7008ffe-883b-4947-bafd-a2eafa8ba7f8 ro quiet splash
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-4.19.0-16-amd64
}
submenu 'Advanced options for LMDE 4 Debbie' $menuentry_id_option 'gnulinux-advanced-b7008ffe-883b-4947-bafd-a2eafa8ba7f8' {
menuentry 'LMDE 4 Debbie, with Linux 4.19.0-16-amd64' --class linuxmint --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.19.0-16-amd64-advanced-b7008ffe-883b-4947-bafd-a2eafa8ba7f8' {
load_video
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
set root='hd0,msdos9'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 b7008ffe-883b-4947-bafd-a2eafa8ba7f8
else
search --no-floppy --fs-uuid --set=root b7008ffe-883b-4947-bafd-a2eafa8ba7f8
fi
echo 'Loading Linux 4.19.0-16-amd64 ...'
linux /boot/vmlinuz-4.19.0-16-amd64 root=UUID=b7008ffe-883b-4947-bafd-a2eafa8ba7f8 ro quiet splash
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-4.19.0-16-amd64
}
menuentry 'LMDE 4 Debbie, with Linux 4.19.0-16-amd64 (recovery mode)' --class linuxmint --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.19.0-16-amd64-recovery-b7008ffe-883b-4947-bafd-a2eafa8ba7f8' {
load_video
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
set root='hd0,msdos9'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 b7008ffe-883b-4947-bafd-a2eafa8ba7f8
else
search --no-floppy --fs-uuid --set=root b7008ffe-883b-4947-bafd-a2eafa8ba7f8
fi
echo 'Loading Linux 4.19.0-16-amd64 ...'
linux /boot/vmlinuz-4.19.0-16-amd64 root=UUID=b7008ffe-883b-4947-bafd-a2eafa8ba7f8 ro single
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-4.19.0-16-amd64
}
menuentry 'LMDE 4 Debbie, with Linux 4.19.0-8-amd64' --class linuxmint --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.19.0-8-amd64-advanced-b7008ffe-883b-4947-bafd-a2eafa8ba7f8' {
load_video
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
set root='hd0,msdos9'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 b7008ffe-883b-4947-bafd-a2eafa8ba7f8
else
search --no-floppy --fs-uuid --set=root b7008ffe-883b-4947-bafd-a2eafa8ba7f8
fi
echo 'Loading Linux 4.19.0-8-amd64 ...'
linux /boot/vmlinuz-4.19.0-8-amd64 root=UUID=b7008ffe-883b-4947-bafd-a2eafa8ba7f8 ro quiet splash
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-4.19.0-8-amd64
}
menuentry 'LMDE 4 Debbie, with Linux 4.19.0-8-amd64 (recovery mode)' --class linuxmint --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.19.0-8-amd64-recovery-b7008ffe-883b-4947-bafd-a2eafa8ba7f8' {
load_video
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
set root='hd0,msdos9'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 b7008ffe-883b-4947-bafd-a2eafa8ba7f8
else
search --no-floppy --fs-uuid --set=root b7008ffe-883b-4947-bafd-a2eafa8ba7f8
fi
echo 'Loading Linux 4.19.0-8-amd64 ...'
linux /boot/vmlinuz-4.19.0-8-amd64 root=UUID=b7008ffe-883b-4947-bafd-a2eafa8ba7f8 ro single
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-4.19.0-8-amd64
}
}

### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###

### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows 7 (on /dev/sda2)' --class windows --class os $menuentry_id_option 'osprober-chain-CC70378A703779F2' {
insmod part_msdos
insmod ntfs
set root='hd0,msdos2'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 CC70378A703779F2
else
search --no-floppy --fs-uuid --set=root CC70378A703779F2
fi
parttool ${root} hidden-
chainloader +1
}
menuentry 'Windows 7 (on /dev/sda3)' --class windows --class os $menuentry_id_option 'osprober-chain-AC7C4EC27C4E86D4' {
insmod part_msdos
insmod ntfs
set root='hd0,msdos3'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos3 --hint-efi=hd0,msdos3 --hint-baremetal=ahci0,msdos3 AC7C4EC27C4E86D4
else
search --no-floppy --fs-uuid --set=root AC7C4EC27C4E86D4
fi
parttool ${root} hidden-
chainloader +1
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/30_uefi-firmware ###
### END /etc/grub.d/30_uefi-firmware ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f ${config_directory}/custom.cfg ]; then
source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
User avatar
ricardogroetaers
Level 6
Level 6
Posts: 1368
Joined: Sat Oct 27, 2018 3:06 am
Location: Rio de Janeiro, Brasil

Re: Quik, easy, reliable way to edit grub menu?

Post by ricardogroetaers »

Linny wrote: Wed Jun 16, 2021 3:23 pm... Delete or disable would be best. ...
Despite opinions to the contrary, the "grub customizer" program is a good option.
Just uncheck (do not delete) the menu options you want to hide.
Note in the figure that I only hid the "memory test" options, not eliminated them.

Observation:
Don't be impressed if "GrubCustomizer" shows "Ubuntu" instead of "Linux Mint". Don't worry and don't mess with it.
Don't be impressed if I made an option for grub to launch DOS.
Attachments
Captura de tela_2021-06-17_02-01-41.png
ajgringo619

Re: Quik, easy, reliable way to edit grub menu?

Post by ajgringo619 »

The offending entry is coming from os-prober. If you want to make the necessary changes manually, then do this:

1. add this line to /etc/default/grub

Code: Select all

GRUB_DISABLE_OS_PROBER=true
2. add this to etc/grub.d/40_custom

Code: Select all

menuentry 'Windows 7 (on /dev/sda2)' --class windows --class os $menuentry_id_option 'osprober-chain-CC70378A703779F2' {
insmod part_msdos
insmod ntfs
set root='hd0,msdos2'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 CC70378A703779F2
else
search --no-floppy --fs-uuid --set=root CC70378A703779F2
fi
parttool ${root} hidden-
chainloader +1
}
3. run sudo update-grub to make the changes permanent

Basically what you'll have done is eliminate Mint's searching for other bootable OS's and manually added an entry for Windows 7. If you ever change to Windows 10 you'll need to back these changes out.
Linny
Level 2
Level 2
Posts: 66
Joined: Mon Apr 21, 2014 10:35 am

Re: Quik, easy, reliable way to edit grub menu?

Post by Linny »

I've used grub customizer before and it did seem a little flaky. But I went ahead and moved the Windows 7 option to the top and left the recovery option at the bottom and I think I will go back and set the delay to 2 or 3 seconds until my wife is comfortable using Linux full time. I don't see ever updating to Windows 10. Now if I can enable hibernation and/or speed up the boot (over 60 seconds from the grub menu seems too long) I should be ready to have her give it a try. And thank you very much for your help.
Locked

Return to “Installation & Boot”