取得Grub安装文件,比如:grub-0.5.93.1-51p.i386.rpm
安装:rpm -ivh grub-0.5.93.1-51p.i386.rpm
一般会产生一下文件:
/boot/grub/e2fs_stage1_5
/boot/grub/fat_stage1_5
/boot/grub/ffs_stage1_5
/boot/grub/minix_stage1_5
/boot/grub/stage1
/boot/grub/stage_lba
/boot/grub/stage_2
/usr/sbin/grub
......
将grub安装到MBR中
先运行Grub
# grub
则会产生如下提示符
grub>
可键入命令
install (hd0,5)/boot/grub/stage1 d (hd0) (hd0,5)/boot/grub/stage2 p (hd0,5)/boot/grub/menu.lst
接下来用quit命令退出grub作如下工作
创建文件install.sh,menu.lst,device.map,messages
文件内容如下:(方括号内的内容不包括)
install.sh:
[BEGIN]
grub --device-map=/boot/grub/device.map --batch <<EOF
install (hd0,5)/boot/grub/stage1 d (hd0) (hd0,5)/boot/grub/stage2 p(hd0,5)/boot/grub/menu.lst
quit
EOF
[END]
messages:
[BEGIN]
Welcome to GRUB the operating system chooser!
use the 5c and %c keys for selecting which entry is highlighted.
Press enter to boot the selected OS,'e' to edit the commands before booting or 'c' for a command-line.
The highlighted entry will be booted automatically in %d seconds.
[END]
device.map:
[BEGIN]
(fd0) /dev/fd0
(fd1) /dev/fd1
(hd0) /dev/hda
[END]
menu.lst:
[BEGIN]
timeout 5
color black/cyan yellow/cyan
i18n (hd0,5)/boot/grub/messages
keytable (hd0,5(/boot/us.klt
default 1
title linux
kernel (hd0,5)/boot/vmlinuz root=/dev/hda6
title windows
root (hd0,0)
makeactive
chainloader =1
title floppy
root (fd0)
chainloader +1
[END]
好了,reboot就可以了。这里已我的分区为例子
hda1 (hd0,0) (即C:) windows2000 fat32
hda6 (hd0,5) Linux根节点挂载区 Redhat Linux 7.1 ext2
如果重装Windows则MBR中的内容会被改写所以必须创建Linux引导盘
引导进入Linux后,运行grub,键入命令makebootable就可以将grub重新写入MBR了
也可以命令行引导系统:
如:
引导Windows:
grub> root (hd0,0)
grub> chainloader (hd0,0) =1
grub> boot
引导Linux:
grub> root (hd0,5)
grub> kernel /boot/vmlinuz root=/dev/hda6
grub> boot
也可以制作个grub引导软盘:
# dd if=stage1 of=/dev/fd0 bs=512 count=1
# dd if=stage2 of=/dev/fd0 bs=512 seek=1
[ 此贴被XChinux在2005-08-29 12:09重新编辑 ]