(1个U盘,1个硬盘,都装有grub。以下的hd0,hd1是从U盘启动的角度而言。如果从硬盘启动grub,hd0指硬盘,hd1指U盘;如果从U盘启动grub,反之)
U盘:(hd0,0),(hd0,1),grub安装在(hd0,1)里面从U盘启动grub:
grub> root (hd1,8) ## 指定包含vmlinuz-2.6.18-274.7.1.el5和initrd-2.6.18-274.7.1.el5.img的partition grub> kernel /boot/vmlinuz-2.6.18-274.7.1.el5 ro root=/dev/sda9 ## root= 是指定包含/sbin/init的partition,即挂载/的partition(以Linux的角度) grub> initrd /boot/initrd-2.6.18-274.7.1.el5.img ## 据说这项可以省略 grub> bootor: 不指定the partition containing the kernel
grub> kernel (hd1,8)/boot/vmlinuz-2.6.18-274.7.1.el5 ro root=/dev/sda9 grub> initrd (hd1,8)/boot/initrd-2.6.18-274.7.1.el5.img grub> boot
这里的 "xxx" 是指包含 /sbin/init 的分区,有一下几种填法:
root=/dev/sda9, 上面这种形式
root=UUID=<partition_uuid>, 安装完系统默认是这种形式
root=LABEL=<partition_label>, 见下面到例子
单独挂载到/boot
U盘:同上
硬盘:/dev/sda1(从U盘启动grub的角度是(hd1,0))挂载在/boot;/dev/sda9(相应的(hd1,8))挂载在/
从U盘启动grub:
grub> root (hd1,0) grub> kernel /vmlinuz-2.6.18-274.7.1.el5 ro root=/dev/sda9 ## 因为/dev/sda1挂载在/boot,所以kernel就不添加/boot目录 grub> initrd /initrd-2.6.18-274.7.1.el5.img grub> bootor:
grub> kernel (hd1,0)/vmlinuz-2.6.18-274.7.1.el5 ro root=/dev/sda9 grub> initrd (hd1,0)/initrd-2.6.18-274.7.1.el5.img grub> boot
grub> help ##查看所有命令的帮助信息 grub> help <cmd> ##查看某一个命令的帮助信息
grub> null (hd<Tab> Possible disks are: hd0 hd1 grub> null (hd1,<Tab> Possible partitions are: Partition num: 0, Filesystem type unknown, partition type 0x83 Partition num: 1, Filesystem type is ext2fs, partition type 0x83 grub> duyiwuer (hd0,8)/boot/vm<Tab> grub> duyiwuer (hd0,8)/boot/vmlinuz-2.6.18-274. Possible files are: vmlinuz-2.6.18-274.el5 vmlinuz-2.6.18-274.7.1.el5说明:In the preceding, the word "null" is not a keyword, but instead a word chosen because it is not a keyword. Instead of "null", you could have used "whatever" or "bogus" or any other non-keyword.("null"代表非关键字,也就是说一切非关键字都可以)
grub> find /sbin/init ## 用这种方式可以找到挂载/的分区 (hd0,8) grub> find /boot/grub/grub.conf ## /boot没有单独占分区 (hd0,8) (hd1,1)
grub> find /boot/grub/grub.conf ## 找不到文件 find /boot/grub/grub.conf Error 15: File not found grub> find /grub/grub.conf ## 正确方式 find /grub/grub.conf (hd0,0)
# The partition layout: # /dev/sda1 1 3917 31463271 7 HPFS/NTFS XP(Primary) # /dev/sda2 * 3918 7834 31463302+ 7 HPFS/NTFS Windows Server 2003(Primary) # /dev/sda3 7835 14362 52428800 7 HPFS/NTFS Windows 7(Primary) # /dev/sda4 14362 60802 373029857+ f W95 Ext'd (LBA) Extended # /dev/sda5 14362 20888 52427180+ 7 HPFS/NTFS For files # /dev/sda6 20889 46996 209712478+ 7 HPFS/NTFS For files # /dev/sda7 46997 53221 49999872 83 Linux Ubuntu Desktop(Ubuntu's grub on this partion's boot serctor) # /dev/sda8 60304 60802 3998720 82 Linux swap / Solaris # /dev/sda9 53222 60303 56886133+ 83 Linux CeotOS(CentOS's grub on sda's MBR, note: don't mix it with Ubuntu's grub) # command: rootnoverify,chainloader default=0 timeout=10 splashimage=(hd0,8)/boot/grub/splash.xpm.gz #hiddenmenu title XP rootnoverify (hd0,0) chainloader +1 title CentOS (2.6.18-274.7.1.el5) root (hd0,8) kernel /boot/vmlinuz-2.6.18-274.7.1.el5 ro root=LABEL=/ initrd /boot/initrd-2.6.18-274.7.1.el5.img title XP + Server 2003 + Windows 7 rootnoverify (hd0,1) chainloader +1 title Ubuntu Desktop rootnoverify (hd0,6) chainloader +1 title CentOS (2.6.18-274.el5) root (hd0,8) kernel /boot/vmlinuz-2.6.18-274.el5 ro root=LABEL=/ initrd /boot/initrd-2.6.18-274.el5.img
鸟哥的文档也不错, http://vbird.dic.ksu.edu.tw/linux_basic/0510osloader_3.php
GRUB - COMMAND LIST, http://linux-sxs.org/administration/grub-cmd.html
Using GRUB to load Windows XP located on a second hard disk, http://linux-sxs.org/administration/grubxp.html
GRUB, http://linux-sxs.org/administration/grub.html