Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › FreeBSD booting with grub
New Posts  All Forums:Forum Nav:

FreeBSD booting with grub

post #1 of 9
Thread Starter 
since I hadn't done much in FreeBSD I didn't bother to bring over my install when I upgraded disks, and now that I'm installing it again I've run amok with grub, completely forgot how I did it last time. Placed this in /etc/grub.d/40_custom
Code:
menuentry 'FreeBSD 9.1' {
    set root='(hd0,6)'
    chainloader +1
}

after update-grub it shows up in my menu, but hitting enter returns a 'invalid signature, any key to continue' any key bring my back to the main menu. tried it with hd0,5 in case grub counts from 0. Didn't work.

my disk setup is as soon:

/dev/sda1- bios_boot
/dev/sda2- (linux) /boot
/dev/sda3- linux-swap
/dev/sda4- Debian
/dev/sda5- LMDE
/dev/sda6- FreeBSD
/dev/sda7- nothing
/dev/sda8- (linux) /home

disk is GPT.

I've done some searching on the web and found old, updated and conflicting info. How would you guys do it? Rep to any who help. FreeBSD is installed to UFS2 this time.
post #2 of 9
I think that should be (hd0,5) as GRUB counts from zero. So you take the number from /dev/sda[0-9] and minus 1.

[edit]

Why are you running Debian and LMDE?
Edited by Plan9 - 1/15/13 at 1:20am
post #3 of 9
Thread Starter 
Quote:
Originally Posted by Plan9 View Post

I think that should be (hd0,5) as GRUB counts from zero. So you take the number from /dev/sda[0-9] and minus 1.

[edit]

Why are you running Debian and LMDE?

I tried hd0,5 and that didn't work either.

I am running debian squeeze and LMDE for two different reasons. LMDE is when I want a full DE (without havn't to install it on my squeeze install) where as squeeze is what I use most of the time. basiclly, I have disk space to spare. I am using the debian stable grub-pc package for grub., version 1.98. I might try it in grub from LMDE as well, see if it's a version issue.
post #4 of 9
grub2-mkconfig -o /boot/grub2/grub.cfg (might be /boog/grub/grub.cfg) should detect things automatically. I was unaware that it didn't, either way you have the syntax wrong. As of Squeeze (should be the same on LMDE) everything is grub2, so the syntax is different. Instead of using:

set root='(hd0,6)'

It should be something like:

set root='hd1,msdos1'

The syntax has changed, so you cannot set it up like grub legacy. At least I SWEAR Squeeze had Grub2.

http://wiki.debian.org/Grub
Code:
Grub v2 is provided since DebianLenny. It is the default bootloader since DebianSqueeze.

Yeah, but they might have patched things for older syntax but I doubt it. Anyways, I'd check up FreeBSD and Grub2 for examples.
Current Rig
(14 items)
 
  
CPUMotherboardGraphicsRAM
FX-8350 4.6GHz@1.44v GA-990FXA-UD3 R4.0 HD 7950 (1100/1450) 8G Muskin DDR3 1866@8CLS 
Hard DriveOptical DriveOSMonitor
1TB WD LiteOn DVD-RW DL Linux/Windows 19" Phillips TV 1080p 
PowerCaseMouseMouse Pad
OCZ 600W Generic Junk Logitech MX400 Generic Junk 
Audio
SBL 5.1 
  hide details  
Reply
Current Rig
(14 items)
 
  
CPUMotherboardGraphicsRAM
FX-8350 4.6GHz@1.44v GA-990FXA-UD3 R4.0 HD 7950 (1100/1450) 8G Muskin DDR3 1866@8CLS 
Hard DriveOptical DriveOSMonitor
1TB WD LiteOn DVD-RW DL Linux/Windows 19" Phillips TV 1080p 
PowerCaseMouseMouse Pad
OCZ 600W Generic Junk Logitech MX400 Generic Junk 
Audio
SBL 5.1 
  hide details  
Reply
post #5 of 9
Thread Starter 
That's pretty much the problem. All the info out there is for like freebsd 6/7 on grub instead of grub2, and is conflicting at that. I'll give that mkconfig thing a shot, thanks for the tip thumb.gif
post #6 of 9
Thread Starter 
didn't work even with os-prober installed. I'm not sure I'm using grub2 though, I had to drop the 2 from your mkconfig command there to get it to run (command not found)

going to try this in LMDE see what happens.
post #7 of 9
Quote:
Originally Posted by jrl1357 View Post

didn't work even with os-prober installed. I'm not sure I'm using grub2 though, I had to drop the 2 from your mkconfig command there to get it to run (command not found)

going to try this in LMDE see what happens.

I don't think Debian does grub2-mkconfig, I think it's just plain grub-mkconfig. It's confusing because many distros do it differently. =(

Just checked, it's Grub2. Grub is a dummy package for Grub-pc which is Grub2, version number starts at ~1.98 and continues up. Grub 1.97 was legacy and discontinued during Squeeze (actually before the "freeze", grub 1.97 might still be grub2 as I don't remember the exact number). If os-prober doesn't work then you might have to write in a custom for Grub2.
Code:
     menuentry "FreeBSD ad4, direct" {
                insmod ufs2
                set root=(hd0,1,a)
                search --no-floppy --fs-uuid --set 4b22f9090565ab77
                freebsd                 /boot/kernel/kernel
                freebsd_loadenv         /boot/device.hints
                set FreeBSD.vfs.root.mountfrom=ufs:/dev/ad4s1a
                set FreeBSD.vfs.root.mountfrom.options=rw
        }

That was an example for directly booting FreeBSD, you would have to change things appropriately (for obvious reasons =P ). I guess the other method you did is supposed to work, did FreeBSD install a bootloader to /root or did you do it to the MBR of the disk? Also, somebody pointed out that it changed to kfreebsd for the kernel perams. I'm not sure about that, don't have FreeBSD.

http://forums.freebsd.org/showthread.php?t=5918

That's where I got the info from, as I'm relying on google since I don't care to set up my own system. lol The chainloader approach might work but you should have to change:

set root='(hd0,6)'
to
set root='hd1,msdos1' (example)

Then try fiddling with the numbers, /dev/sda1 = hd0, unsure how the partitions go... all my 2nd entries are msdos1 lol so I don't know, it works here.
Current Rig
(14 items)
 
  
CPUMotherboardGraphicsRAM
FX-8350 4.6GHz@1.44v GA-990FXA-UD3 R4.0 HD 7950 (1100/1450) 8G Muskin DDR3 1866@8CLS 
Hard DriveOptical DriveOSMonitor
1TB WD LiteOn DVD-RW DL Linux/Windows 19" Phillips TV 1080p 
PowerCaseMouseMouse Pad
OCZ 600W Generic Junk Logitech MX400 Generic Junk 
Audio
SBL 5.1 
  hide details  
Reply
Current Rig
(14 items)
 
  
CPUMotherboardGraphicsRAM
FX-8350 4.6GHz@1.44v GA-990FXA-UD3 R4.0 HD 7950 (1100/1450) 8G Muskin DDR3 1866@8CLS 
Hard DriveOptical DriveOSMonitor
1TB WD LiteOn DVD-RW DL Linux/Windows 19" Phillips TV 1080p 
PowerCaseMouseMouse Pad
OCZ 600W Generic Junk Logitech MX400 Generic Junk 
Audio
SBL 5.1 
  hide details  
Reply
post #8 of 9
Thread Starter 
Quote:
Originally Posted by mushroomboy View Post

Quote:
Originally Posted by jrl1357 View Post

didn't work even with os-prober installed. I'm not sure I'm using grub2 though, I had to drop the 2 from your mkconfig command there to get it to run (command not found)

going to try this in LMDE see what happens.

I don't think Debian does grub2-mkconfig, I think it's just plain grub-mkconfig. It's confusing because many distros do it differently. =(

Just checked, it's Grub2. Grub is a dummy package for Grub-pc which is Grub2, version number starts at ~1.98 and continues up. Grub 1.97 was legacy and discontinued during Squeeze (actually before the "freeze", grub 1.97 might still be grub2 as I don't remember the exact number). If os-prober doesn't work then you might have to write in a custom for Grub2.
Code:
     menuentry "FreeBSD ad4, direct" {
                insmod ufs2
                set root=(hd0,1,a)
                search --no-floppy --fs-uuid --set 4b22f9090565ab77
                freebsd                 /boot/kernel/kernel
                freebsd_loadenv         /boot/device.hints
                set FreeBSD.vfs.root.mountfrom=ufs:/dev/ad4s1a
                set FreeBSD.vfs.root.mountfrom.options=rw
        }

That was an example for directly booting FreeBSD, you would have to change things appropriately (for obvious reasons =P ). I guess the other method you did is supposed to work, did FreeBSD install a bootloader to /root or did you do it to the MBR of the disk? Also, somebody pointed out that it changed to kfreebsd for the kernel perams. I'm not sure about that, don't have FreeBSD.

http://forums.freebsd.org/showthread.php?t=5918

That's where I got the info from, as I'm relying on google since I don't care to set up my own system. lol The chainloader approach might work but you should have to change:

set root='(hd0,6)'
to
set root='hd1,msdos1' (example)

Then try fiddling with the numbers, /dev/sda1 = hd0, unsure how the partitions go... all my 2nd entries are msdos1 lol so I don't know, it works here.

what does the number in the search line define? running that one gives me no device found. is it the uuid? commands 'freebsd' and 'freebsd_loadenv' are not found.
post #9 of 9
It's kfreebsd and kfreebsd_loadernv this is from the change log:
Code:
2009-10-14  Robert Millan  <rmh.grub@aybabtu.com>

        Refer to kernel of FreeBSD "kFreeBSD" to avoid confusion between
        the Operating System (FreeBSD) and its kernel (kernel of FreeBSD).

        * loader/i386/bsd.c (grub_freebsd_boot): Read kernel environment
        from "kFreeBSD" namespace (rather than "FreeBSD").  Update all
        users.

        (GRUB_MOD_INIT (bsd)): Rename "freebsd" command to "kfreebsd",
        "openbsd" to "kopenbsd", "netbsd" to "knetbsd", "freebsd_loadenv"
        to "kfreebsd_loadenv", "freebsd_module" to "kfreebsd_module",
        and "freebsd_module_elf" to "kfreebsd_module_elf".  Update all
        users.

search --no-floppy --fs-uuid --set 4b22f9090565ab77

That's FS specific UUID, don't know how to find it outside of FreeBSD. Linux might find the UUID number, worth trying with gparted (or parted if your not lazy). hdx is usually corresponding to /dev/sdx minus one, as for msdos1 I'm not sure. I haven't seen msdos2 used yet I think that might be the partition type. If it's not gpd it's mbr, so msdos1 might correspond to the partition type? Idk, I haven't read extensive grub documents so I'm unsure exactly what it means. I just set things accordingly... lol

I dunno, just trying to help. heh I guess I could partition off some space and load FreeBSD sometime. I just got Fedora set up again though and updated to F18 (released today). Nothing else has worked with my broadcom so I'm weary to drop my Linux partition for a FreeBSD test. I need another HDD. =( I want another 500GB to replace my Win disc (160) and then slap windows on it and make my current 640 all for Linux storage. Anyways, if you want to try booting directly I'd change the UUID and /dev portions of the example as that's all machine specific. As well as set root=, which should be closer to set root='hd1,msdos1' also hdx is set to machine specific.

[edit] On a side note, set root='hd1,msdos1' might not be correct. Debian may have patched the syntax for grub.cfg to be more of a legacy style. See what your linux examples are set too and use that as a guide. My linux uses set root='hd1,msdos1' as seen like this:
Code:
menuentry 'Fedora' --class fedora --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-64363bf0-6b18-4c17-80a2-814f5bf59678' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  09dd0798-7fd3-4859-81df-ff0e952b7dc8
        else
          search --no-floppy --fs-uuid --set=root 09dd0798-7fd3-4859-81df-ff0e952b7dc8
        fi
        echo    'Loading Linux 3.7.2-201.fc18.x86_64 ...'
        linux   /vmlinuz-3.7.2-201.fc18.x86_64 root=/dev/sda2 ro rootfstype=ext4 raid=noautodetect SYSFONT=True  KEYTABLE=us LANG=en_US.UTF-8 rhgb quiet nouveau.modeset=0 rd.driver.blacklist=nouveau video=vesa:off vga=normal
#       echo    'Loading initial ramdisk ...'
#       initrd  /initramfs-3.7.2-201.fc18.x86_64.img
}

If yours isn't like that, Debian might have patched the syntax or messed with it. I know they do that, as I remember going to Arch and noting that Grub2 in that distro had different syntax. Don't know if they kept it or just did it for squeeze. I never really messed with Grub2 when I was running Wheezy so I don't remember.
Edited by mushroomboy - 1/15/13 at 6:12pm
Current Rig
(14 items)
 
  
CPUMotherboardGraphicsRAM
FX-8350 4.6GHz@1.44v GA-990FXA-UD3 R4.0 HD 7950 (1100/1450) 8G Muskin DDR3 1866@8CLS 
Hard DriveOptical DriveOSMonitor
1TB WD LiteOn DVD-RW DL Linux/Windows 19" Phillips TV 1080p 
PowerCaseMouseMouse Pad
OCZ 600W Generic Junk Logitech MX400 Generic Junk 
Audio
SBL 5.1 
  hide details  
Reply
Current Rig
(14 items)
 
  
CPUMotherboardGraphicsRAM
FX-8350 4.6GHz@1.44v GA-990FXA-UD3 R4.0 HD 7950 (1100/1450) 8G Muskin DDR3 1866@8CLS 
Hard DriveOptical DriveOSMonitor
1TB WD LiteOn DVD-RW DL Linux/Windows 19" Phillips TV 1080p 
PowerCaseMouseMouse Pad
OCZ 600W Generic Junk Logitech MX400 Generic Junk 
Audio
SBL 5.1 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Linux, Unix
Overclock.net › Forums › Software, Programming and Coding › Operating Systems › Linux, Unix › FreeBSD booting with grub