# How to install GRUB on FreeBSD 11.1



## BSDAppentic3 (Apr 23, 2018)

Anyone has any idea of how can I install GRUB here?
Thanks!


----------



## shepper (Apr 23, 2018)

https://www.freshports.org/sysutils/grub2/
There is a grub-install command that needs to be run after installing the port and the exact syntax depends on whether your are installing to a MBR or installing to GTP/EFI.

See the Arch Grub wiki"
https://wiki.archlinux.org/index.php/GRUB


----------



## BSDAppentic3 (Apr 23, 2018)

shepper said:


> See the Arch Grub wiki"
> https://wiki.archlinux.org/index.php/GRUB


I didn't get this. Why should I see the wiki of Arch? I will install some systems of Linux. I know a lot, and in the web,there are much more.
Edit: Arch is fine. But it is, meh. I'll run it in virtualbox instead.
Do you know Qubes OS? Perhaps I'll download it and installed it. Yep, one of the most hard systems EVER.


----------



## BSDAppentic3 (Apr 23, 2018)

shepper 
Sorry. But using pkg I have nothing, and using make, well, it shows me a couple of errors. Like 127, like error 1. I can't do ctrl+c and ctrl+v to show you because I'm using xterm and it doesn't allow me to copy-paste like the traditional terminal or konsole.


----------



## Sensucht94 (Apr 23, 2018)

BSDAppentic3 said:


> I didn't get this. Why should I see the wiki of Arch? I will install some systems of Linux. I know a lot, and in the web,there are much more.
> 
> Edit: Arch is fine. But it is, meh. I'll run it in virtualbox instead.
> 
> Do you know Qubes OS? Perhaps I'll download it and installed it. Yep, one of the most hard systems EVER.




You were pointed the Arch wiki because the GRUB2 (and actually SysLinux too, which I prefer, but never tried with FreeBSD: sysutils/syslinux)

port you can find in the FreeBSD repo is exactly the same  piece of software you can install on any Linux distribution: it's third party software, it doesn't belong to any OS (rather,it's FSF's "property") and as such it's basically always the same,no matter the OS you're installing it from .


There are various examples of working Grub2 menuentries for FreeBSD on this forum, for all the possible sets and circumstances, and it should be easy for you to find and 'steal' them, but it's a advisable to read the grub-install(8) man page thoroughly.

official and exhaustive documentation is available on gnu.org

SysLinux provides an official wiki too, which is extremely well thought, and proved in my case very useful, both on Linux, and FreeDOS, where SysLinux has been ported too. 

Finally, if you need to set up  a dual/multi-boot environment on a MBR disk, rather than GPT, then FreeBSD natively provides the  lightweight boot0cfg(8) boot manager


----------



## shepper (Apr 23, 2018)

The Arch link explains the basic commands and gives a decent review of how the boot process works.

pkg should install the software but you need an additional steps to install and configure the bootoader.  I copied/pasted the commands from the Arch wiki and changed the partition names to those used in FreeBSD.
If your system is i386/amd64 with a legacy (MBR) BIOS, you need to run this command:
`# grub-install --target=i386-pc /dev/da0`
If you have a newer amd64 system with EFI/GPT BIOS then you run this command:
`# grub-install --target=x86_64-efi --efi-directory=esp --bootloader-id=GRUB`.
If you're multibooting different OS's additional programs can be helpful.

Note the partition names are different in FreeBSD
http://wonkity.com/~wblock/docs/html/disksetup.html.
Once the grub code is written to the boot sector, then you need to run a second command that again depends on your BIOS:
For an MBR bios the second command to configure grub is:
`# grub-mkconfig -o /boot/grub/grub.cfg`


----------



## hotaronohanako (Apr 23, 2018)

BSDAppentic3 said:


> shepper
> Sorry. But using pkg I have nothing, and using make, well, it shows me a couple of errors. Like 127, like error 1. I can't do ctrl+c and ctrl+v to show you because I'm using xterm and it doesn't allow me to copy-paste like the traditional terminal or konsole.



Make some efford in reading the documentation you have been refered to !  the info provide is already pretty specific to your case.

rtfm


----------



## balanga (Apr 26, 2018)

I struggled, but eventually succeeded, it getting the sysutils/grub2 pkg installed on a disk and was able to boot on both UEFI and non-UEFI systems and was able to boot around 10 systems from it. Unfortunately I broke something recently and am struggling to find the right incantations to get it set up again. I did think I had mastered it, but can't figure out what I'm doing wrong in trying to rebuild that disk.


----------



## drhowarddrfine (Apr 26, 2018)

I have not dual-booted in almost 15 years but, when I tried, FreeBSD had its own method that worked quite well. Does that not still exist? If so, why use grub at all?

Of course, I think dual-booting is silly to begin with so I wouldn't know.


----------



## Deleted member 30996 (Apr 26, 2018)

BSDAppentic3 said:


> shepperI can't do ctrl+c and ctrl+v to show you because I'm using xterm and it doesn't allow me to copy-paste like the traditional terminal or konsole.



Highlight the text you want to copy in x11/xterm, bring focus to your text editor and press the middle mouse button to paste the text.


----------



## BSDAppentic3 (Apr 28, 2018)

I only have to add this in  grub2.cfg :
menuentry "FreeBSD" --class freebsd --class bsd --class os {
 insmod ufs2
 insmod bsd
 set root=(hd0,1)
 kfreebsd /boot/kernel/kernel
 kfreebsd_loadenv /boot/device.hints
 set kFreeBSD.vfs.root.mountfrom=ufs:/dev/ada0s1a
 set kFreeBSD.vfs.root.mountfrom.options=rw
 set kFreeBSD.hw.psm.synaptics_support=1
}
So thanks.
But I need to install it, no more.


----------



## -Snake- (Apr 29, 2018)

BSDAppentic3


----------



## balanga (Apr 29, 2018)

There's a big difference between RTFM and UTFM


----------



## hotaronohanako (Apr 29, 2018)

balanga said:


> There's a big difference between RTFM and UTFM


there is no difference if actually the user who is asking for help is not willing to applay any of it in  his research!


----------



## michael_hackson (May 1, 2018)

Hello! Nice timing with the thread since I am in the middle of setting up grub2 myself.

I have set up a `bios-boot` partition with `gpart` assigned as /dev/ada0p4.
Used /sbin/newfs to make a ufs2 and now when I am about to use `# grub-install /dev/ada0p4` I get this:

```
/usr/local/sbin/grub-bios-setup: error: hostdisk//dev/ada0 appears to contain a ufs2 filesystem which isn't known to reserve space for DOS-style boot.  Installing GRUB there could result in FILESYSTEM DESTRUCTION if valuable data is overwritten by grub-setup (--skip-fs-probe disables this check, use at your own risk).
```

And when I use the --skip-fs-probe it is said that there is no such option. I found a patch to a Linux binary adding that option in the util/grub-install.in; not really helping my case.

How can I take it further from here? Haven't tried with FAT32 on /dev/ada0p4 yet because the manual for /sbin/newfs_msdos doesn't make it for me at 4:00 AM.

Thanks!


----------



## michael_hackson (May 1, 2018)

Will add that why I can't stay true to the document in ArchWiki is because I use Legacy BIOS and GPT.


----------



## michael_hackson (May 1, 2018)

Nvm, I read up properly and have some more things to try out. With more questions I'd rather post a proper thread.


----------

