0

I learned about baremetal programming and created a simple pong game.

My linux is on a drive at /dev/sda. I placed the .efi file for pong on a drive at /dev/sdb, then efi/boot/bootx64.efi on this drive

I can access it and play pong by selecting the right boot device (On startup, I press del to enter boot menu. If i select the first drive I boot on grub, then linux. If I select the second drive, it takes me to the pong game)

Now, how can I make grub aware of this boot option, so that I could boot on /dev/sda, see grub, then choose linux or pong?

update-grub do not detect the pong game. (Yet, it detects a windows boot loader on /dev/sdc)

2 Answers 2

1

You need to modify grub's config. Go to /boot/grub/grub.conf.

Look there for the windows section of /dev/hdc, do exactly as it is for /dev/hdb.

# You should have already something like
title Windows         
set root=(hd2,0)         
chainloader +1

# Add 
title Game         
set root=(hd1,0)         
chainloader +1

The root will tell grub which drive, which partition on the drive to use.

The chainloader will tell grub to go directly to actual MBR of the drive. Since you can boot from your drive by using BIOS loaders - your MBR is already set correctly.

for more info: https://www.gnu.org/software/grub/manual/grub/grub.html

1
  • Thanks. The windows part was a menuentry so a bit more complicated. I ended up copying it's content : menuentry 'Pong' $menuentry_id_option 'play pong' { insmod part_gpt insmod ntfs search --no-floppy --fs-uuid --set=root 3D899484509A06C4 chainloader /efi/boot/bootx64.efi } . Chainloader +1 did not work.
    – sayanel
    Oct 14, 2022 at 15:06
1

I got inspiration from the existing grub file /boot/grub/grub.cfg to create my entry. In the end it looks like :

menuentry 'Pong' $menuentry_id_option 'play pong' {
    insmod part_gpt
    insmod ntfs
    search --no-floppy --fs-uuid --set=root 7a844a6a-9734-49a4-881d-662251c39cc3
    chainloader /my/custom/path/Pong.efi
}

With part_gpt and ntfs which are the partition table type and the file format. search will look the the drive with given UUID. And chainloader will select the .efi file to boot on that drive.

Finally, I added this entry not to grub.cfg but to /etc/grub.d/40_custom so that programs like update_grub will keep this configuration. (Nb: Under linux mint 21)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .