CentOS 6.3 GRUB配置详解

GRUB简介
GRUB(GRand Unified Bootloader)是一种多操作系统启动加载程序,它允许用户从多个操作系统中选择要启动的系统,在CentOS 6.3系统中,GRUB是默认的启动加载程序,本文将详细介绍CentOS 6.3中GRUB的配置方法。
GRUB配置文件
CentOS 6.3的GRUB配置文件位于/etc/grub.conf,该文件包含了启动菜单的设置、默认启动选项以及各种启动参数。
修改GRUB配置
打开GRUB配置文件
使用文本编辑器打开/etc/grub.conf文件,例如使用vi编辑器:
vi /etc/grub.conf
修改默认启动选项

在default行中设置默认启动的操作系统,将default=0修改为default=1,表示默认启动第二个操作系统。
修改启动菜单超时时间
在timeout行中设置启动菜单的超时时间,将timeout=5修改为timeout=10,表示启动菜单将在10秒后自动启动默认操作系统。
添加或修改启动项 行下添加新的启动项。
root (hd0,0) kernel /vmlinuz-2.6.32-431.11.1.el6.x86_64 ro root=/dev/mapper/vg_root-lv_root initrd /initramfs-2.6.32-431.11.1.el6.x86_64.img
保存并退出编辑器
保存并退出vi编辑器,GRUB配置文件将自动更新。
重启系统
修改GRUB配置后,需要重启系统使更改生效:

shutdown -r now
GRUB配置示例
以下是一个简单的GRUB配置示例:
# grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd images for all configurations of your # system should be located in the /boot directory. # # See the grub.conf manual for details # Set default boot options default=0 timeout=5 for the first operating systemCentOS 6.3 (2.6.32-431.11.1.el6.x86_64) root (hd0,0) kernel /vmlinuz-2.6.32-431.11.1.el6.x86_64 ro root=/dev/mapper/vg_root-lv_root initrd /initramfs-2.6.32-431.11.1.el6.x86_64.img for the second operating systemWindows 7 (x86) rootnoverify (hd0,1) makeactive chainloader +1
FAQs
问题:如何查看GRUB的版本信息?解答: 使用以下命令查看GRUB的版本信息:
grub-install --version
问题:如何恢复GRUB到默认配置?解答: 可以使用以下命令恢复GRUB到默认配置:
grub-install /dev/sda

