Search code examples
filesystemsisogrub

GRUB can't recognize FAT32 filesystem on an isohybrid image


I am building a multiboot isohybrid image using the following command:

xorriso -as mkisofs -iso-level 3 -full-iso9660-filenames -volid "MULTIBOOT" -eltorito-boot boot/isolinux/isolinux.bin -eltorito-catalog boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -isohybrid-mbr ${isodir}boot/isolinux/isohdpfx.bin -eltorito-alt-boot -e boot/isolinux/efiboot.img -no-emul-boot -isohybrid-gpt-basdat -output ~/output.iso  ${isodir}

This loads the isolinux bootloader as expected when booting in BIOS mode, but as I want to use GRUB, I chain load it using this configuration file:

Default Grub2
LABEL Grub2
SAY Switching to Grub2...
Linux /boot/grub/lnxboot.img
INITRD /boot/grub/core.img

GRUB loads, but instead of displaying the main menu, it drops to the rescue console claiming it can't recognize the filesystem. Interestingly, this happens when if I load the ISO image from a CD, but not if I burn it to a USB drive. I this case, GRUB finds the file system and works as expected.

Here is the start of my current grub.cfg file (without the menu entries):

insmod iso9660
insmod gfxmenu
insmod png
insmod part_msdos
insmod part_gpt
insmod fat
insmod ntfs
insmod ext2
insmod efi_gop
insmod efi_uga
if [ "${grub_platform}" != "efi" ]; then
    insmod vbe
    insmod vga
fi
insmod gfxterm
terminal_output gfxterm

set gfxmode=800x600
search --file --no-floppy --set=root /multiboot/menu/main_menu.cfg
#set root='hd0,msdos1'
set timeout=30
set theme="/boot/grub/themes/multiboot/theme.txt"

loadfont /boot/grub/fonts/unifont-bold-16.pf2
loadfont /boot/grub/fonts/unifont-regular-16.pf2
loadfont /boot/grub/fonts/unifont-regular-14.pf2
loadfont /boot/grub/fonts/unifont-regular-32.pf2

set default=1

My guess is that my core.img file is missing some module to make things works when booting from CD, but I have already specifically included the ISO 9660 module on my core.img without success.


Solution

  • I came up with the solution. I had to create a core.img file using the following command:

    grub-mkimage  -O i386-pc -c common.cfg  -p /boot/grub biosdisk part_msdos part_gpt fat ntfs exfat iso9660 search -o core.img
    

    With the common.cfg file containing this:

    search --file --no-floppy --set=root /multiboot/menu/main_menu.cfg
    set cmdpath=($root)
    set prefix=($root)/boot/grub