will an installation destroy my grub?

Hello, I have several SSDs and HDs in my desktop. one ssd has windows and another ubuntu installed in EFI mode. So when I boot I have a choice between the two. I want to install freeBSD on a third SSD, but I am anxious that it might destroy the grub and that then I wont be able to launch any of the OPs. So is it possible to keep the grub and have freeBSD as a third boot option? Or if freeBSD puts whatever it uses on top, will I keep my boot choices?
 
The FreeBSD installation process on a separate disk won't touch the other disks or GRUB, unless during installation you choose the wrong disk. As precaution make sure you have a backup of your important data from the present installations.

In case you are utmost concerned about your other installations, you could disconnect the disks (unplug the data cable on a powered down system!), install FreeBSD, reconnect the disks ( on a powered down system!).

If you choose during installation Auto (UFS) Guided Disk Setup (2.6. Allocating Disk Space), that would need extra intervention at the end of the installation process. You would need to change two partition names (label the partitions).

In case you choose Auto (ZFS) Guided Root-on-ZFS, no intervention is needed during the installation process. After reboot the swap partition will need to be adjusted, but it's non critical to the system boot process.

In both cases, if not I, others will surely assist you to label the partitions if you ask.
 
I always disconnect the disk I don't want to mangle for safety. You should be able to configure GRUB to boot Freebsd once you are done.
 
I always disconnect the disk I don't want to mangle for safety. You should be able to configure GRUB to boot Freebsd once you are done.

I have installed in ZFS UEFI mode. freeBSD isn't shown in the GRUB, is there any tutorial how to configure grub for freeBSD, I have never done it before. Thx.
 
Try this setting to GRUBS's /etc/grub.d/40_custom menu:

Code:
menuentry "FreeBSD 12.1-RELEASE" {
       insmod zfs
       search --set --label zroot
       kfreebsd /ROOT/default/@/boot/zfsloader
}

Don't forget to run update-grub.
 
  • Thanks
Reactions: a6h
And just for the record, this one is a solution for MBR/GPT (Not ZFS/UEFI) for MBR/GPT user who has the same problem.
Suppose, FreeBSD has installed on the 2nd partition (partition as in non-FreeBSD temenology)

partition 1: Ubuntu
partition 2: FreeBSD => (hd0,1) second primary partition of the first hard disk
In case of dual-boot windows, it's probably reside on 3rd partition, because you have a Windows hidden system partition, therefore (hd0,2)

partition 1: Windows hidden system
partition 2: Windows
partition 3: FreeBSD => (hd0,2)

Code:
/etc/grub.d/40_custom
    menuentry "FreeBSD" {
    set root='(hd0,1)'
    kfreebsd /boot/loader
}

# grub-mkconfig -o /boot/grub/grub.cfg

[EDIT]: add extra information
And in the process if you managed to destory grub, don't panic, run a Live CD and:
An example on /dev/sda (/dev/sda1) # it works on Arch.

Code:
mount /dev/sda1 /mnt
mount --bind /dev /mnt/dev
mount --bind /dev/pts /mnt/dev/pts
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
chroot /mnt
grub-install /dev/sda1
grub-install --recheck /dev/sda1
update-grub
exit
umount /mnt/sys
umount /mnt/proc
umount /mnt/dev/pts
umount /mnt/dev
umount /mnt
Then reboot.
 
Try this setting to GRUBS's /etc/grub.d/40_custom menu:

Code:
menuentry "FreeBSD 12.1-RELEASE" {
       insmod zfs
       search --set --label zroot
       kfreebsd /ROOT/default/@/boot/zfsloader
}

Don't forget to run update-grub.
I tried this, freeBSD 12.1 is in the grub boot menu, but if I chose it screen goes black and nothing happens, I waited like for 5 minutes
 
Change 3rd line: from search --set --label zroot to search --set=root --label zroot
[EDIT]: Don't forget update-grub
 
Change 3rd line: from search --set --label zroot to search --set=root --label zroot
[EDIT]: Don't forget update-grub
Nop, just the same result, don't know if it helps, but here is the result of update-grub
Sourcing file `/etc/default/grub' Sourcing file `/etc/default/grub.d/init-select.cfg' Generating grub configuration file ... Found linux image: /boot/vmlinuz-5.4.0-37-generic Found initrd image: /boot/initrd.img-5.4.0-37-generic Found linux image: /boot/vmlinuz-5.4.0-26-generic Found initrd image: /boot/initrd.img-5.4.0-26-generic Found Windows Boot Manager on /dev/nvme0n1p2@/EFI/Microsoft/Boot/bootmgfw.efi Adding boot menu entry for UEFI Firmware Settings done
 
Does FreeBSD boot when chosen from the BIOS/UEFI boot selection menu (usualy the F12 key, but it may differ for your computer)?
 
Does FreeBSD boot when chosen from the BIOS/UEFI boot selection menu (usualy the F12 key, but it may differ for your computer)?
it`s F11 on my mainboard..but yeah, there are 3 options. UEFI OS (P1: ssd name) is the one with the freeBSD installation and i can boot it from there.
 
Chainloading FreeBSD EFI loader from GRUB always works for me:
Code:
menuentry "FreeBSD" {
    set root=(hd0,gpt1)
    chainloader /efi/boot/bootx64.efi
}
Change hd0 with your actual disk ;)
 
Nop, this didn't work either...it just said device not found. So someone asked what my devices look like.

dev.png


freeBSD is on sdb, windows is nvme1n1 and ubuntu is on nvme0n1, grub looks like this
grub.png
 
Chainloading FreeBSD EFI loader from GRUB always works for me:
Code:
menuentry "FreeBSD" {
    set root=(hd0,gpt1)
    chainloader /efi/boot/bootx64.efi
}
Change hd0 with your actual disk ;)

I was about to recommend your tutorial:

Beginning at "# Mount the existing EFI partition of your disk:", ending at "# For GRUB:"
Is it still up to date?
 
I was about to recommend your tutorial:

Beginning at "# Mount the existing EFI partition of your disk:", ending at "# For GRUB:"
Is it still up to date?
Yes, it is. The difference is, in my tutorial you do a manual installation and you give the efi loader the name "freebsd.efi" (so it doesn't interfere with loaders from other systems). On the other hand, when using FreeBSD's default installation, the efi loader is named "bootx64.efi"
 
Just to confirm, sdb would mean 'hd1' in GRUB. Was that what you did?
It should look like this:
Code:
menuentry "FreeBSD" {
    set root=(hd1,gpt1)
    chainloader /efi/boot/bootx64.efi
}

No, I actually just put in sdb there the first time :D. Anyway I replaced it with what you said, I did sudo update-grub, but now when I choose freeBSD from the menu the cursor is put back on the Ubuntu entry
 
No, I actually just put in sdb there the first time :D. Anyway I replaced it with what you said, I did sudo update-grub, but now when I choose freeBSD from the menu the cursor is put back on the Ubuntu entry
Hmm, perhaps it may be that GRUB is numbering the disk where it resides in as the first one, thus altering the numbering of the other drives...
You can try changing from 'hd1' to 'hd2' and see if it makes a difference. I'm just guessing though
 
I replaced it with what you said, I did sudo update-grub,
You can set/check the right hd without editing the grub custom file.

At the GRUB menu pressing the C key will take you to the GRUB terminal, enter ls, it will list all disks. Identify your FreeBSD disk and partition 1. Descend into the disk directory to verify the correct disk and partition:

ls (hd1,gpt1)/ ,
ls (hd2,gpt1)/efi/boot , etc.

Press Esc to return to the GRUB menu.

Then choose at the GRUB boot menu FreeBSD, press the E key, that will enter into the menu entry editor mode, edit the entry, press F10 to boot. If all is satisfactory edit /etc/grub/40_custom.
 
Hello, I did that, so the partitions are as follows

Code:
ls (hd1,gpt3)
Partition hd1,gpt3: Filesystem type zfs - Label `zroot' -...

ls (hd1,gpt2)
No known filesystem detected.

ls(hd1,gpt1)
Partition hd1,gpt1: Filesystem type fat - Label `EFISYS' ...

ls (hd1,gpt1)/efi/boot
BOOTx64.efi startup.nsh

Then I pressed E to modify the freeBSD entry and made sure that

Code:
menuentry "FreeBSD" {
    set root=(hd1,gpt1)
    chainloader /efi/boot/bootx64.efi
}

is still there. But when I press F10 to boot up I get the error message:

Code:
Image has invalid negative size

Strangely though when I exit grub freeBSD starts to booting up anyway.
 
ls (hd1,gpt3)
Partition hd1,gpt3: Filesystem type zfs - Label `zroot' -...

Rich (BB code):
       menuentry "FreeBSD" {
set root=(hd1,gpt1)
chainloader /efi/boot/bootx64.efi
   
}

Try setting gpt3:
Rich (BB code):
menuentry "FreeBSD" {
    set root=(hd1,gpt3)
    chainloader /efi/boot/bootx64.efi

}
 
I tried that. I get an error: File `efi' not found. Is it perhaps because I chose GPT(UEFI) for the partition scheme during the installation? Maybe a reinstall with another partition scheme (UEFI+BIOS) or just (BIOS) would help?
 
I tried that. I get an error: File `efi' not found. Is it perhaps because I chose GPT(UEFI) for the partition scheme during the installation? Maybe a reinstall with another partition scheme (UEFI+BIOS) or just (BIOS) would help?
No, I don't think so. It's absolutely right to use GPT(UEFI), unless you're booting in legacy mode.
The reason it shows the error "efi not found" is because you pointed to gpt3, which is the partition with ZFS.
Using gpt1 was correct when trying to chainload, as the FreeBSD efi loader is in fact located in that 200M FAT32 efi partition.
I have no clue why it reported before "Image has invalid negative size", but hey, if anyway it does boot to FreeBSD afterwards I guess you shouldn't care too much.
Finally, if you want to try a different way than chainloading, then you could try directly loading the FreeBSD kernel from GRUB (here you would indeed need to point to 'gpt3', the partition with ZFS), but you'll need to find exactly how to do it elsewhere as I don't really know how to :(
 
Back
Top