grub安装 --安恒网管员手记
2005-03-09    刘世伟   
打印自: 安恒公司
地址: HTTP://www.anheng.com.cn/news/article.php?articleid=805
grub安装 --安恒网管员手记

在grub下, 磁盘的命名是bsd格式,

hd0是第一个盘,hd1第二个盘, hd1可能是hdb也可能是hdc也可能是sda

hd0,0是第一分区, hd0,0 是 /dev/hda1 hd0,1 是 /dev/hda2 .... hd0,5 是 /dev/hda6....

grub的有一个自己的命令界面,在启动时,安c可以进入, 或者在linux下直接执行grub出现命令界面.

grub下的命令支持tab补全. 也可以用tab对文件名进行补全.

在grub命令界面, 常用的几个命令有:

root (hd0,0) ;指定/dev/hda1做为根

kernel /boot/vmlinuz root=.... ;指定要调入的内核 以及参数

initrd /boot/initrd.img ;指定ramfs启动映像

boot ;开始启动

;上面几条可以从一个不能启动硬盘恢复启动.

setup ;此命令,可以用于在grub命令界面向硬盘安装grub启动支持.

faq:

问:我已经在用文件复制 在/dev/hdc6 建立了一个linux系统,如何让它可以启动?

答:将grub安装到mbr,以下命令,

#:grub
Probing devices to guess BIOS drives. This may take a long time.

GNU GRUB version 0.97 (640K lower / 3072K upper memory)

[ Minimal BASH-like line editing is supported. For
the first word, TAB lists possible command
completions. Anywhere else TAB lists the possible
completions of a device/filename. ]
grub>root (hd1,5) ;指定根是/dev/hdc6
Filesystem type is ext2fs, partition type 0x83
grub>setup (hd1)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
....
grub>quit

直接用grub-install来安装:

mount /dev/hdc1 /2 ;先把要安装grub的根mount

grub-install /2 /dev/hdc ;装grub到hdc硬盘  

制作一个grub软盘:

grub-floppy /dev/fd0 

责任编辑: 刘世伟