Removing Excess Windows 10 menuentries from GRUB Menu

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post please read how to get help
Post Reply
User avatar
nickname
Level 1
Level 1
Posts: 23
Joined: Sun Feb 17, 2019 11:38 am

Removing Excess Windows 10 menuentries from GRUB Menu

Post by nickname » Tue Mar 05, 2019 2:48 pm

Title pretty much says it.

I have several GRUB menuentry's for Windows, each named for the partition it occupies. Only one is currently valid, so I'd like to configure GRUB to ignore the rest, leaving me with a menu similar to this:

Linux Mint
Linux Mint with boot options
Windows 10
System Setup

From what I've read, I should be able to disable OS probing and then add an entry in its own file.

The partition I want to boot Windows from is: /dev/sdd2

So, should be able to write a file (let's call it: 15_windows) with a script like:

Code: Select all

#!/bin/sh -e
echo "Adding Windows 10 to GRUB 2 menu"
cat << EOF
menuentry "Windows 10" {
set root=(hd4,3)
chainloader (hd4,1)+1
}
EOF
Drive are numbered from 1, partitions from 0, right? So sdd2 would translate to drive 4, partition 1.

However, would it be better to:
  • turn off the execution bit for /etc/grub.d/30_os-prober, or
  • add: GRUB_DISABLE_OS_PROBER=true to /etc/default/grub ?
Or does the latter even work with GRUB2?

User avatar
nickname
Level 1
Level 1
Posts: 23
Joined: Sun Feb 17, 2019 11:38 am

Re: Removing Excess Windows 10 menuentries from GRUB Menu

Post by nickname » Sat Mar 09, 2019 7:55 am

I finally got around to exploring this a bit and the final script for adding Windows 10 turned out to be:

Code: Select all

#!/bin/sh -e
echo "Adding Windows 10 to GRUB 2 menu"
cat << EOF
menuentry "Windows 10" {
    insmod part_gpt
    insmod fat
    set root='hd3,gpt2'
    chainloader /efi/Microsoft/Boot/bootmgfw.efi
}
EOF
This added "Windows 10" as a working menuentry in grub.

The odd thing is that, even though this is grub2, for whatever reason, the drive numbering still seems to be from classic grub, starting at '0' instead of '1' as is stated in the tutorial I found here.

I tried turning off the execute bit for 30_os-prober, but I ended up with no grub menu and booting straight into mint. And if I were to use GRUB_DISABLE_OS_PROBER=true in /etc/default/grub, I suspect I'd get the same results.

So, I'm still left with the question: How do I get rid of the excess grub menuentry's for Windows?

User avatar
nickname
Level 1
Level 1
Posts: 23
Joined: Sun Feb 17, 2019 11:38 am

Re: Removing Excess Windows 10 menuentries from GRUB Menu

Post by nickname » Sat Mar 09, 2019 9:57 am

For clarification, the grub menu now has these entries:

Code: Select all

Linux Mint 19.1 xfce
Advanced options for Linux Mint 19.1 xfce
Windows 10
Windows Boot Manager (on /dev/sda1)
Windows Boot Manager (on /dev/sdc2)
Windows Boot Manager (on /dev/sdd2)
System setup
And I'd like it to have only these:

Code: Select all

Linux Mint 19.1 xfce
Advanced options for Linux Mint 19.1 xfce
Windows 10
System setup

User avatar
arvy
Level 4
Level 4
Posts: 311
Joined: Sat Mar 26, 2016 11:22 am

Re: Removing Excess Windows 10 menuentries from GRUB Menu

Post by arvy » Sat Mar 09, 2019 12:34 pm

nickname wrote:
Sat Mar 09, 2019 7:55 am
I tried turning off the execute bit for 30_os-prober, but I ended up with no grub menu and booting straight into mint.
You've got the right general idea about turning off 30_os-prober, but before doing that, you need to insert the menu entry items that it generates in grub.cfg for "Windows 10" and "System Setup" into 40_custom and then run:

Code: Select all

sudo update-grub
System: Asus ROG Maximus XI Code mobo, Intel i9-9900K CPU, Nvidia GTX1080 GPU, 32 GB DDR4-3600 RAM, Sumsung Pro 2x512GB NVMe & 3x1TB SSD, Mint 19.1 x64 Cinnamon

User avatar
nickname
Level 1
Level 1
Posts: 23
Joined: Sun Feb 17, 2019 11:38 am

Re: Removing Excess Windows 10 menuentries from GRUB Menu

Post by nickname » Sun Mar 10, 2019 6:09 am

arvy wrote:
Sat Mar 09, 2019 12:34 pm
You've got the right general idea about turning off 30_os-prober, but before doing that, you need to insert the menu entry items that it generates in grub.cfg for "Windows 10" and "System Setup" into 40_custom and then run:

Code: Select all

sudo update-grub
Hmm... According to /boot/grub/grub.cfg, System Setup is added by /etc/grub.d/30_uefi-firmware, but regardless...

I did set up my own entry for Windows 10 in 15_windows (which I've tested and it works when added to grub along with all the generated entries) and the Linux entries should be taken care of by 10_linux, but...

None of this apparently makes any difference. Turning off the execute bit for 30_os-prober results in no grub menu at all.

User avatar
nickname
Level 1
Level 1
Posts: 23
Joined: Sun Feb 17, 2019 11:38 am

Re: Removing Excess Windows 10 menuentries from GRUB Menu

Post by nickname » Mon Mar 11, 2019 10:15 am

I'm now taking a different approach to this...

Instead of wrestling with grub configurations (since most of it's automatic) I've come at this from a different direction.

This is what I did:
  • fired up Aeomi Partition Assistant,
  • deleted the extraneous partitions (including EFI) from all drives except the two where Linux and Windows are installed.
As a result, I now have a much cleaner grub menu that looks like this:

Code: Select all

Linux Mint
Linux Mint with boot options
Windows (on /dev/sda1)
Windows (on /dev/sdd2)
System Setup
So, it's getting there. I managed to get rid of two extraneous boot options. But I now have one on the sda drive that isn't needed. That's the drive where Linux Mint lives, but apparently there's some leftover Windows stuff, too.

The sda drive has two partitions, an EFI and the extX Linux partition.

My question: If grub2 uses the MBR to boot-strap into /boot/efi/YADA-YADA, is that EFI partition needed? Can I just delete it or will that stop Linux from booting?

I know that to delete the partition—if that's the right thing to do (read: won't kill grub/linux)—should be a matter of:
  • boot from the live USB stick,
  • run gparted,
  • delete the EFI partition (sda1),
  • move sda2 to the beginning of the drive, and
  • resize sda2 (which will now be sda1) so it takes up the entire drive.
I just don't know for sure if it'll muck things up or not.

User avatar
nickname
Level 1
Level 1
Posts: 23
Joined: Sun Feb 17, 2019 11:38 am

Re: Removing Excess Windows 10 menuentries from GRUB Menu

Post by nickname » Mon Mar 11, 2019 12:10 pm

More info on this problem...

Output of efibootmgr -v:

Code: Select all

BootCurrent: 0007
Timeout: 1 seconds
BootOrder: 0007,0009,0001,000A,0000,0005
Boot0000* Windows Boot Manager	HD(2,GPT,b1852155-bd66-41e5-917c-28de0f83f40b,0xfa000,0x32000)/File(\EFI\MICROSOFT\BOOT\BOOTMGFW.EFI)WINDOWS.........x...B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}...a................
Boot0001* ubuntu	HD(1,GPT,a1c4fc88-2629-43a1-996c-4e625773d9f4,0x800,0x100000)/File(\EFI\UBUNTU\SHIMX64.EFI)
Boot0005  Windows Boot Manager	HD(2,GPT,a8ba65b9-935f-4258-bd31-1df47fb78675,0x3304b,0x2730c)/File(\EFI\MICROSOFT\BOOT\BOOTMGFW.EFI)..BO
Boot0007* ubuntu	HD(1,GPT,a1c4fc88-2629-43a1-996c-4e625773d9f4,0x800,0x100000)/File(\EFI\UBUNTU\GRUBX64.EFI)..BO
Boot0009* ubuntu	HD(2,GPT,a8ba65b9-935f-4258-bd31-1df47fb78675,0x3304b,0x2730c)/File(\EFI\UBUNTU\GRUBX64.EFI)..BO
Boot000A* Windows Boot Manager	HD(1,GPT,a1c4fc88-2629-43a1-996c-4e625773d9f4,0x800,0x100000)/File(\EFI\MICROSOFT\BOOT\BOOTMGFW.EFI)..BO
Output of sudo blkid:

Code: Select all

/dev/sda1: UUID="7366-1FFF" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="a1c4fc88-2629-43a1-996c-4e625773d9f4"
/dev/sda2: UUID="79e0ecc3-d1a5-41a8-90d8-df78d0f25701" TYPE="ext4" PARTUUID="1acb7cbd-8bba-4c6c-b57e-a394faf5629c"
/dev/sdb1: LABEL="Data" UUID="5AA6B3C7A6B3A245" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="fa03cc90-3717-4b08-a716-1b279c971f4b"
/dev/sdc1: LABEL="DataBU" UUID="52D02E5BD02E4597" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="d5123b5d-fb5c-40a2-8e38-0affbefbf1f3"
/dev/sdd1: LABEL="Recovery" UUID="01D497A4CAFAECE0" TYPE="ntfs" PARTLABEL="M-oM-?M-?M-oM-?M-?M-oM-?M-?M-oM-?M-?$" PARTUUID="c101d536-f618-45aa-b54c-8e1e4b478020"
/dev/sdd2: UUID="E42A-F805" TYPE="vfat" PARTUUID="a8ba65b9-935f-4258-bd31-1df47fb78675"
/dev/sdd4: UUID="01D497A788D85AC0" TYPE="ntfs" PARTUUID="a94233a6-4edb-430c-aa6e-950f7d98a5c2"
/dev/mmcblk0p1: LABEL="SysSnap" UUID="0ee8d592-e78f-4a09-8b5d-a59421260b9a" TYPE="ext4" PARTUUID="c99186e7-01"
/dev/sdd3: PARTUUID="8d79c695-a00e-4428-814c-00af5a957549"
/dev/mmcblk0: PTUUID="c99186e7" PTTYPE="dos"
And output of lsblk -f:

Code: Select all

NAME        FSTYPE LABEL    UUID                                 MOUNTPOINT
sda                                                              
├─sda1      vfat            7366-1FFF                            /boot/efi
└─sda2      ext4            79e0ecc3-d1a5-41a8-90d8-df78d0f25701 /
sdb                                                              
└─sdb1      ntfs   Data     5AA6B3C7A6B3A245                     /mnt/Data
sdc                                                              
└─sdc1      ntfs   DataBU   52D02E5BD02E4597                     /mnt/DataBU
sdd                                                              
├─sdd1      ntfs   Recovery 01D497A4CAFAECE0                     
├─sdd2      vfat            E42A-F805                            
├─sdd3                                                           
└─sdd4      ntfs            01D497A788D85AC0                     /mnt/WinSys
The entry I'm trying to get rid of is referred to as Boot000A and PARTUUID a1c4fc88-2629-43a1-996c-4e625773d9f4.

I tried using efibootmgr -b 000A -B to delete the entry, but it still shows up in the grub menu.

And if I do the above followed by: update-grub, it makes no difference.

So that raises another question: When I give the number of the entry I want deleted, is it:
  • the boot order number (which would be 4 because this partition is listed at #4 in the boot order at the top of efibootmgr's output),
  • the hex number in the 'name' (ie. Boot000A as I tried), or
  • the ordinal number of as listed by efibootmgr (which in this case would be '6').
This is seriously confusing.

And also brings me back to the question I raised above: Does Linux need that EFI partition? Can I safely delete it? 'Cause if I can, that seems the least complicated way to do this.

Post Reply

Return to “Installation & Boot”