I have a small mini PC at home running both Linux and Windows. The machine uses GRUB to choose which system to boot, and by default GRUB waits 10 seconds for a selection before continuing. That delay is not a big deal when sitting in front of the machine, but it becomes noticeable every time the system is rebooted remotely: SSH does not come back until the boot menu countdown has finished.
The fix is to adjust GRUB’s configuration and regenerate its main configuration file.
Where GRUB keeps its configuration
GRUB’s configuration is split across a few locations:
<table> <thead> <tr> <th>Path</th> <th>Purpose</th> </tr> </thead> <tbody> <tr> <td>/boot/grub/grub.cfg</td>
<td>Main GRUB configuration file</td>
</tr>
<tr>
<td>/etc/grub.d/</td>
<td>Directory containing GRUB scripts</td>
</tr>
<tr>
<td>/etc/default/grub</td>
<td>Default GRUB menu configuration</td>
</tr>
</tbody>
</table>
The file /boot/grub/grub.cfg is the configuration GRUB reads while booting. It is generated by the grub-mkconfig command and behaves like a script-style configuration file.
When grub-mkconfig runs, it reads settings from /etc/default/grub and the scripts under /etc/grub.d/, then uses them to produce a new grub.cfg file. For that reason, GRUB settings should normally be changed in /etc/default/grub or, when needed, in files under /etc/grub.d/.
Editing /boot/grub/grub.cfg directly can work, but it is not recommended, because the file may be overwritten the next time the GRUB configuration is regenerated.
Changing the default countdown
To reduce the boot menu waiting time, edit the GRUB_TIMEOUT value in /etc/default/grub. For example:
1
GRUB_TIMEOUT=5 # 设置等待时间为5秒
After saving the change, regenerate /boot/grub/grub.cfg with grub-mkconfig, or use update-grub, which is based on grub-mkconfig on systems that provide it.
Other common settings in /etc/default/grub
The same file also contains several other frequently used GRUB options:
<table> <thead> <tr> <th>Parameter</th> <th>Purpose</th> </tr> </thead> <tbody> <tr> <td>GRUB_GFXMODE</td>
<td>Graphics display mode</td>
</tr>
<tr>
<td>GRUB_BACKGROUND</td>
<td>Background image setting</td>
</tr>
<tr>
<td>GRUB_THEME</td>
<td>Theme setting</td>
</tr>
<tr>
<td>GRUB_TERMINAL</td>
<td>Use console terminal</td>
</tr>
<tr>
<td>GRUB_DEFAULT</td>
<td>Default boot entry</td>
</tr>
</tbody>
</table>
For a dual-boot machine that is often restarted remotely, simply lowering GRUB_TIMEOUT can make reboots feel much faster, especially when the default operating system is already the one you normally want to start.