grub初级用法
background
强烈建议阅读An introduction to GRUB2 configuration for your Linux machine。
个人notes:
- The grub.cfg file is the GRUB configuration file. Try
vim /boot/grub/grub.cfg
to see your own grub.cfg. The grub.cfg file is generated by the
grub-mkconfig
program using a set of primary configuration files and the grub default file as a source for user configuration specifications.- grub configuration files: the main set of configuration files for grub.cfg is located in the /etc/grub.d directory.
- grub default file: the /etc/default/grub
在grub2配置中,grub.cfg目录:
/boot/grub2/grub.cfg
,有些命令也有区别,例如grub2-mkconfig
,注意差异即可
GRUB configuration files
The main set of configuration files for grub.cfg is located in the /etc/grub.d directory. Each of the files in that directory contains GRUB code that is collected into the final grub.cfg file. The numbering scheme used in the names of these configuration files is designed to provide ordering so that the final grub.cfg file is assembled into the correct sequence. Each of these files has a comment to denote the beginning and end of the section, and those comments are also part of the final grub.cfg file so that it is possible to see from which file each section is generated. The delimiting comments look like this:
1 | ### BEGIN /etc/grub.d/10_linux ### |
These files should not be modified unless you are a GRUB expert and understand what the changes will do. Even then you should always keep a backup copy of the original, working grub.cfg file. The specific files, 40_custom and 41_custom are intended to be used to generate user modifications to the GRUB configuration. You should still be aware of the consequences of any changes you make to these files and maintain a backup of the original grub.cfg file.
GRUB defaults file
The /etc/default/grub file is very simple. The grub defaults file has a number of valid key/value pairs listed already. You can simply change the values of existing keys or add other keys that are not already in the file.
spec:Simple configuration handling
misc
make the Grub menu visible when booting:
1
2#GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=5set the default menu entry:
GRUB_DEFAULT
update-grub
:update-grub is a stub for runninggrub-mkconfig -o /boot/grub/grub.cfg
to generate grub.cfg file.spec:GNU GRUB Manual 2.04
阅读Getting Started Guide for ACRN Industry Scenario With Ubuntu Service VM,看看实例是如何配置grub的。