Linux typically uses GRUB2 to boot the operating system. It can manage not only various kernels, but also both Windows and Linux simultaneously.

I recently switched to a new machine. Although it's a rather unpleasant memory, the bottom line is that my family wants to use my old machine. So, a GRUB that defaults to booting Linux doesn't seem quite appropriate anymore ("You haven't even figured out Windows yet, and you want me to mess with Linux? Are you doing this on purpose?!" Mom roared.). So, let's tweak the boot order to show some goodwill.

There are many ways[1] to change it, but I think modifying grub.d is probably the most appropriate.

The specific steps are as follows:

Go to the configuration folder /etc/grub.d, and ls will show a series of executable files and a README, as shown below:

Bash
[root@localhost grub.d]# ls -al
total 76
drwx------.   2 root root  4096 Sep 27 16:56 .
drwxr-xr-x. 192 root root 12288 Sep 27 16:54 ..
-rwxr-xr-x.   1 root root  7528 Dec 21  2012 00_header
-rwxr-xr-x.   1 root root  9623 Dec 21  2012 10_linux
-rwxr-xr-x.   1 root root 10074 Dec 21  2012 20_linux_xen
-rwxr-xr-x.   1 root root  2564 Dec 21  2012 20_ppc_terminfo
-rwxr-xr-x.   1 root root  9339 Dec 21  2012 30_os-prober
-rwxr-xr-x.   1 root root   214 Dec 21  2012 40_custom
-rwxr-xr-x.   1 root root   216 Dec 21  2012 41_custom
-rw-r--r--.   1 root root   483 Dec 21  2012 README

Among them, 10_linux is the Bash script that searches for our Fedora kernels, while 30_os-prober is the Bash script that searches for other operating systems—including Windows.

GRUB is generated by executing the Bash scripts in /etc/grub.d/ in sequence to produce a grub.cfg file. The way to change the boot order is to manipulate this.

Rename 30_os-prober so it comes before 10_linux—for example, 08_os-prober will do.

Then regenerate the grub.cfg file.

First, use the command

grub2-mkconfig

to check whether the order is what we want, then replace the original grub.cfg file.

On my Fedora, the GRUB directory is /boot/grub2, so the command

grub2-mkconfig -o /boot/grub2/grub.cfg

will do.