Solved Grub - Modifying OS sequence, Deleting/Removing entries

Solved issue
Chaps. Looks like there is no coherent (at least for me) way to fix my stuffed up Boot loader/Grub. I am tempted to go the Nuclear Option (again...I quite like this option) wipe the SSD clean and fresh install only Mint and Ubuntu. It's a pity as I would have thought that modifying Boot/Grub (i.e. deleting some entries) was more doable in Linux for us less educated or even average punters. Before I press the Nuclear Button any final thoughts? Cheers John
 


Yes.

Draw a long breath, again.

I know he is excruciatingly busy.

@wizardfromoz
 
Before I press the Nuclear Button any final thoughts?
I have just read over your thread. One thing you definitely need to avoid is editing GRUB settings in /etc in multiple distros (you mention MINT and Ubuntu). It is going to be a recursive circle of distro defaults for grub scripts overwriting each other otherwise.

Prior to reinstall decide which distro is going to be your lead for the bootloader. It will be necessary to let distros do their boot loader installation (e.g. Ubuntu is notoriously difficult to install without). What no distro will do is overwrite files in /boot (unless you let it format it). After you installed the next distro, you can always go boot the one you want to control the grub.cfg and re-install/update any necessary grub steps with it. While I have not run MINT/Ubuntu installers lately, this way is probably easier than trying to get one of the installers ignore installing a boot loader. After you have done that, you still need to make sure the other distro does not automatically run commands like 'grub-update', which will again create a mess, but that better wait until you have declared which one you let manage grub.
 
you may try, in order
identify the grub partition on your drive
Switch off insert Mint bootable ISO and boot to test mode
mount the grub partition and run

grub-install /dev/sdX [replace sdx with your partition label]

then run
update grub
 
Last edited:
The simplest way to control the order of the operating systems in the GRUB menu itself is to make sure the operating system you want as first is the one that last ran the sudo update-grub command and is currently "owning" the GRUB installation.
However, the easiest way to ensure a specific OS (like Ubuntu) is always the default selection is by editing the configuration file.
1. The Recommended Method: Edit /etc/default/grub
You need to identify the exact name or position of the Ubuntu entry in your GRUB menu. The menu entries are counted starting from 0 (zero-indexed).
A. Identify the Ubuntu Entry
First, view the generated configuration file to see the exact names of your boot entries.
* Open your Terminal in the OS that is currently controlling GRUB (usually the one you installed last).
* Run this command to list the main menu entries:
grep "menuentry " /boot/grub/grub.cfg

* Note the entry number (index) and the full entry name for Ubuntu.
* The first entry listed is 0.
* The second is 1, and so on.
* Example Output:
menuentry 'Ubuntu' {
menuentry 'Linux Mint 21.3 Cinnamon' --class linuxmint ...
menuentry 'Windows Boot Manager (on /dev/sda1)' ...

* Let's assume Ubuntu is entry 0 and Linux Mint is entry 1.
B. Edit the Default Configuration File
* Open the configuration file using a text editor (like Nano or Gedit/Pluma):
sudo nano /etc/default/grub
# OR (for a graphical editor)
# sudo gedit /etc/default/grub

* Find the line that starts with GRUB_DEFAULT=.
* Change the value to one of the following options:
| Option | Description |
|---|---|
| GRUB_DEFAULT=0 | Sets the default to the first entry (index 0). If Ubuntu is first, this is the solution. |
| GRUB_DEFAULT=1 | Sets the default to the second entry (index 1). If Mint is first and Ubuntu is second, this is the solution. |
| GRUB_DEFAULT="Ubuntu" | Sets the default using the exact menu entry title (recommended over the index number as the order can change after kernel updates). Make sure to use quotes! |
Example (to set Ubuntu as the default):
GRUB_DEFAULT="Ubuntu"

C. Save and Update GRUB
* Save the file and exit the editor.

* Update the GRUB configuration (this is the critical step that generates the new grub.cfg):
sudo update-grub

* Reboot to test the new default order.
2. The GUI Method: Grub Customizer
If you prefer a graphical interface to drag-and-drop the entries into your preferred order, you can use Grub Customizer.
* Install Grub Customizer:
sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt update
sudo apt install grub-customizer

* Run Grub Customizer: Find it in your application menu or run grub-customizer from the terminal.
* Change the Order:
* Go to the List configuration tab.
* Drag the entries (like "Ubuntu" and "Linux Mint...") into your desired 1st, 2nd, etc. order.
* Click the Save button (the disk icon) to apply the changes.
* Reboot to see the new permanent order.
 
@JohnJ

If you are the sole user of your computer - there is a file in both Ubuntu and Mint named

/usr/share/grub/default/grub

which for the most part duplicates what you have in

/etc/default/grub

Check its content and see if it differs significantly to what you have in your grub flle.

If so, change the relevant lines to match, or comment out (with a # ) the lines that differ in the one in /usr/share

You will need to use administrative privileges to do so.

On conclusion, run

sudo update-grub

again, reboot and report back if you will what you find.

I have other ways ro let you place on top of your grub menu whichever distro you like, and/or to always open the last distro you were using.

I would not get rid of the lines that say Advanced options , and you will see why.

HTH

Wiz
 
@tpkusr

Grub-customizer is rubbish, and your input appears to be AI-generated.

Is that so?

Wizard
 
I have just read over your thread. One thing you definitely need to avoid is editing GRUB settings in /etc in multiple distros (you mention MINT and Ubuntu). It is going to be a recursive circle of distro defaults for grub scripts overwriting each other otherwise.

Prior to reinstall decide which distro is going to be your lead for the bootloader. It will be necessary to let distros do their boot loader installation (e.g. Ubuntu is notoriously difficult to install without). What no distro will do is overwrite files in /boot (unless you let it format it). After you installed the next distro, you can always go boot the one you want to control the grub.cfg and re-install/update any necessary grub steps with it. While I have not run MINT/Ubuntu installers lately, this way is probably easier than trying to get one of the installers ignore installing a boot loader. After you have done that, you still need to make sure the other distro does not automatically run commands like 'grub-update', which will again create a mess, but that better wait until you have declared which one you let manage grub.
Thanks Trml. Understood. Cheers
 
The simplest way to control the order of the operating systems in the GRUB menu itself is to make sure the operating system you want as first is the one that last ran the sudo update-grub command and is currently "owning" the GRUB installation.
However, the easiest way to ensure a specific OS (like Ubuntu) is always the default selection is by editing the configuration file.
1. The Recommended Method: Edit /etc/default/grub
You need to identify the exact name or position of the Ubuntu entry in your GRUB menu. The menu entries are counted starting from 0 (zero-indexed).
A. Identify the Ubuntu Entry
First, view the generated configuration file to see the exact names of your boot entries.
* Open your Terminal in the OS that is currently controlling GRUB (usually the one you installed last).
* Run this command to list the main menu entries:
grep "menuentry " /boot/grub/grub.cfg

* Note the entry number (index) and the full entry name for Ubuntu.
* The first entry listed is 0.
* The second is 1, and so on.
* Example Output:
menuentry 'Ubuntu' {
menuentry 'Linux Mint 21.3 Cinnamon' --class linuxmint ...
menuentry 'Windows Boot Manager (on /dev/sda1)' ...

* Let's assume Ubuntu is entry 0 and Linux Mint is entry 1.
B. Edit the Default Configuration File
* Open the configuration file using a text editor (like Nano or Gedit/Pluma):
sudo nano /etc/default/grub
# OR (for a graphical editor)
# sudo gedit /etc/default/grub

* Find the line that starts with GRUB_DEFAULT=.
* Change the value to one of the following options:
| Option | Description |
|---|---|
| GRUB_DEFAULT=0 | Sets the default to the first entry (index 0). If Ubuntu is first, this is the solution. |
| GRUB_DEFAULT=1 | Sets the default to the second entry (index 1). If Mint is first and Ubuntu is second, this is the solution. |
| GRUB_DEFAULT="Ubuntu" | Sets the default using the exact menu entry title (recommended over the index number as the order can change after kernel updates). Make sure to use quotes! |
Example (to set Ubuntu as the default):
GRUB_DEFAULT="Ubuntu"

C. Save and Update GRUB
* Save the file and exit the editor.

* Update the GRUB configuration (this is the critical step that generates the new grub.cfg):
sudo update-grub

* Reboot to test the new default order.
2. The GUI Method: Grub Customizer
If you prefer a graphical interface to drag-and-drop the entries into your preferred order, you can use Grub Customizer.
* Install Grub Customizer:
sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt update
sudo apt install grub-customizer

* Run Grub Customizer: Find it in your application menu or run grub-customizer from the terminal.
* Change the Order:
* Go to the List configuration tab.
* Drag the entries (like "Ubuntu" and "Linux Mint...") into your desired 1st, 2nd, etc. order.
* Click the Save button (the disk icon) to apply the changes.
* Reboot to see the new permanent order.
Thanks Tpkusr. I am actually not all that worried about sorting out/changing the sequencing of OSs in Grub Default areas. I understand how the sequencing stuff works and how to change it. My concern is focussed on any orphan OSs that show up when I have Nuked them from the SSD.
Yes. I have seen reference elsewhere regarding Grub Customizer. It has it's Champions but there are lots of Opponents who say steer clear of it. I favour manually doing this stuff if I can manage it. Cheers
 
@JohnJ

If you are the sole user of your computer - there is a file in both Ubuntu and Mint named

/usr/share/grub/default/grub

which for the most part duplicates what you have in

/etc/default/grub

Check its content and see if it differs significantly to what you have in your grub flle.

If so, change the relevant lines to match, or comment out (with a # ) the lines that differ in the one in /usr/share

You will need to use administrative privileges to do so.

On conclusion, run

sudo update-grub

again, reboot and report back if you will what you find.

I have other ways ro let you place on top of your grub menu whichever distro you like, and/or to always open the last distro you were using.

I would not get rid of the lines that say Advanced options , and you will see why.

HTH

Wiz
Thanks Wiz. I am off for my dinner now. Will check this out tomorrow. Cheers John
 
@JohnJ

If you are the sole user of your computer - there is a file in both Ubuntu and Mint named

/usr/share/grub/default/grub

which for the most part duplicates what you have in

/etc/default/grub

Check its content and see if it differs significantly to what you have in your grub flle.

If so, change the relevant lines to match, or comment out (with a # ) the lines that differ in the one in /usr/share

You will need to use administrative privileges to do so.

On conclusion, run

sudo update-grub

again, reboot and report back if you will what you find.

I have other ways ro let you place on top of your grub menu whichever distro you like, and/or to always open the last distro you were using.

I would not get rid of the lines that say Advanced options , and you will see why.

HTH

Wiz
Great. Yes. Checked them both and they match so no point in going further re update-grub. It's interesting. I am finally getting my head around where and how Grub lives via my simple File Manager.

As a side point or two - If it's so easy to get to Grub this way and to edit things, why does everyone go though the Sudo nano ... Terminal approach? There is probably a good reason.

Also you mention that one should not '...get rid of the lines that say Advanced options.' Why is this?

cheers John
 
I've never had any trouble with Grub...because I don't touch it.
1763248176294.gif
 
Also you mention that one should not '...get rid of the lines that say Advanced options.' Why is this?

If you choose to reorder your grub menu so that the distro you prefer to have on top is different to the one currently, an easy way to do this is to go into Advanced Options and select the Recovery mode option and proceed from there. You can let me know if you want that option, or if I have mentioned that elsewhere, I'll come back with a link.

Further, you may find times when you are in need of rescue options, or using the previous kernel to boot, which likewise can be performed through there.

If you remove that option from your grub menu, that is more difficult to find.

HTH

Wiz
 
If you choose to reorder your grub menu so that the distro you prefer to have on top is different to the one currently, an easy way to do this is to go into Advanced Options and select the Recovery mode option and proceed from there. You can let me know if you want that option, or if I have mentioned that elsewhere, I'll come back with a link.

Further, you may find times when you are in need of rescue options, or using the previous kernel to boot, which likewise can be performed through there.

If you remove that option from your grub menu, that is more difficult to find.

HTH

Wiz
Thanks Wiz. Understood
cheers
John
 
If so, change the relevant lines to match, or comment out (with a # ) the lines that differ in the one in /usr/share
One point to watch out for is that updates to the grub package will overwrite changes made to /usr/share/grub/default/grub.

You are safe from this, if you sync the respective defaults in both distros /etc/default/grub instead. The file is the same, the location matters.
 
One point to watch out for is that updates to the grub package will overwrite changes made to /usr/share/grub/default/grub.

You are safe from this, if you sync the respective defaults in both distros /etc/default/grub instead. The file is the same, the location matters.
Understood. Thanks Tr. Cheers
 
Hello all. Update as follows.

Just a recap – My HP laptop has a 500GB internal SSD where all my Linux Oss have been fully installed next to each other. The exception seems to be Debian as I explain below. My laptop also has a 2TB SSD for all my data, etc.

Sooo…I entered the Bios of my laptop and from the OS Boot manager I swapped Debian for Ubuntu so Ubuntu is now ‘on top’ and fires up (pardon my technical language) instead of Debian. I did this because for some strange reason this was reversed (I definitely did not do this) so I lost my original Boot menu but still had a strange looking/different boot menu that only listed Debian as an option. When I manually swapped the Debian for Ubuntu option at the top in the Bios boot manager and restarted everything my old Boot menu returned with all my Oss – Ubuntu, Mint and Debian.

Joy O Joy I thought. So now I can Nuke my Debian partition (which strangely is only 1.94gb used compared to Mint 37gb used and Ubuntu 21.47gb used) update Grub and Debian should no longer be in the menu.

Sadly. Not so. Post Nuke and Grub update not only is Debian still on the menu but it also loads and works perfectly - despite my Nuking the Debian partition on my SSD and making it Unallocated. So where has Debian installed itself? Apparently on /dev/sda11. But where is this? I choose ‘install next to Ubuntu and Mint’ on the Debian install procedure. The Bios thinks that Debian is on (ST2000LMo7-1R8174) whatever that means.

Have attempted to post some images and other info using <>. Hope you can see them OK and that I uploaded the images the right way. Let me know if there is an appropriate/better way to attach or upload images

Cheers

John

Code:
johnj@debian:~$ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda           8:0    0   1.8T  0 disk
├─sda1        8:1    0   128M  0 part
├─sda2        8:2    0   100M  0 part
├─sda3        8:3    0   125G  0 part
├─sda4        8:4    0 249.9G  0 part
├─sda5        8:5    0 212.6G  0 part
├─sda6        8:6    0 411.6G  0 part
├─sda7        8:7    0 245.3G  0 part
├─sda8        8:8    0 189.6G  0 part
├─sda9        8:9    0 236.3G  0 part
├─sda10       8:10   0   977M  0 part /boot/efi
├─sda11       8:11   0 181.6G  0 part /
└─sda12       8:12   0   9.9G  0 part [SWAP]
nvme0n1     259:0    0 465.8G  0 disk
├─nvme0n1p1 259:1    0   512M  0 part
├─nvme0n1p2 259:2    0 109.7G  0 part
└─nvme0n1p3 259:3    0  84.2G  0 part
johnj@debian:~$ sudo fdisk -l
[sudo] password for johnj:
Disk /dev/nvme0n1: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: Samsung SSD 970 EVO Plus 500GB         
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 3A8957EA-AB59-4A9E-AD45-98C921FC7DC6

Device             Start       End   Sectors   Size Type
/dev/nvme0n1p1      2048   1050623   1048576   512M EFI System
/dev/nvme0n1p2   1050624 231192575 230141952 109.7G Linux filesystem
/dev/nvme0n1p3 800151552 976771071 176619520  84.2G Linux filesystem


Disk /dev/sda: 1.82 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: ST2000LM007-1R81
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 4EB62AB8-239F-4E67-AB7C-AB273BBE64F5

Device          Start        End   Sectors   Size Type
/dev/sda1          34     262177    262144   128M Microsoft reserved
/dev/sda2      264192     468991    204800   100M EFI System
/dev/sda3      468992  262541311 262072320   125G Microsoft basic data
/dev/sda4   262541312  786667519 524126208 249.9G Microsoft basic data
/dev/sda5   786667520 1232490495 445822976 212.6G Microsoft basic data
/dev/sda6  1232490496 2095613951 863123456 411.6G Microsoft basic data
/dev/sda7  2994849792 3509319679 514469888 245.3G Linux filesystem
/dev/sda8  3509319680 3907028991 397709312 189.6G Linux filesystem
/dev/sda9  2499233792 2994849791 495616000 236.3G Linux filesystem
/dev/sda10 2095613952 2097614847   2000896   977M EFI System
/dev/sda11 2097614848 2478411775 380796928 181.6G Linux filesystem
/dev/sda12 2478411776 2499233791  20822016   9.9G Linux swap

Partition 1 does not start on physical sector boundary.
Partition table entries are not in disk order.
johnj@debian:~$ sudo parted -l
Model: ATA ST2000LM007-1R81 (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system     Name               Flags
 1      17.4kB  134MB   134MB                                      msftres
 2      135MB   240MB   105MB   fat32                              boot, esp
 3      240MB   134GB   134GB   ntfs            DataLaptop         msftdata
 4      134GB   403GB   268GB   ntfs            PhotosLaptop       msftdata
 5      403GB   631GB   228GB   ntfs            UpdatesLaptop      msftdata
 6      631GB   1073GB  442GB   ntfs            ArchiveLaptop      msftdata
10      1073GB  1074GB  1024MB  fat32                              boot, esp
11      1074GB  1269GB  195GB   ext4
12      1269GB  1280GB  10.7GB  linux-swap(v1)                     swap
 9      1280GB  1533GB  254GB   ext4            TimeshiftLaptop
 7      1533GB  1797GB  263GB   ext4            FoxcloneLaptop
 8      1797GB  2000GB  204GB   ext4            RescuezillaLaptop


Model: Samsung SSD 970 EVO Plus 500GB (nvme)
Disk /dev/nvme0n1: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End    Size    File system  Name                  Flags
 1      1049kB  538MB  537MB   fat32        EFI System Partition  boot, esp
 2      538MB   118GB  118GB   ext4         Mint
 3      410GB   500GB  90.4GB  ext4         Ubuntu


johnj@debian:~$
johnj@debian:~$
johnj@debian:~$
johnj@debian:~$
johnj@debian:~$
johnj@debian:~$
johnj@debian:~$
johnj@debian:~$ sudo fdisk -l
Disk /dev/nvme0n1: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: Samsung SSD 970 EVO Plus 500GB         
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 3A8957EA-AB59-4A9E-AD45-98C921FC7DC6

Device             Start       End   Sectors   Size Type
/dev/nvme0n1p1      2048   1050623   1048576   512M EFI System
/dev/nvme0n1p2   1050624 231192575 230141952 109.7G Linux filesystem
/dev/nvme0n1p3 800151552 976771071 176619520  84.2G Linux filesystem


Disk /dev/sda: 1.82 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: ST2000LM007-1R81
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 4EB62AB8-239F-4E67-AB7C-AB273BBE64F5

Device          Start        End   Sectors   Size Type
/dev/sda1          34     262177    262144   128M Microsoft reserved
/dev/sda2      264192     468991    204800   100M EFI System
/dev/sda3      468992  262541311 262072320   125G Microsoft basic data
/dev/sda4   262541312  786667519 524126208 249.9G Microsoft basic data
/dev/sda5   786667520 1232490495 445822976 212.6G Microsoft basic data
/dev/sda6  1232490496 2095613951 863123456 411.6G Microsoft basic data
/dev/sda7  2994849792 3509319679 514469888 245.3G Linux filesystem
/dev/sda8  3509319680 3907028991 397709312 189.6G Linux filesystem
/dev/sda9  2499233792 2994849791 495616000 236.3G Linux filesystem
/dev/sda10 2095613952 2097614847   2000896   977M EFI System
/dev/sda11 2097614848 2478411775 380796928 181.6G Linux filesystem
/dev/sda12 2478411776 2499233791  20822016   9.9G Linux swap

Partition 1 does not start on physical sector boundary.
Partition table entries are not in disk order.
johnj@debian:~$
1763334399406.jpeg

1763334432251.jpeg

1763334497068.jpeg

1763334546040.jpeg
 


Follow Linux.org

Members online


Top