-1

FreeBSD newbie here.

I have a Windows 10, Debian Linux and most recently, a FreeBSD installation on a 240GB SSD and a 1TB HDD reserved purely for files. FreeBSD's installation went quite well since I've carefully followed the steps available, but I cannot boot to the system since my GRUB is having a hard time recognising it.

I've already edited /etc/grub.d/40_custom and included this piece of code right before updating GRUB:

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

On doing a update-grub, the terminal outputs me this:

Generating grub configuration file ...
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Imagem Linux encontrada: /boot/vmlinuz-4.19.0-6-amd64
Imagem initrd encontrada: /boot/initrd.img-4.19.0-6-amd64
Imagem Linux encontrada: /boot/vmlinuz-4.19.0-5-amd64
Imagem initrd encontrada: /boot/initrd.img-4.19.0-5-amd64
Encontrado unknown Linux distribution em /dev/sda6
Encontrado Windows Boot Manager em /dev/sdb1@/efi/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for EFI firmware configuration
concluído

The output of fdisk -l comes as:

Disco /dev/sda: 223,6 GiB, 240065183744 bytes, 468877312 setores
Modelo de disco: SanDisk SSD PLUS
Unidades: setor de 1 * 512 = 512 bytes
Tamanho de setor (lógico/físico): 512 bytes / 512 bytes
Tamanho E/S (mínimo/ótimo): 512 bytes / 512 bytes
Tipo de rótulo do disco: gpt
Identificador do disco: 51AF3127-339F-4F6D-A1D0-4A7E66BCEBDE

Dispositivo    Início       Fim   Setores Tamanho Tipo
/dev/sda1          34     32767     32734     16M Microsoft reservado
/dev/sda2       32768 305035263 305002496  145,4G Microsoft dados básico
/dev/sda3   305035264 305036287      1024    512K FreeBSD inicialização
/dev/sda4   367949824 368158719    208896    102M Sistema EFI
/dev/sda5   368158720 468875263 100716544     48G Linux sistema de arquivos
/dev/sda6   305036288 367949823  62913536     30G FreeBSD UFS

I've tried to set root=(hd0,gptX) to 3 and 6, removed the "gpt", did loads of things, and yet, nothing worked, my output is still the same:

error: disk 'hd0,gpt3' not found.

I have no idea of how GRUB is not recognising those partitions, maybe I've configured something in the wrong way. Windows 10 and Debian boot normally with no issues at all.

0

Are you sure GRUB's (hd0) label refers to /dev/sda? If /boot/grub/device.map exists, it might define different labeling order, since you seem to have at least sda and sdb.

Wait... even though your system boots in native UEFI style, you seem to have created a BIOS-style FreeBSD boot partition. That probably won't work, as the boot code within such a partition is old-style 16-bit code, and UEFI will expect modern 64-bit code.

You've probably followed instructions that assume the system is booting in legacy BIOS-style, even if using GPT partitioning. The native UEFI Windows bootloader on your /dev/sdb1 and the "Adding boot menu entry for EFI firmware configuration" both suggest that your system is not currently set up to work that way.

Instead, you might do something like this with your GRUB configuration for FreeBSD:

menuentry "FreeBSD" {
    insmod ufs2
    search --file --set root --no-floppy /boot/loader.efi
    chainloader /boot/loader.efi
}

If I've understood correctly what I googled (I have not used modern versions of FreeBSD), this should find the UEFI version of BSD loader code on your /dev/sda6 and load it directly from there - no matter which (hdN) label GRUB assigns to sda.

The "standard" way with UEFI would be to create a directory /EFI/FreeBSD on your EFI system partition (apparently /dev/sda4) and copy the FreeBSD /boot/loader.efi in there. But since GRUB has a module for reading UFS2 directly, the above should work just fine too.

If your /dev/sda4 is currently mounted to /boot/efi, as Debian usually does, then the standard UEFI-style FreeBSD boot directory should be created at /boot/efi/EFI/FreeBSD.

Since UEFI can simply handle any bootloader as a regular file on the ESP partition, there should be no need for a separate FreeBSD boot partition at all: the complete FreeBSD boot code can be contained in the loader.efi file.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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