2

I have a device with an AMD64 CPU but a UEFI bootloader that only supports i386.

I have made a custom Ubuntu 19.04 ISO installer using Cubic and have flashed it to a USB using usb-creator-gtk (Startup Disk Creator).

This creates two partitions on the USB:

USB Partitions

The first partition formatted as ISO9660 and holds the ISO contents, the second is a FAT32 partition that contains only the .EFI boot files.

The second partition is what the tablet will boot from. Its contents come from an efi.img file stored inside /boot/grub on the ISO. This originally contained only AMD64 EFI files.:

AMD64 boot files

I have created my own replacement img.efi file and input a bootia32.efi file using these commands:

dd if=/dev/zero of=efi.img bs=1M count=5
mkfs.fat efi.img
sudo mount -o loop,rw efi.img /media/efi
sudo cp -r <files> /media/efi

This successfully makes a bootable USB, however it doesn't load the installer Grub, it only loads a Grub command line.

I've used this bootia32.efi file to successfully load grub before, if I instead manually format the USB as FAT32, copy over the ISO files and put the custom EFI file inside of /EFI/BOOT then the device will boot into Grub as I would expect.

But I'd like to make an ISO that can be flashed as normal and boot fine.

My question is, what is the point of creating a separate partition to hold the boot EFI files as usb-creator-gtk does? How do I make that partition load the installer's Grub config instead of just the Grub command line?

Thank you

2
  • 1
    Some ISO (Windows) are larger than the FAT32 limit of 4GB. So you have to have separate FAT32 with UEFI boot files & then rest of system in another partition. It then looks like usb-creator-gtk is following that logic. If entire ISO extracted fits inside 4GB you can just do this & add the bootia32.efi file. UEFI only USB key, just extract ISO ( 7 zip or similar) to FAT32 formated flash & set boot flag. askubuntu.com/questions/395879/…
    – oldfred
    Aug 23, 2019 at 21:58
  • 1
    @oldfred thanks for clearing up why the partitions are separated, working around the 4GB restriction makes perfect sense. I realise I can manually make the bootable USB manually but I am deliberately trying to make an ISO that can be flashed using the built-in Startup Disk Creator.
    – Baa
    Aug 23, 2019 at 22:02

1 Answer 1

0

Thanks to @oldfred for explaining that the seperated partitions is to overcome the 4GB file size limit for FAT32.

I've managed to create the bootable ISO by putting both the boot folder and the EFI folders from the ISO into the FAT32 (efi.img) partition.

I've modified the grub.cfg to launch from a different partition than the one it sits in.

This doesn't seem right to me because the original efi.img file only had three files:

BOOTx64.EFI
grubx64.efi
mmx64.efi

But, it works so I'm happy.

The exact structure of my efi.img file is this:

.
├── boot
│   └── grub
│       ├── font.pf2
│       ├── grub.cfg
│       ├── loopback.cfg
│       └── x86_64-efi
│           ├── acpi.mod
│           ├── adler32.mod
│           ├── ahci.mod
│           ├── all_video.mod
│           ├── aout.mod
│           ├── appleldr.mod
│           ├── archelp.mod
│           ├── ata.mod
│           ├── at_keyboard.mod
│           ├── backtrace.mod
│           ├── bfs.mod
│           ├── bitmap.mod
│           ├── bitmap_scale.mod
│           ├── blocklist.mod
│           ├── boot.mod
│           ├── bsd.mod
│           ├── bswap_test.mod
│           ├── btrfs.mod
│           ├── bufio.mod
│           ├── cat.mod
│           ├── cbfs.mod
│           ├── cbls.mod
│           ├── cbmemc.mod
│           ├── cbtable.mod
│           ├── cbtime.mod
│           ├── chain.mod
│           ├── cmdline_cat_test.mod
│           ├── cmp.mod
│           ├── cmp_test.mod
│           ├── command.lst
│           ├── cpio_be.mod
│           ├── cpio.mod
│           ├── cpuid.mod
│           ├── crc64.mod
│           ├── cryptodisk.mod
│           ├── crypto.lst
│           ├── crypto.mod
│           ├── cs5536.mod
│           ├── ctz_test.mod
│           ├── datehook.mod
│           ├── date.mod
│           ├── datetime.mod
│           ├── diskfilter.mod
│           ├── disk.mod
│           ├── div.mod
│           ├── div_test.mod
│           ├── dm_nv.mod
│           ├── echo.mod
│           ├── efifwsetup.mod
│           ├── efi_gop.mod
│           ├── efinet.mod
│           ├── efi_uga.mod
│           ├── ehci.mod
│           ├── elf.mod
│           ├── eval.mod
│           ├── exfat.mod
│           ├── exfctest.mod
│           ├── ext2.mod
│           ├── fat.mod
│           ├── file.mod
│           ├── fixvideo.mod
│           ├── font.mod
│           ├── fs.lst
│           ├── gcry_arcfour.mod
│           ├── gcry_blowfish.mod
│           ├── gcry_camellia.mod
│           ├── gcry_cast5.mod
│           ├── gcry_crc.mod
│           ├── gcry_des.mod
│           ├── gcry_dsa.mod
│           ├── gcry_idea.mod
│           ├── gcry_md4.mod
│           ├── gcry_md5.mod
│           ├── gcry_rfc2268.mod
│           ├── gcry_rijndael.mod
│           ├── gcry_rmd160.mod
│           ├── gcry_rsa.mod
│           ├── gcry_seed.mod
│           ├── gcry_serpent.mod
│           ├── gcry_sha1.mod
│           ├── gcry_sha256.mod
│           ├── gcry_sha512.mod
│           ├── gcry_tiger.mod
│           ├── gcry_twofish.mod
│           ├── gcry_whirlpool.mod
│           ├── geli.mod
│           ├── gettext.mod
│           ├── gfxmenu.mod
│           ├── gfxterm_background.mod
│           ├── gfxterm_menu.mod
│           ├── gfxterm.mod
│           ├── gptsync.mod
│           ├── grub.cfg
│           ├── gzio.mod
│           ├── halt.mod
│           ├── hashsum.mod
│           ├── hdparm.mod
│           ├── help.mod
│           ├── hexdump.mod
│           ├── hfs.mod
│           ├── hfspluscomp.mod
│           ├── hfsplus.mod
│           ├── http.mod
│           ├── iorw.mod
│           ├── jfs.mod
│           ├── jpeg.mod
│           ├── keylayouts.mod
│           ├── keystatus.mod
│           ├── ldm.mod
│           ├── legacycfg.mod
│           ├── legacy_password_test.mod
│           ├── linux16.mod
│           ├── linuxefi.mod
│           ├── linux.mod
│           ├── loadbios.mod
│           ├── loadenv.mod
│           ├── loopback.mod
│           ├── lsacpi.mod
│           ├── lsefimmap.mod
│           ├── lsefi.mod
│           ├── lsefisystab.mod
│           ├── lsmmap.mod
│           ├── ls.mod
│           ├── lspci.mod
│           ├── lssal.mod
│           ├── luks.mod
│           ├── lvm.mod
│           ├── lzopio.mod
│           ├── macbless.mod
│           ├── macho.mod
│           ├── mdraid09_be.mod
│           ├── mdraid09.mod
│           ├── mdraid1x.mod
│           ├── memrw.mod
│           ├── minicmd.mod
│           ├── minix2_be.mod
│           ├── minix2.mod
│           ├── minix3_be.mod
│           ├── minix3.mod
│           ├── minix_be.mod
│           ├── mmap.mod
│           ├── moddep.lst
│           ├── morse.mod
│           ├── mpi.mod
│           ├── msdospart.mod
│           ├── mul_test.mod
│           ├── multiboot2.mod
│           ├── multiboot.mod
│           ├── nativedisk.mod
│           ├── net.mod
│           ├── newc.mod
│           ├── ntfscomp.mod
│           ├── ntfs.mod
│           ├── odc.mod
│           ├── offsetio.mod
│           ├── ohci.mod
│           ├── part_acorn.mod
│           ├── part_amiga.mod
│           ├── part_apple.mod
│           ├── part_bsd.mod
│           ├── part_dfly.mod
│           ├── part_dvh.mod
│           ├── part_gpt.mod
│           ├── partmap.lst
│           ├── part_msdos.mod
│           ├── part_plan.mod
│           ├── part_sun.mod
│           ├── part_sunpc.mod
│           ├── parttool.lst
│           ├── parttool.mod
│           ├── password.mod
│           ├── password_pbkdf2.mod
│           ├── pata.mod
│           ├── pbkdf2.mod
│           ├── pbkdf2_test.mod
│           ├── pcidump.mod
│           ├── play.mod
│           ├── png.mod
│           ├── priority_queue.mod
│           ├── probe.mod
│           ├── procfs.mod
│           ├── progress.mod
│           ├── raid5rec.mod
│           ├── raid6rec.mod
│           ├── random.mod
│           ├── read.mod
│           ├── reboot.mod
│           ├── regexp.mod
│           ├── reiserfs.mod
│           ├── relocator.mod
│           ├── romfs.mod
│           ├── scsi.mod
│           ├── serial.mod
│           ├── setjmp.mod
│           ├── setjmp_test.mod
│           ├── setpci.mod
│           ├── shift_test.mod
│           ├── signature_test.mod
│           ├── sleep.mod
│           ├── sleep_test.mod
│           ├── spkmodem.mod
│           ├── squash4.mod
│           ├── syslinuxcfg.mod
│           ├── terminal.lst
│           ├── terminal.mod
│           ├── terminfo.mod
│           ├── test_blockarg.mod
│           ├── testload.mod
│           ├── test.mod
│           ├── testspeed.mod
│           ├── tftp.mod
│           ├── tga.mod
│           ├── time.mod
│           ├── trig.mod
│           ├── tr.mod
│           ├── true.mod
│           ├── udf.mod
│           ├── ufs1_be.mod
│           ├── ufs1.mod
│           ├── ufs2.mod
│           ├── uhci.mod
│           ├── usb_keyboard.mod
│           ├── usb.mod
│           ├── usbms.mod
│           ├── usbserial_common.mod
│           ├── usbserial_ftdi.mod
│           ├── usbserial_pl2303.mod
│           ├── usbserial_usbdebug.mod
│           ├── usbtest.mod
│           ├── verify.mod
│           ├── video_bochs.mod
│           ├── video_cirrus.mod
│           ├── video_colors.mod
│           ├── video_fb.mod
│           ├── videoinfo.mod
│           ├── video.lst
│           ├── video.mod
│           ├── videotest_checksum.mod
│           ├── videotest.mod
│           ├── xfs.mod
│           ├── xnu.mod
│           ├── xnu_uuid.mod
│           ├── xnu_uuid_test.mod
│           ├── xzio.mod
│           └── zfscrypt.mod
└── efi
    └── boot
        ├── bootia32.efi
        ├── BOOTx64.EFI
        ├── grubx64.efi
        └── mmx64.efi

Some of those probably aren't necessary, but I'm not concerned about the extra 10MB of space it uses.

This is my grub.cfg inside the img.efi file, note the set root=(hd0):

if loadfont /boot/grub/font.pf2 ; then
    set gfxmode=auto
    insmod efi_gop
    insmod efi_uga
    insmod gfxterm
    terminal_output gfxterm
fi

set menu_color_normal=white/black
set menu_color_highlight=black/light-gray

set timeout=5
menuentry "Install Ubuntu Server" {
    set root=(hd0)
    set gfxpayload=keep
    linux   /casper/vmlinuz  boot=casper only-ubiquity quiet splash ---
    initrd  /casper/initrd
}
menuentry "Run from internal disk" {
    linux    (hd1,gpt2)/boot/vmlinuz root=/dev/mmcblk1p2 intel_idle.max_cstate=0 quiet splash $vt_handoff
    initrd   (hd1,gpt2)/boot/initrd
}

If anyone can shed further light on what should be inside of the efi.img file, please let me know.

You must log in to answer this question.

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