官术网_书友最值得收藏!

GRUB2

GRUB2 uses a more programmatic approach in the way the menu is presented. At first glance, GRUB2 may look intimidating, but rest assured that it's not as complicated as it appears to be. The syntax is similar to a programming language, with lots of if...then statements. Here is what /boot/grub/grub.cfg looks like on a CentOS 7 system:

[root@localhost ~]# cat /boot/grub2/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
set pager=1
if [ -s $prefix/grubenv ]; then
load_env
fi
if [ "${next_entry}" ] ; then
set default="${next_entry}"
set next_entry=
save_env next_entry
set boot_once=true
else
set default="${saved_entry}"
fi

Some of the following output is omitted for the sake of brevity in /boot/grub/grub.cfg:

### BEGIN /etc/grub.d/10_linux ###
menuentry 'CentOS Linux (3.10.0-693.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-693.el7.x86_64-advanced-16e2de7b-b679-4a12-888e-55081af4dad8' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 40c7c63f-1c93-438a-971a-5331e265419b
else
search --no-floppy --fs-uuid --set=root 40c7c63f-1c93-438a-971a-5331e265419b
fi
linux16 /vmlinuz-3.10.0-693.el7.x86_64 root=UUID=16e2de7b-b679-4a12-888e-55081af4dad8 ro crashkernel=auto rhgb quiet LANG=en_US.UTF-8
initrd16 /initramfs-3.10.0-693.el7.x86_64.img
}
### END /etc/grub.d/10_linux ###

So, to interpret the /boot/grub/grub.cfg file, we look for lines that start with menuentry. These lines start the actual menu entry for an operating system, such as a Linux distribution or a Windows OS.

Entries are enclosed within curly braces {}.
主站蜘蛛池模板: 环江| 安图县| 南华县| 中牟县| 仁化县| 太和县| 娄底市| 元氏县| 玉树县| 沂源县| 昭平县| 丹东市| 黄浦区| 石渠县| 搜索| 屏南县| 田阳县| 湟源县| 图片| 阿鲁科尔沁旗| 东方市| 巴青县| 新丰县| 乐安县| 高青县| 锡林郭勒盟| 平阳县| 锦州市| 且末县| 白河县| 梓潼县| 台山市| 多伦县| 射洪县| 鞍山市| 巴塘县| 兴化市| 天镇县| 浦县| 瓦房店市| 岑巩县|