# GRUB won't boot FreeBSD 9.1



## geek (Feb 6, 2013)

Hello. I've had a problem installing FreeBSD 9.1, because that won't boot. Therefore I installed the older FreeBSD 9.0 version, which boots fine.

I first installed the amd64 FreeBSD from the boot-only disk, but booting it with GRUB with kfreebsd /boot/kernel/kernel resulted just in having some weird characters on the screen and an immediate reboot.

I've found the same problem with VirtualBox 32-bit, except that the system won't reboot but just leave the weird screen showing. It looks like this:


----------



## ahavatar (Feb 8, 2013)

Last time I checked, booting FreeBSD with Grub only works when the disk drive is in MBR (BIOS) partition scheme. I don't know the current status of FreeBSD + Grub + UEFI booting.


----------



## serpent7776 (Feb 8, 2013)

If direct boting does not work try booting the FreeBSD loader


```
menuentry 'FreeBSD' --class freebsd --class os {
	insmod part_msdos
	insmod ufs2
	insmod chain
	set root='(hd0,msdos2)'
	chainloader +1
}
```

I am not sure whether the modules are required.


----------



## Beeblebrox (Feb 8, 2013)

> booting FreeBSD with Grub only works when the disk drive is in MBR


No. GPT works.

@geek: where is grub? Is it in some linux's root partition? That won't work and you must have a separate grub partition.

If you are multi-booting, carefully read through this thread


----------



## geek (Feb 8, 2013)

Beeblebrox said:
			
		

> No. GPT works.
> 
> @geek: where is grub? Is it in some linux's root partition? That won't work and you must have a separate grub partition.
> 
> If you are multi-booting, carefully read through this thread



My disk is MBR formatted. The grub is not on a linux root partition. And yes, I am multi-booting, currently I have Windows 7, Linux Mint and FreeBSD 9.0 on the computer. Linux and FreeBSD are installed into logical partitions. As I think I've said, I've had the problem with FreeBSD 9.1 but not with 9.0, which boots fine.

I haven't managed to get the /boot/loader thing to work.


----------



## wblock@ (Feb 8, 2013)

Unlike 9.0, FreeBSD 9.1 has KMS.  Can Grub be configured to disable or ignore that?


----------



## Beeblebrox (Feb 8, 2013)

@geek: Please post relevant section of grub.conf (FreeBSD entry)

wblock@: grub's job is to just bootstrap into the kernel. It cannot AFAIK intrude on any monolithic kernel settings, while it can request kernel modules to load.

@serpent7776: yes those modules would be needed if they were not already loaded before (not the same as kernel modules).


----------



## sossego (Feb 9, 2013)

```
menuentry "FreeBSD (or GNU/kFreeBSD), via /boot/loader" {
        insmod part_bsd
        insmod ufs1
        insmod ufs2
        set root=(hd0,3)
        chainloader   +1
}
```

That is from grub2.
The disk and partition positions/locations may not be the same as yours.


----------



## Beeblebrox (Feb 9, 2013)

Well, the "correct" way to do it is direct booting, which goes something like this, depending on a PC's particulars:

```
insmod <whatever you want, one per line>
set root=(hd0,<slice number>,a)
search --no-floppy --fs-uuid --set <uuid from blkid>
kfreebsd                 /boot/kernel/kernel
kfreebsd_loadenv         /boot/device.hints
set FreeBSD.vfs.root.mountfrom=ufs:/dev/<partition name>
set FreeBSD.vfs.root.mountfrom.options=rw
```
But geek already has this configured as he has stated in the first post.
@geek: At the top of the grub.conf file (and 1-2 other place), you should find several settings; disable those for debugging purposes. Those are set gfxpayload or gfxmode, insmod gfxterm, load_video. These are all grub's own modules to make a pretty screen. I Ä±would then normally enable verbose as below, but I'm not sure it will work.

```
kfreebsd                 /boot/kernel/kernel  verbose
```
Just make a copy of the grub.conf then delete all gfx stuff and even fonts, etc. Then try booting to FreeBSD through the qemu layer. *Do not* shut down your computer until you have replaced grub.conf with the backed-up original. For amd64 systems use qemu with (/dev/ada0 whatever your HDD is in /dev. No Slice or Partition number, just device number):
`# qemu-system-x86_64 -hda /dev/ada0`


----------



## OSeeker (Feb 10, 2013)

geek, Thank you for the post. I am having same problem with an AMD64 install. I had a 9.0 running, then upgraded to 9.1. During the internet install I lost control of the keyboard and after several hours, upon seeing no internet activity, hard shutdown. My GRUB 2.0 BSD boot file is similar to that provided by Beeblebrox. Used GRUB c option to see BSD folders and inspect some files using cat, but cannot scroll or attempt change. I can use ls (hd0,msdos3)/boot/kernel to see kernel file and device.hints files. Succeeded in booting to loader, but help does not work and I am thinking install is incomplete. Found /boot/kernel.old/kernel and booted into it as single user on command line. With this capability how do I fix BSD or reinstall? Thank you all for comments...


----------



## sossego (Feb 10, 2013)

If all else fails, find a FreeBSD live CD such as GhostBSD, the bsdinstallerCD, orone of the older live CDs. It's a suggestion- if you're not sure then ignore this suggestion.


----------



## BostonDriver (Feb 10, 2013)

I just did this myself last night.  If it helps, this is what I did to boot FreeBSD 9.1.

MY disk had FreeBSD 9.0, amd64, BIOS booted, GPT (no mbr) disk system (shared with Fedora 17) and everything worked fine since 9.0-Release came out.  Initially grub2 was from ports, but I needed Fedora for some KVM work in a hurry... I just let Fedora install it's Grub2 and taught it to find FreeBSD.  

Last night I installed FreeBSD 9.1, in doing so, deleted the old FreeBSD GPT  partitions and added them manually, using the same gpt labels.  FreeBSD 9.1 wouldn't boot using any of the grub menu entries that did work before.

After searching, and getting the menu as minimal as possible, this worked (I found it at http://slackwiki.com/Dual_Booting_With_FreeBSD_9


```
menuentry "FreeBSD" --class freebsd --class bsd --class os {
         insmod ufs2
         set root='(hd0,2)'
         kfreebsd                /boot/loader
}
```

On the GPT disk, my freebsd-ufs root filesystem is /dev/ada0p2 and freebsd-boot is /dev/ada0p1

Old entries that no longer work (I modified the uuid for the new root):


```
menuentry "FreeBSD, with kFreeBSD kernel" --class freebsd --class bsd --class os {
        insmod ufs2
        set root='(/dev/ada0p2)'
        search --no-floppy --fs-uuid --set 503e6d686fb53574
        echo                    Loading kernel of FreeBSD kernel ...
        kfreebsd                /boot/kernel/kernel
        kfreebsd_loadenv        /boot/device.hints
        set kFreeBSD.vfs.root.mountfrom=ufs:/dev/ada0p2
        set kFreeBSD.vfs.root.mountfrom.options=rw
}
```

Others:


```
menuentry "FreeBSD" --class freebsd --class bsd --class os {
	insmod ufs2
        set root='hd0,gpt2'
	kfreebsd	/boot/loader 
}

menuentry "FreeBSD-ada0p2" --class freebsd --class bsd --class os {
        insmod ufs2
        set root='(/dev/ada0p2)'
        kfreebsd        /boot/loader
}

menuentry "FreeBSD-Chain" {
    set root=(hd0,gpt2)
    chainloader +1
}

menuentry "FreeBSD-Chain-a" {
    set root=(hd0,gpt2,a)
    chainloader +1
}
```


----------

