Total Pageviews

Tuesday 17 January 2012

成功搞定Grub2引导基于GPT+ZFS的FreeBSD

之前一直没成功在GPT+ZFS的环境下引导FreeBSD和Linux等多系统,原因是wiki上面的指南是基于全盘ZFS的方法,而且之前也看到wiki有这么一句话:
The disadvantage of using a GPT disk is that you can't dual boot other Operating Systems using the /boot/pmbr and /boot/gptzfsboot code. You may be able to boot multiple Operating Systems using a GPT aware Grub or Grub2 setup and a Hybrid GPT/MBR Installation.

来自于:http://wiki.freebsd.org/RootOnZFS
这句话后半部分的意思应该是说如果要在GPT启动多系统,不光需要有支持GPT的Grub或者Grub2,还需要GPT/MBR的混合模式分区表。
今天发现这句话真是大大的误导,之前看到这句话,搞得我以为在GPT+ZFS环境下FreeBSD无法和其他OS共存,只能整块硬盘让给FreeBSD,今天多找了点资料,终于解决了之前蛋疼的引导问题。
要成功引导GPT+ZFS上面的FreeBSD,需要用Grub2(当然,引导基于GPT+UFS的FreeBSD是很简单的,不知道之前提过没)。至于菜单项,区别于普通UFS,应该这么写(我的GPT28分区是给了ZFS):
menuentry 'FreeBSD(ZFS)' --class freebsd --class os {
insmod part_gpt
insmod zfs
set root='(hd0,gpt28)'
search -s -l zroot
kfreebsd (hd0,gpt28)/@/boot/kernel/kernel
kfreebsd_module_elf (hd0,gpt28)/@/boot/kernel/opensolaris.ko
kfreebsd_module_elf (hd0,gpt28)/@/boot/kernel/zfs.ko
kfreebsd_module (hd0,gpt28)/@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
set kFreeBSD.vfs.root.mountfrom=zfs:zroot
set kFreeBSD.vfs.root.mountfrom.options=rw
}

当然,我这个是直接引导了FreeBSD内核,至于要怎么调出FreeBSD的菜单,待我再研究下……
这么写了以后,就能成功引导GPT+ZFS上面的FreeBSD了。

No comments:

Post a Comment