#
# 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 paths are relative to /boot/, eg.
# root (hd0,9)
# kernel /vmlinuz-version ro root=/dev/mapper/vg_yangcentos-lv_root
# initrd /initrd-[generic-]version.img
#boot=/dev/sdb
default=0
timeout=5
splashimage=(hd0,9)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-431.5.1.el6.i686)
root (hd0,9)
kernel /vmlinuz-2.6.32-431.5.1.el6.i686 ro root=/dev/mapper/vg_yangcentos-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_yangcentos/lv_swap rd_NO_MD rd_LVM_LV=vg_yangcentos/lv_root SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-431.5.1.el6.i686.img
title CentOS (2.6.32-358.23.2.el6.i686)
root (hd0,9)
kernel /vmlinuz-2.6.32-358.23.2.el6.i686 ro root=/dev/mapper/vg_yangcentos-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_yangcentos/lv_swap rd_NO_MD rd_LVM_LV=vg_yangcentos/lv_root SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-358.23.2.el6.i686.img
title CentOS (2.6.32-358.14.1.el6.i686)
root (hd0,9)
kernel /vmlinuz-2.6.32-358.14.1.el6.i686 ro root=/dev/mapper/vg_yangcentos-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_yangcentos/lv_swap rd_NO_MD rd_LVM_LV=vg_yangcentos/lv_root SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-358.14.1.el6.i686.img
title CentOS (2.6.32-358.11.1.el6.i686)
root (hd0,9)
kernel /vmlinuz-2.6.32-358.11.1.el6.i686 ro root=/dev/mapper/vg_yangcentos-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_yangcentos/lv_swap rd_NO_MD rd_LVM_LV=vg_yangcentos/lv_root SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-358.11.1.el6.i686.img
title CentOS (2.6.32-358.el6.i686)
root (hd0,9)
kernel /vmlinuz-2.6.32-358.el6.i686 ro root=/dev/mapper/vg_yangcentos-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_yangcentos/lv_swap rd_NO_MD rd_LVM_LV=vg_yangcentos/lv_root SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-358.el6.i686.img
title Other
rootnoverify (hd0,0)
chainloader +1
其中:
1,default=0
表示默认启动的第0号的操作系统,在GRUB中,title定义了启动的操作系统,从第1个开始,GRUB中是0,而第2个是1,依次类推...
2,timeout=5
表示的是出现GRUB界面后,无操作情况下进入default设定的操作系统的时间,如果上下移动选择,则该选项无效
3,splashimage=(hd0,9)/boot/grub/splah.xpm.gz
表示的是允许出现的GRUB背景的path,显然(hd0,9)指定了分区(不知能否这么解释,呵呵),而后边的则是正常的path(在例子中,用#把它注释,为一可选项)
4,hiddenmenu
表示隐藏GRUB的启动菜单,直接进入由default庙宇的操作系统中去,为一可选项.
linux类
其格式一般为:
title (......)
root (hd[0-n],x)
kernel (......)
initrd (......)
其中:
title行,是定义一个启动操作系统,而后边可以自己随便写上喜欢的名字,呵,当然最起码你得写得要自己能认出来,没必要把linux写成windows吧?!
root行,指定相应的linux所有的/boot,如果在写分区和挂载时没有单独挂载,那么就和/在同一个分区中,hd[0-n]表示的是第几个硬盘,而x则表示的是[第几个分区-1],即x比分区号小1,特别要注意.
kernel行,在这里以kernel 起始,指定Linux的内核的文件所处的绝对路径(通过在终端输入命令:ls /boot/vmlinuz*来看内核的全名);因为内核是处在/boot目录中的,而如果/boot是独立的一个分区,则需要把boot省略,因为 /boot所在的分区在root (hd[0-n],x)中指定了,所以就无需要再指明内核处在哪个分区了;ro 表示只读;root=LABEL=/ 来表示Linux的根所处的分区。LABEL=/ 这是硬盘分区格式化为相应文件系统后所加的标签;如果您不了解什么是标签,也可以直接以/dev/hd[a-z]X 或者/dev/sd[a-z]X来表示;就看您的Linux是根分区是在哪个分区了。比如我的是在/dev/hda10, 那这里就可以写成root=/dev/hda10;
initrd行,如果是/boot独立一个分区,initrd 一行要把/boot中省略;如果/boot不是处于一个分区,而是和Linux的/分区处于同一分区,不应该省略;我们通过查看/boot中的 initrd的文件名到底是什么来写这一行代码,在终端输入:ls /boot/initrd*
很容易能得到initrd文件名,然后写入.
在了解了以上情况之后,我们就很容易地理解另一种写法了:
title (......)
kernel (hd[0-n],y)(/boot)...... ro root=......
initrd (hd[0-n],y)(/boot)......
其实只是省略的root很实在地写在了kernel和initrd行中去了而已
附:
其 实在GRUB启动菜单不能工作的时候,进入GRUB命令行(可按CTRL+C键)后,我们同样可以一步一步地把系统启动起来,其实在menu.lst中, 除title不是指令外,其余的都是GRUB指令,我们只要一步步地输入它们(错了要从新开始),中间输入关于kernel和 initrd要利用
TAB键补齐写好,最后只要boot一下就行了.
用GRUB指令引导windows:
GRUB> rootnoverify (hd0,0)
GRUB> chainloader +1
GRUB> boot
表示的是出现GRUB界面后,无操作情况下进入default设定的操作系统的时间,如果上下移动选择,则该选项无效
随着linux系统的不断升级,启动项里面有很多版本,从上面menu.lst和grub.conf可以看出有5个版本,用以下命令查询当前安装版本的安装包:
[root@yang-centos boot]# rpm -qa | grep kernel
kernel-2.6.32-358.23.2.el6.i686
kernel-2.6.32-358.el6.i686
kernel-devel-2.6.32-358.el6.i686
abrt-addon-kerneloops-2.0.8-21.el6.centos.i686
kernel-firmware-2.6.32-431.5.1.el6.noarch
dracut-kernel-004-336.el6_5.2.noarch
kernel-2.6.32-431.5.1.el6.i686
kernel-devel-2.6.32-431.5.1.el6.i686
kernel-2.6.32-358.14.1.el6.i686
kernel-headers-2.6.32-431.5.1.el6.i686
kernel-devel-2.6.32-358.14.1.el6.i686
libreport-plugin-kerneloops-2.0.9-19.el6.centos.i686
kernel-2.6.32-358.11.1.el6.i686
kernel-devel-2.6.32-358.23.2.el6.i686
kernel-devel-2.6.32-358.11.1.el6.i686
2.6.32-431为最新版本,2.6.32-358.***都是旧版本,下面的命令卸载所有的旧版本,只保留2.6.32-431
[root@yang-centos boot]# a=$((rpm -qa | grep kernel) | grep 2.6.32-358)
[root@yang-centos boot]# yum remove $a
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check #卸载的版本
---> Package kernel.i686 0:2.6.32-358.el6 will be erased
---> Package kernel.i686 0:2.6.32-358.11.1.el6 will be erased
---> Package kernel.i686 0:2.6.32-358.14.1.el6 will be erased
---> Package kernel.i686 0:2.6.32-358.23.2.el6 will be erased
---> Package kernel-devel.i686 0:2.6.32-358.el6 will be erased
---> Package kernel-devel.i686 0:2.6.32-358.11.1.el6 will be erased
---> Package kernel-devel.i686 0:2.6.32-358.14.1.el6 will be erased
---> Package kernel-devel.i686 0:2.6.32-358.23.2.el6 will be erased
--> Finished Dependency Resolution
查看menu.lst文件,可以看到现在只有2.6.32-431一个linux选项了,另一个是windows 7的选项
[root@yang-centos boot]# cat ./grub/menu.lst
# 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 paths are relative to /boot/, eg.
# root (hd0,9)
# kernel /vmlinuz-version ro root=/dev/mapper/vg_yangcentos-lv_root
# initrd /initrd-[generic-]version.img
#boot=/dev/sdb
default=0
timeout=10
splashimage=(hd0,9)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-431.5.1.el6.i686)
root (hd0,9)
kernel /vmlinuz-2.6.32-431.5.1.el6.i686 ro root=/dev/mapper/vg_yangcentos-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_yangcentos/lv_swap rd_NO_MD rd_LVM_LV=vg_yangcentos/lv_root SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-431.5.1.el6.i686.img
title Windows 7
rootnoverify (hd0,0)
chainloader +1
[root@yang-centos boot]#