学习多系统引导程序grub
时间:2009-08-25 来源:advancing
一,前言:
随着电脑的普及以及电脑技术日新月异的发展,人们开始不断体验技术带来的魅力,而在自己的电脑上安装多操作系统更是一种直观的表现。然而,安装多操作系统首先遇到的便是多系统引导这个问题,即当一台电脑上有了多个操作系统时,怎样才能让他们协调工作而不互相干扰。在这个问题面前,多系统引导程序grub应运而生,下面让我来简单的介绍一下
二,
GRUB
1,什么是grub
GNU GRUB 是一个多重操作系统启动管理器。用来引导不同系统,如windows,linux。
2,了解grub下设备的名称
硬盘都是用hd开始。软盘用fd开头。命名和linux不大一样。是从0算起。
(hd0,0)。表示C盘。
(hd0,4)。表示D盘。
系统的第一个硬盘驱动器表示成(hd0),其上的第一个分区表示为(hd0,0),也就是说对于硬盘,采用(hdx,y)的形式来表示,x、y都是从0开始计数的,x表示硬盘号,y表示分区号。
由于主分区只能有四个,所以第一硬盘的四个主分区分别用(hd0,0)~(hd0,3)来表示;逻辑分区则从(hd0,4)开始算,即第一逻辑分区用(hd0,4),第二逻辑分区用(hd0,5)来表示,依次类推。
一般机子的硬盘都是一个主分区,其余是逻辑分区。因此C盘用(hd0,0),D盘用(hd0,4)来表示。 光盘用(cd)表示,第一软驱用(fd0)表示。
三,下面认识一下几个常用的命令(出现于/boot/grub/menu.lst中)
color - 设定在菜单中使用的颜色,一种是作为前景色,一种作为背景色。可以简单地使用颜色名称,如red/black。比如:
color red/black green/blue
default - 默认项目的标题名称。如果菜单接口超时,那它将被载入。
fallback - 当这个命令被使用时,如果第一次尝试失败,那么这个项目的标题名称将被试用。
hiddenmenu - 这个命令被使用时,它不显示GRUB菜单接口,在超时时间过期后载入默认项。用户通过按[Esc]键,可以看到标准的GRUB菜单。
timeout - 这个命令设定了在GRUB载入由default命令指定的项目前的时间间隔,以秒为单位。
splashimage - 它指定在GRUB引导时所使用的屏幕图像的位置。
title - 设定用来装载一个操作系统的一组特定命令的标题。
字符#用来在菜单配置文件放置注释。(T002)
四,认识vmlinuz和initrd.img两个文件
Vmlinuz是内核。。它从GRUB的根文件系统载入的,如(hd0,0)。同时,后面一个选项被传给内核。它指出当Linux内核载入时,内核的根文件系统应该是位于hda5,第一个IDE硬盘的第五个分区。
initrd - 使用户能够指定一个在引导时可用的初始RAM盘。当内核为了完全引导而需要某些模块时,这是必需的。
五,演示如下:
1,打开终端
heyong@lenovo-hy-laptop:~$
2,进入boot
heyong@lenovo-hy-laptop:~$ cd /boot
heyong@lenovo-hy-laptop:/boot$
heyong@lenovo-hy-laptop:/boot$ ls
abi-2.6.28-11-generic memtest86+.bin
abi-2.6.28-12-generic System.map-2.6.28-11-generic
abi-2.6.28-15-generic System.map-2.6.28-12-generic
abi-2.6.30-020630rc3-generic System.map-2.6.28-15-generic
config-2.6.28-11-generic System.map-2.6.30-020630rc3-generic
config-2.6.28-12-generic vmcoreinfo-2.6.28-11-generic
config-2.6.28-15-generic vmcoreinfo-2.6.28-12-generic
config-2.6.30-020630rc3-generic vmcoreinfo-2.6.28-15-generic
grub vmlinuz-2.6.28-11-generic
initrd.img-2.6.28-11-generic vmlinuz-2.6.28-12-generic
initrd.img-2.6.28-12-generic vmlinuz-2.6.28-15-generic
initrd.img-2.6.28-15-generic vmlinuz-2.6.30-020630rc3-generic
initrd.img-2.6.30-020630rc3-generic
3,进入grub
heyong@lenovo-hy-laptop:/boot$ cd grub
heyong@lenovo-hy-laptop:/boot/grub$ ls
default installed-version minix_stage1_5 xfs_stage1_5
device.map jfs_stage1_5 reiserfs_stage1_5
e2fs_stage1_5 menu.lst stage1
fat_stage1_5 menu.lst~ stage2
heyong@lenovo-hy-laptop:/boot/grub$
4,查看文件menu.lst
1 # menu.lst - See: grub(8), info grub, update-grub(8)
2 # grub-install(8), grub-floppy(8),
3 # grub-md5-crypt, /usr/share/doc/grub
4 # and /usr/share/doc/grub-doc/.
5
6 ## default num
7 # Set the default entry to the entry number NUM. Numbering starts from 0, an d
8 # the entry number 0 is the default if the command is not used.
9 #
10 # You can specify 'saved' instead of a number. In this case, the default ent ry
11 # is the entry saved with the command 'savedefault'.
12 # WARNING: If you are using dmraid do not use 'savedefault' or your
13 # array will desync and will not let you boot your system.
14 default 0
15
16 ## timeout sec
17 # Set a timeout, in SEC seconds, before automatically booting the default en try
18 # (normally the first entry defined).
19 timeout 10
六,举个简单易懂的例子
这是个非常基本的用于引导Red Hat Linux或Microsoft Windows 2000的GRUB菜单配置文件可能如下所示:
default=linux
timeout=10
color=green/black light-gray/blue
# section to load linux
title linux
root (hd0,1) 这里制定了 grub的根。并且挂载。
kernel /vmlinuz root=/dev/hda5 内核是grub根下的vmlinuz。
并且内核载入后,内核的根是在/dev/hda5
boot
# section to load Windows 2000
title windows
rootnoverify (hd0,0) rootnoverify就是指定根,但是不要挂载。
chainloader +1 使用(hd0,0)的第一扇区来引导。
七,结语
朋友,希望以上内容对你有所帮助,如有错误,请你指正,我将不甚感激,谢谢。
小贺
随着电脑的普及以及电脑技术日新月异的发展,人们开始不断体验技术带来的魅力,而在自己的电脑上安装多操作系统更是一种直观的表现。然而,安装多操作系统首先遇到的便是多系统引导这个问题,即当一台电脑上有了多个操作系统时,怎样才能让他们协调工作而不互相干扰。在这个问题面前,多系统引导程序grub应运而生,下面让我来简单的介绍一下
二,
GRUB
1,什么是grub
GNU GRUB 是一个多重操作系统启动管理器。用来引导不同系统,如windows,linux。
2,了解grub下设备的名称
硬盘都是用hd开始。软盘用fd开头。命名和linux不大一样。是从0算起。
(hd0,0)。表示C盘。
(hd0,4)。表示D盘。
系统的第一个硬盘驱动器表示成(hd0),其上的第一个分区表示为(hd0,0),也就是说对于硬盘,采用(hdx,y)的形式来表示,x、y都是从0开始计数的,x表示硬盘号,y表示分区号。
由于主分区只能有四个,所以第一硬盘的四个主分区分别用(hd0,0)~(hd0,3)来表示;逻辑分区则从(hd0,4)开始算,即第一逻辑分区用(hd0,4),第二逻辑分区用(hd0,5)来表示,依次类推。
一般机子的硬盘都是一个主分区,其余是逻辑分区。因此C盘用(hd0,0),D盘用(hd0,4)来表示。 光盘用(cd)表示,第一软驱用(fd0)表示。
三,下面认识一下几个常用的命令(出现于/boot/grub/menu.lst中)
color - 设定在菜单中使用的颜色,一种是作为前景色,一种作为背景色。可以简单地使用颜色名称,如red/black。比如:
color red/black green/blue
default - 默认项目的标题名称。如果菜单接口超时,那它将被载入。
fallback - 当这个命令被使用时,如果第一次尝试失败,那么这个项目的标题名称将被试用。
hiddenmenu - 这个命令被使用时,它不显示GRUB菜单接口,在超时时间过期后载入默认项。用户通过按[Esc]键,可以看到标准的GRUB菜单。
timeout - 这个命令设定了在GRUB载入由default命令指定的项目前的时间间隔,以秒为单位。
splashimage - 它指定在GRUB引导时所使用的屏幕图像的位置。
title - 设定用来装载一个操作系统的一组特定命令的标题。
字符#用来在菜单配置文件放置注释。(T002)
四,认识vmlinuz和initrd.img两个文件
Vmlinuz是内核。。它从GRUB的根文件系统载入的,如(hd0,0)。同时,后面一个选项被传给内核。它指出当Linux内核载入时,内核的根文件系统应该是位于hda5,第一个IDE硬盘的第五个分区。
initrd - 使用户能够指定一个在引导时可用的初始RAM盘。当内核为了完全引导而需要某些模块时,这是必需的。
五,演示如下:
1,打开终端
heyong@lenovo-hy-laptop:~$
2,进入boot
heyong@lenovo-hy-laptop:~$ cd /boot
heyong@lenovo-hy-laptop:/boot$
heyong@lenovo-hy-laptop:/boot$ ls
abi-2.6.28-11-generic memtest86+.bin
abi-2.6.28-12-generic System.map-2.6.28-11-generic
abi-2.6.28-15-generic System.map-2.6.28-12-generic
abi-2.6.30-020630rc3-generic System.map-2.6.28-15-generic
config-2.6.28-11-generic System.map-2.6.30-020630rc3-generic
config-2.6.28-12-generic vmcoreinfo-2.6.28-11-generic
config-2.6.28-15-generic vmcoreinfo-2.6.28-12-generic
config-2.6.30-020630rc3-generic vmcoreinfo-2.6.28-15-generic
grub vmlinuz-2.6.28-11-generic
initrd.img-2.6.28-11-generic vmlinuz-2.6.28-12-generic
initrd.img-2.6.28-12-generic vmlinuz-2.6.28-15-generic
initrd.img-2.6.28-15-generic vmlinuz-2.6.30-020630rc3-generic
initrd.img-2.6.30-020630rc3-generic
3,进入grub
heyong@lenovo-hy-laptop:/boot$ cd grub
heyong@lenovo-hy-laptop:/boot/grub$ ls
default installed-version minix_stage1_5 xfs_stage1_5
device.map jfs_stage1_5 reiserfs_stage1_5
e2fs_stage1_5 menu.lst stage1
fat_stage1_5 menu.lst~ stage2
heyong@lenovo-hy-laptop:/boot/grub$
4,查看文件menu.lst
1 # menu.lst - See: grub(8), info grub, update-grub(8)
2 # grub-install(8), grub-floppy(8),
3 # grub-md5-crypt, /usr/share/doc/grub
4 # and /usr/share/doc/grub-doc/.
5
6 ## default num
7 # Set the default entry to the entry number NUM. Numbering starts from 0, an d
8 # the entry number 0 is the default if the command is not used.
9 #
10 # You can specify 'saved' instead of a number. In this case, the default ent ry
11 # is the entry saved with the command 'savedefault'.
12 # WARNING: If you are using dmraid do not use 'savedefault' or your
13 # array will desync and will not let you boot your system.
14 default 0
15
16 ## timeout sec
17 # Set a timeout, in SEC seconds, before automatically booting the default en try
18 # (normally the first entry defined).
19 timeout 10
六,举个简单易懂的例子
这是个非常基本的用于引导Red Hat Linux或Microsoft Windows 2000的GRUB菜单配置文件可能如下所示:
default=linux
timeout=10
color=green/black light-gray/blue
# section to load linux
title linux
root (hd0,1) 这里制定了 grub的根。并且挂载。
kernel /vmlinuz root=/dev/hda5 内核是grub根下的vmlinuz。
并且内核载入后,内核的根是在/dev/hda5
boot
# section to load Windows 2000
title windows
rootnoverify (hd0,0) rootnoverify就是指定根,但是不要挂载。
chainloader +1 使用(hd0,0)的第一扇区来引导。
七,结语
朋友,希望以上内容对你有所帮助,如有错误,请你指正,我将不甚感激,谢谢。
小贺
相关阅读 更多 +
排行榜 更多 +