How do I set the order of systems in grub?

There are 3 systems: Windows, Linux Mint, and Debian.

Now the download list looks something like this:

Windows
Debian
Дополнительные параметры для Debian
Linux Mint
Дополнительные параметры для Linux Mint
memtest
memtest serial console

How do I make Linux Mint the second one?

Windows
Linux Mint
Дополнительные параметры для Linux Mint
Debian
Дополнительные параметры для Debian
memtest
memtest serial console

And is it even possible to get the following order?

Windows
Linux Mint
Debian
Дополнительные параметры для Linux Mint
Дополнительные параметры для Debian
memtest
memtest serial console

Windows and Debian are installed on the first physical disk (MBR)
Linux Mint is installed on a second physical disk (GPT)
UEFI no, booting from the first disk.

Grub enastraivayu from Mint.


The file renaming suggested in the comments doesn't help:

qwertiy-Z68AP-D3 grub.d # ls -l .
итого 92
-rwxr-xr-x 1 root root  9424 мая   13 21:33 00_header
-rwxr-xr-x 1 root root 11692 мая   13 21:33 03_os-prober
-rwxr-xr-x 1 root root  1180 окт.  25  2014 06_mint_theme
-rwxr-xr-x 1 root root 11620 нояб.  8  2015 10_linux
-rwxr-xr-x 1 root root 10634 окт.   1  2012 10_lupin
-rwxr-xr-x 1 root root  6058 мая   13 17:51 15_debian_theme
-rwxr-xr-x 1 root root 10412 мая   13 21:33 20_linux_xen
-rwxr-xr-x 1 root root  1992 марта 12  2014 20_memtest86+
-rwxr-xr-x 1 root root  1416 мая   13 21:33 30_uefi-firmware
-rwxr-xr-x 1 root root   214 мая   13 21:33 40_custom
-rwxr-xr-x 1 root root   216 мая   13 21:33 41_custom
-rw-r--r-- 1 root root   483 мая   13 21:33 README
qwertiy-Z68AP-D3 grub.d # update-grub
Generating grub configuration file ...
  No volume groups found
Найден Windows 7 (loader) на /dev/sda1
Найден Debian GNU/Linux (6.0.10) на /dev/sda5
Найден образ linux: /boot/vmlinuz-3.16.0-38-generic
Найден образ initrd: /boot/initrd.img-3.16.0-38-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
завершено
qwertiy-Z68AP-D3 grub.d # 

In /boot/grub/grub.cfg found that Debian is inside

### BEGIN /etc/grub.d/03_os-prober ###
### END /etc/grub.d/03_os-prober ###

So, it finds Windows and Debian together and manipulating the file order will lead to nothing?

Author: aleksandr barakin, 2015-11-07

1 answers

You can swap the menuentry sections in /boot/grub/grub.cfg as needed. this file is read (and interpreted) by the loader at each launch directly, i.e. the file changes are "picked up on the fly".

Syntax of the section:

menuentry "заголовок" [опции] { команды }

Sections menuentry can be nested in sections submenu (sub-menu). the resulting file may look like this, for example:

submenu "заголовок" [опции] {
  menuentry "заголовок" [опции] { команды }
  menuentry "заголовок" [опции] { команды }
}
menuentry "заголовок" [опции] { команды }

Drawback: executing the script /usr/sbin/update-grub will return the order of the records "back to normal". a is called this script, at least, when updating packages with programs linux and grub.


Supplement

They also write that you can use the grub-customizer package, among the features of which:

  • move, remove or rename menuentries (they stey updatable by update-grub)

Disadvantage: judging by the information from packages.ubuntu.com, this package is not included in any of the supported ones repositories.


Supplement 2

So that the file /boot/grub/grub.cfg is not overwritten when updating packages with the program linux, you can replace this file name with some other one in the script /usr/sbin/update-grub (for example, /boot/grub/grub.cfg.new), and update the file manually. replacement example:

$ cat /usr/sbin/update-grub
#!/bin/sh
set -e
exec grub-mkconfig -o /boot/grub/grub.cfg.new "$@"

Disadvantages:

  • you will have to manually keep the /boot/grub/grub.cfg file up-to-date (based on changes in /boot/grub/grub.cfg.new).
  • when updating the package grub2-common (or another one containing the mentioned script /usr/sbin/update-grub), you will have to correct both /usr/sbin/update-grub and /boot/grub/grub.cfg again.
 2
Author: aleksandr barakin, 2015-11-08 13:58:46