I have confirmed basic operation of grub2. What about as an alternative sys-freebsd/boot0 can not be compiled gcc version 4.6 or later. I have confirmed can boot directly using grub2 in the following environments. * FreeBSD 9.1-RC2 amd64 * gcc-4.6.3 * patched grub-2.00 * BIOS/GPT (FYI, https://wiki.gentoo.org/wiki/Gentoo_FreeBSD#If_you_want_to_use_the_UFS2_file_system_.28GPT.29 ) * UFS2 How to use 1. layman -a gentoo-bsd 2. echo 'source /var/lib/layman/make.conf' >> /etc/portage/make.conf 3. ACCEPT_KEYWORDS=~amd64 USE="-nls -device-mapper -mount" emerge -va sys-boot/grub::gentoo-bsd 4. grub2-install --modules="part_gpt fat ufs2" --no-floppy /dev/ada0 5. grub2-mkconfig -o /boot/grub2/grub.cfg I'm not confirm ZFS and other operation yet. please test! and please update the patches. thanks in advance.
Created attachment 328544 [details, diff] files/grub-2.00-fbsd.patch * Added support freebsd-boot partition on GPT. * FreeBSD's sed doesn't support '\t', change to tab. * grub2-probe is used instead of grub-probe on Gentoo. Taken from FreeBSD ports (I made some changes for grub-2.00) patch-include-grub-gpt_partition.h patch-util-i386-pc-grub-setup.c patch-util-grub.d-10_kfreebsd.in
Created attachment 328546 [details, diff] files/grub-2.00-fbsd91-boot.patch Fix to boot directly. Taken from http://people.freebsd.org/~nox/tmp/grub2-paste_180121.patch FYI, http://www.freebsd.org/cgi/query-pr.cgi?pr=170417&cat=ports
Created attachment 328548 [details, diff] patch for grub-2.00-r1.ebuild use elibc_FreeBSD && append-cppflags "-isystem /usr/include" to fix the following problems. x86_64-gentoo-freebsd9.1-gcc -DHAVE_CONFIG_H -I. -I/var/tmp/portage/sys-boot/grub-2.00-r1/work/grub-2.00/grub-core -I.. -Wall -W -I/var/tmp/portage/sys-boot/grub-2.00-r1/work/grub-2.00/include -I../include -DGRUB_MACHINE_PCBIOS=1 -DGRUB_MACHINE=I386_PC -DGRUB_TARGET_CPU_I386=1 -m32 -nostdinc -isystem /usr/lib/gcc/x86_64-gentoo-freebsd9.1/4.6.3/include -DGRUB_FILE=\"fs/btrfs.c\" -I. -I/var/tmp/portage/sys-boot/grub-2.00-r1/work/grub-2.00/grub-core -I.. -I/var/tmp/portage/sys-boot/grub-2.00-r1/work/grub-2.00 -I/var/tmp/portage/sys-boot/grub-2.00-r1/work/grub-2.00/include -I../include -I/var/tmp/portage/sys-boot/grub-2.00-r1/work/grub-2.00/grub-core/lib/posix_wrap -I/var/tmp/portage/sys-boot/grub-2.00-r1/work/grub-2.00/grub-core/lib/minilzo -DMINILZO_HAVE_CONFIG_H -Os -Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Waddress -Wattributes -Wcast-align -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wempty-body -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-noreturn -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -falign-jumps=1 -falign-loops=1 -falign-functions=1 -mno-mmx -mno-sse -mno-sse2 -mno-3dnow -fno-dwarf2-cfi-asm -fno-asynchronous-unwind-tables -m32 -fno-stack-protector -mno-stack-arg-probe -Wno-trampolines -mrtd -mregparm=3 -ffreestanding -fno-builtin -Wno-undef -c -o fs/btrfs_module-btrfs.o `test -f 'fs/btrfs.c' || echo '/var/tmp/portage/sys-boot/grub-2.00-r1/work/grub-2.00/grub-core/'`fs/btrfs.c In file included from /var/tmp/portage/sys-boot/grub-2.00-r1/work/grub-2.00/grub-core/lib/minilzo/lzoconf.h:56:0, from /var/tmp/portage/sys-boot/grub-2.00-r1/work/grub-2.00/grub-core/lib/minilzo/minilzo.h:60, from /var/tmp/portage/sys-boot/grub-2.00-r1/work/grub-2.00/grub-core/fs/btrfs.c:29: /usr/lib/gcc/x86_64-gentoo-freebsd9.1/4.6.3/include/stddef.h:59:24: fatal error: sys/_types.h: No such file or directory compilation terminated. gmake[3]: *** [fs/btrfs_module-btrfs.o] Error 1 gmake[3]: Leaving directory `/var/tmp/portage/sys-boot/grub-2.00-r1/work/build-guessed/grub-core' gmake[2]: *** [all] Error 2 gmake[2]: Leaving directory `/var/tmp/portage/sys-boot/grub-2.00-r1/work/build-guessed/grub-core' gmake[1]: *** [all-recursive] Error 1 gmake[1]: Leaving directory `/var/tmp/portage/sys-boot/grub-2.00-r1/work/build-guessed' gmake: *** [all] Error 2
These patches should be applied unconditionally. A scenario in which the conditional patching based on elibc_FreeBSD would cause a problem would be a dual-boot between Gentoo Linux and Gentoo FreeBSD where the Gentoo Linux package is used.
Created attachment 328650 [details, diff] patch for grub-2.00-r1.ebuild (In reply to comment #4) > These patches should be applied unconditionally. A scenario in which the > conditional patching based on elibc_FreeBSD would cause a problem would be a > dual-boot between Gentoo Linux and Gentoo FreeBSD where the Gentoo Linux > package is used. Thank you for your comment. I attach a new patch. Fix patch for FreeBSD to be applied all environments. I made the following changes in addition. RDEPEND+=" - grub_platforms_efi-32? ( sys-boot/efibootmgr ) - grub_platforms_efi-64? ( sys-boot/efibootmgr ) + kernel_linux? ( + grub_platforms_efi-32? ( sys-boot/efibootmgr ) + grub_platforms_efi-64? ( sys-boot/efibootmgr ) + ) "
Update the status of operation check. BIOS/GPT/UFS2, boot directly ok. see comment #0 BIOS/MBR/UFS2, boot directly ok. grub2-install --modules="biosdisk part_msdos bsd search_fs_uuid ufs2 msdospart" --no-floppy /dev/ada0 NOTE, You need to create a free space when creating partitions in order to successfully install grub2. # gpart add -b 1024k -t freebsd ada0 => 63 23068609 ada0 MBR (11G) 63 2016 - free - (1M) 2079 23066568 1 freebsd [active] (11G) 23068647 25 - free - (12k) BIOS/GPT/ZFS, boot directly ok. Patch needs to be updated. I'll attach it, and also update patch on overlay. grub2-install --modules="part_gpt fat zfs" --no-floppy /dev/ada0 If you want to install the modules of larger capacity may not be enough free space. I would like to change to reserve 1MB of free space in the description on the wiki... The error message is as follows. /usr/sbin/grub2-bios-setup: warning: your BIOS Boot Partition is too small; embedding won't be possible. /usr/sbin/grub2-bios-setup: error: embedding is not possible, but this is required for cross-disk install.
Created attachment 328656 [details] When static enabled, fails to link libgeom -- log Information whether you can build [ebuild R ] sys-boot/grub-2.00-r1::x-portage USE="debug doc efiemu nls sdl truetype -custom-cflags -device-mapper (-libzfs) -mount -static" GRUB_PLATFORMS="coreboot efi-32 efi-64 ieee1275 multiboot pc qemu -emu -qemu-mips -yeeloong" 0 kB USE flag device-mapper and mount, probably only on linux. please add to package.use.mask or use.mask. device-mapper depends lvm2 and util-linux. mount depends fuse and fuse4bsd. When you enable USE flag static, it can not be compiled. In the following the error message. details, please see attached log. checking for geom_gettree in -lgeom... no configure: error: Your platform requires libgeom GRUB_PLATFORM I have confirmed build of platforms other than those listed below. qemu-mips yeeloong CPU doesn't support emu Linux only ? /var/tmp/portage/sys-boot/grub-2.00-r1/work/grub-2.00/grub-core/net/drivers/emu/emunet.c:24:22: fatal error: linux/if.h: No such file or directory
Created attachment 328658 [details, diff] files/grub-2.00-fbsd.patch fix for grub2-mkconfig to work correctly on ZFS environment
This looks good to me. floppym is the GRUB2 maintainer, so I am turning this over to him.
(In reply to comment #2) > Created attachment 328546 [details, diff] [details, diff] > files/grub-2.00-fbsd91-boot.patch > This has been applied upstream in revision 4556, so I have no problem applying it. (In reply to comment #8) > Created attachment 328658 [details, diff] [details, diff] > files/grub-2.00-fbsd.patch I would feel much more comfortable applying this patches if you would get it committed upstream first. I suggest breaking this into 2 patches: one for the partmap changes, and another for the changes to 10_kfreebsd.in. Instead of hard-coding "grub2-probe", please use the ${grub_probe} variable, as is done in 10_linux.in.
(In reply to comment #10) > (In reply to comment #8) > > Created attachment 328658 [details, diff] [details, diff] [details, diff] > > files/grub-2.00-fbsd.patch > > I would feel much more comfortable applying this patches if you would get it > committed upstream first. > > I suggest breaking this into 2 patches: one for the partmap changes, and > another for the changes to 10_kfreebsd.in. Thanks for your comment. gpart support bios-boot partition type. so, patch to support the freebsd-boot partition is not required. I had to remove patches of grub-core/partmap/gpt.c and include/grub/gpt_partition.h. Please change the partition type before you run the grub2-install. # gpart modify -i 1 -t bios-boot ada0 FYI, http://svnweb.freebsd.org/base/releng/9.1/sys/geom/part/g_part.c?r1=217040&r2=218014 > Instead of hard-coding "grub2-probe", please use the ${grub_probe} variable, > as is done in 10_linux.in. I reported to upstream, updated patch for 10_kfreebsd.in. Please see URL. NOTE, \t problem is fixed in upstream, rev 4584 http://bzr.savannah.gnu.org/lh/grub/trunk/grub/revision/4584
Created attachment 334396 [details, diff] files/grub-2.00-fbsd.patch Issue has been resolved in the upstream. I'll attach a new patch. FYI, http://bzr.savannah.gnu.org/lh/grub/trunk/grub/revision/4556 http://bzr.savannah.gnu.org/lh/grub/trunk/grub/revision/4584 http://bzr.savannah.gnu.org/lh/grub/trunk/grub/revision/4624 http://bzr.savannah.gnu.org/lh/grub/trunk/grub/revision/4625
Ok I think I have applied everything that needed to be applied.