How could I make a dual bootable(UEFI & BIOS) Disk?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
gamingjam60
Member
Member
Posts: 70
Joined: Sat Aug 24, 2024 10:06 pm
Libera.chat IRC: gamingjam60
Location: India
GitHub: https://github.com/baponkar
Contact:

How could I make a dual bootable(UEFI & BIOS) Disk?

Post by gamingjam60 »

I am making a dual bootable(BIOS & UEFI) Disk by writing following Sector :
  • Sector 0 : Protective MBR with BIOS Boot Code(Limine Stage 1 ),
  • Sector 1 : GPT header,
  • Sector 2: Partition Entries,
  • ....
  • Sector 32: Partition Entries,
  • Sector 33: Is this place for Limine Stage 2 Bootloader code?
  • ...
  • Sector 2048: Fat32 File System ,
  • limine-bios-cd.bin, limine-bios.sys, limine-uefi-cd.bin, kernel.bin, limine.conf, user_main.elf, BOOTX64.EFI
  • Sector n-33 : Backup Partition Entry,
  • ......,
  • Sector n-2: Backup Partition Entry,
  • Sector n-1: Backup GPT Header
Where n is represent total Sector.

Fat filesystem have following files and directories,

Code: Select all

.
├── BOOT.CAT
├── EFI
│   └── BOOT
│       ├
│       └── BOOTX64.EFI
└── boot
    ├── boot_loader_wallpaper.bmp
    ├── kernel.bin
    ├── limine
    │   ├── limine-bios-cd.bin
    │   ├── limine-bios.sys
    │   └── limine-uefi-cd.bin
    ├── limine.conf
    └── user_main.elf

I also have seen compiled limine-9.2.3 have following files:

Code: Select all

.
├── BOOTAA64.EFI
├── BOOTIA32.EFI
├── BOOTLOONGARCH64.EFI
├── BOOTRISCV64.EFI
├── BOOTX64.EFI
├── LICENSE
├── Makefile
├── install-sh
├── limine
├── limine-bios-cd.bin
├── limine-bios-hdd.h
├── limine-bios-pxe.bin
├── limine-bios.sys
├── limine-uefi-cd.bin
├── limine.conf
├── limine.exe
└── limine.h
My Custom OS don't have functionality to Run "limine bios-install". I have only available low level disk read and disk write functionality.

Code: Select all

bool kebla_disk_read(int disk_no, uint64_t lba, uint32_t count, void* buf);
bool kebla_disk_write(int disk_no, uint64_t lba, uint32_t count, void* buf);
I want to make a detected disk fully bootable by Limine Bootloader.

My Code is installer.c

output:

Code: Select all

Checking if KeblaOS is installed on disk 1...
 Successfully Disk initialization in Disk 1
 Successfully Disk initialization in Disk 0
 Successfully initialized VFS in Disk 0
 Successfully initialized VFS in Disk 1
 Disk 0 Status ok
 Disk 1 Status ok
 ✓ Protective MBR found
 ✓ GPT header found
 ✓ FAT32 filesystem mounted successfully
 ✓ Found: 1:/boot.cat (2048 bytes)
 ✓ Found: 1:/boot/limine/limine_bios_cd.bin (22528 bytes)
 ✓ Found: 1:/boot/limine/limine_bios_hdd.sys (211588 bytes)
 ✓ Found: 1:/boot/limine/limine_uefi_cd.bin (2949120 bytes)
 ✓ Found: 1:/boot/boot_loader_wallpaper.bmp (9830538 bytes)
 ✓ Found: 1:/boot/kernel.bin (969048 bytes)
 ✓ Found: 1:/boot/limine.conf (714 bytes)
 ✓ Found: 1:/boot/user_main.elf (457488 bytes)
 ✓ Found: 1:/efi/boot/bootx64.efi (245760 bytes)
 ✅ KeblaOS installation verified successfully on disk 1
KeblaOS is already installed on Disk 0.
Now the disk can not boot OS.

I have following questions
  • Q1: Does "const uint8_t binary_limine_hdd_bin_data[]" array have Stage 1 & Stage 2 Code what present in limine-bios-hdd.h file?
  • Q2: What is functionality of "limine-bios.sys"?
  • Q3: If Sector 33 have Limine Stage 2 Code then where it should be mentioned I mean how does limine stage 1 boot loader or anything know sector 33 have the stage 2 code?
  • Q4: If Only UEFI boot then just have bootx64.efi in efi/boot is sufficient ?
Last edited by gamingjam60 on Thu Oct 30, 2025 8:15 am, edited 7 times in total.
Octocontrabass
Member
Member
Posts: 6275
Joined: Mon Mar 25, 2013 7:01 pm

Re: How could I make a UEFI bootable Disk also BIOS bootable?

Post by Octocontrabass »

gamingjam60 wrote: ↑Mon Oct 20, 2025 10:58 pmI think limine-bios-cd.bin and limine-bios.sys have boot code for bios boot. Then How do I update MBR or anything so that disk would be BIOS bootable as well as UEFI bootable?
You need to set up your disk according to the instructions.
gamingjam60 wrote: ↑Mon Oct 20, 2025 10:58 pmOne more question : When booting the system in UEFI mode from the disk, user_main.elf doesn’t execute, although it runs correctly when booted from the ISO. Should I place user_main.elf or any additional files in the EFI directory?
According to the instructions, no. I do wonder if it's getting confused because you have both /boot and /boot/limine directories on your disk, though. Normally you would put all of Limine's files in one or the other.
User avatar
gamingjam60
Member
Member
Posts: 70
Joined: Sat Aug 24, 2024 10:06 pm
Libera.chat IRC: gamingjam60
Location: India
GitHub: https://github.com/baponkar
Contact:

Re: How could I make a UEFI bootable Disk also BIOS bootable?

Post by gamingjam60 »

Octocontrabass wrote: ↑Tue Oct 21, 2025 10:16 am
gamingjam60 wrote: ↑Mon Oct 20, 2025 10:58 pmI think limine-bios-cd.bin and limine-bios.sys have boot code for bios boot. Then How do I update MBR or anything so that disk would be BIOS bootable as well as UEFI bootable?
You need to set up your disk according to the instructions.
gamingjam60 wrote: ↑Mon Oct 20, 2025 10:58 pmOne more question : When booting the system in UEFI mode from the disk, user_main.elf doesn’t execute, although it runs correctly when booted from the ISO. Should I place user_main.elf or any additional files in the EFI directory?
According to the instructions, no. I do wonder if it's getting confused because you have both /boot and /boot/limine directories on your disk, though. Normally you would put all of Limine's files in one or the other.
Please help me
Octocontrabass
Member
Member
Posts: 6275
Joined: Mon Mar 25, 2013 7:01 pm

Re: How could I make a dual bootable(UEFI & BIOS) Disk?

Post by Octocontrabass »

gamingjam60 wrote: ↑Mon Oct 20, 2025 10:58 pmQ1: Does "const uint8_t binary_limine_hdd_bin_data[]" array have Stage 1 & Stage 2 Code what present in limine-bios-hdd.h file?
Yes.
gamingjam60 wrote: ↑Mon Oct 20, 2025 10:58 pmQ2: What is functionality of "limine-bios.sys"?
It's the Stage 3 code for BIOS boot.
gamingjam60 wrote: ↑Mon Oct 20, 2025 10:58 pmQ3: If Sector 33 have Limine Stage 2 Code then where it should be mentioned I mean how does limine stage 1 boot loader or anything know sector 33 have the stage 2 code?
The installer writes it into the stage 1 code.
gamingjam60 wrote: ↑Mon Oct 20, 2025 10:58 pmQ4: If Only UEFI boot then just have bootx64.efi in efi/boot is sufficient ?
Yes.
Post Reply