Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I currently have Windows7 and Ubuntu 11.04 (Natty) installed on my computer. I also made a FreeBSD liveUSB (or installer, not sure; just dded their .img to the USB stick) and installed it without installing a bootloader (because I didn't want to mess up Grub2, and I thought Grub2 should be able to boot most anything). FreeBSD has it's own partition and inside that it has Freebsd partitions (maybe they are called slices?) as automatically allocated by the installer. I already tried running update-grub -- it said it was an Unknown Linux and didn't add an entry for it.

So, two questions:

  1. How can I find what partition to tell Grub using either Ubuntu tools or the USB installer stick I have?
  2. Once I find the partition, what would I put in /etc/grub.d/40_custom?
share|improve this question
    
When you say "LiveUSB", what do you mean by that? A live USB which has an image of a Live CD on it? Or did you actually install the OS onto the USB stick and not use a live image as the source of information? From my experience, GRUB does not detect installer sticks as actual Linux partitions. –  Thomas W. Jul 18 '11 at 14:28
    
I took their .img file and used dd to put it on the USB stick. It starts into a text based installer. –  Azendale Jul 18 '11 at 14:30
    
I see. That may be the issue - the system doesnt recognize the drive as an actual Linux environment. From what I can tell, FreeBSD is detected correctly when installed to the actual drive. LiveUSB installer disks are not detected as an actual linux because of the nature of those drives, from what research I have been able to find (also, from actual testing, the same can be said). –  Thomas W. Jul 18 '11 at 14:34
    
@The Evil Phoenix I installed from the USB stick. The USB stick is no longer plugged into the computer. Since writing the question, I installed ufsutils on Ubuntu. Using the CLI I can mount /dev/sda4 and /dev/sda8. They appear to have a Unix style system installed in theme. /dev/sda4 & /dev/sda8 seem to be the same. Gparted only shows /dev/sda4 (and there is no sda8 according to it), so I think /dev/sda8 may be some FreeBSD partition in /dev/sda4 and the default when you try to mount /dev/sda4? –  Azendale Jul 18 '11 at 14:44
    
@Gilles' answer should be useful to you. –  Thomas W. Jul 18 '11 at 15:12

3 Answers 3

up vote 4 down vote accepted

You have three choices: you can have Grub treat FreeBSD as some unknown OS and chainload FreeBSD's stage 1 bootloader, or you can have Grub load FreeBSD's stage 2 bootloader, or you can have Grub load the FreeBSD kernel.

Chainloading

This is the simplest and most reliable method. All you need is to install the FreeBSD bootloader on its own slice (what *BSD calls a slice is what Linux and Windows call a partition). Then Grub should find it automatically (via /etc/grub.d/30_os-prober) when you run update-grub. The entry in /boot/grub/grub.cfg would look like this (if FreeBSD is on /dev/sda2 a.k.a. /dev/wd0s2):

menuentry "FreeBSD" {
    set root=(hd0,2)
    chainloader +1
}

Loading a FreeBSD bootloader or kernel

Grub2 currently supports all major BSD kernels (assuming your computer boots from BIOS). The installation scripts don't (at least the ones shipped with Ubuntu 10.04, I haven't checked 11.04), so if you choose this route, you'll have to add your own entries via /etc/grub.d/40_Custom.

Here are sample entries from David Marec on the FreeBSD forums. I haven't tested them but they look plausible. The best method seems to be to load the FreeBSD stage 2 bootloader. You can specify the location of the FreeBSD installation as a disk number, slice number and partition a:

menuentry "FreeBSD (/boot/loader)" {
    insmod ufs2
    set root=(hd0,1,a)
    kfreebsd /boot/loader
}

or by searching a filesystem with a certain UUID, file or label:

menuentry "FreeBSD (/boot/loader)" {
    insmod ufs2
    search --no-floppy --file /boot/loader
    kfreebsd /boot/loader
}
share|improve this answer

Searching a filesystem with a certain UUID, file or label:

menuentry "FreeBSD (/boot/loader)" {
    insmod ufs2
    search --no-floppy --file --set=root /boot/loader
    kfreebsd /boot/loader
}

or:

menuentry "FreeBSD (/boot/loader)" {
    insmod ufs2
    search --no-floppy --file /boot/loader --set=root /boot/loader
    kfreebsd /boot/loader
}
share|improve this answer

Have you considered running update-grub? This will automatically update the GRUB system and its list of items for you.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.