Grub error: Image has invalid negative size

I have a multiboot configuration. I can boot anything without Grub2. But Grub only works with Windows(Veracrypt) and Ubuntu. Initially the current branch was installed, but now I am using the 12.0 RELEASE.
When I try to start FreeBSD with Grub, this happens:
Booting a command list
error: Image has invalid negativ size
Press any key......

sudo sfdisk -l /dev/sda
Disk /dev/sda: 238,5 GiB, 256060514304 bytes, 500118192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Device       Start       End   Sectors   Size Type
/dev/sda1       40    409639    409600   200M EFI System
/dev/sda2   411648   4605951   4194304     2G FreeBSD swap
/dev/sda3  4605952 500117503 495511552 236,3G FreeBSD ZFS
40_custom file:
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry 'Windows 10' --class windows --class os $menuentry_id_option 'osprober-efi-BA81-814C' {
    insmod part_gpt
    insmod fat
    set root='hd1,gpt2'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt2 --hint-efi=hd1,gpt2 --hint-baremetal=ahci1,gpt2  BA81-814C
      search --no-floppy --fs-uuid --set=root BA81-814C
    chainloader /efi/VeraCrypt/DcsBoot.efi
set timeout_style=menu
if [ "${timeout}" = 0 ]; then
  set timeout=10

menuentry "FreeBSD" {
          insmod zfs
          insmod fat
          insmod part_gpt
          search --fs-uuid --no-floppy --set=root E4A6-1DF0
          chainloader /efi/boot/bootx64.efi
#menuentry "FreeBSD" {
#    insmod part_gpt
#    insmod fat
#    insmod zfs
#    set root=(hd0,gpt1)
#    chainloader /efi/boot/BOOTx64.efi
sudo update-grub
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.18.0-20-generic
Found initrd image: /boot/initrd.img-4.18.0-20-generic
Found linux image: /boot/vmlinuz-4.18.0-18-generic
Found initrd image: /boot/initrd.img-4.18.0-18-generic
Found linux image: /boot/vmlinuz-4.15.0-50-generic
Found initrd image: /boot/initrd.img-4.15.0-50-generic
Found Windows Boot Manager on /dev/sdb2@/efi/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for EFI firmware configuration
sudo os-prober
/dev/sdb2@/efi/Microsoft/Boot/bootmgfw.efi:Windows Boot Manager:Windows:efi

So, how can I get this stupid grub entry to work??
Last edited by a moderator:
This works for efi installs of pfSense 2.5.1. I expect it will work as well for other FreeBSD distributions:

Install pfsense 2.5.1.

I think it'll work to just rename efi/boot/BOOTx64.efi to efi/boot/pfBOOTx64.efi and leave it right there in the efi partition, tho I had copied it elsewhere and put it back after the linux install.

install linux.

# lsblk -f

Replace the uuid in the search command below with the uuid of your efi partition:
Add this menuentry to your /etc/grub.d/40_custom:
menuentry 'pfsense 2.5.1' {
   search --no-floppy --fs-uuid --set=root CD98-A7D8
   chainloader /efi/boot/pfBOOTx64.efi

rebuild your grub.conf, or just add the menuentry there too yourself.