1

I'm trying to make a iso, based on Ubuntu 18.04, that boots in both Bios and UEFI mode. I have it booting in Bios mode but having a problem getting it booting in UEFI mode. When I burn it to a USB stick, I get a UEFI partition within the ISO9660 USB. When I try to boot it in UEFI mode I get a grub prompt.

Results of fdisk -l

larry@larry-Satellite-C55-A:~/foxclone$ fdisk -l foxclone025-02.iso
Disk foxclone025-02.iso: 660 MiB, 692060160 bytes, 1351680 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x45d15306

Device              Boot Start     End Sectors  Size Id Type
foxclone025-02.iso1 *        0 1351679 1351680  660M  0 Empty
foxclone025-02.iso2        276    5203    4928  2.4M ef EFI (FAT-12/16/32)

The method to create the EFI partition was:

#! /bin/sh

BOOT_IMG_DATA=$($HOME/foxclone/newiso -d)
BOOT_IMG=efi.img

mkdir -p $(dirname $BOOT_IMG)

truncate -s 4M $BOOT_IMG
mkfs.vfat $BOOT_IMG
mkdir -p $BOOT_IMG_DATA/efi/boot

grub-mkimage \
    -C xz \
    -O x86_64-efi \
    -p /boot/grub \
    -o $BOOT_IMG_DATA/efi/boot/bootx64.efi \
    boot linux search normal configfile \
    part_gpt btrfs fat iso9660 loopback \
    test keystatus gfxmenu regexp probe \
    efi_gop efi_uga all_video gfxterm font \
    echo read ls cat png jpeg halt reboot

mcopy -i $BOOT_IMG -s $BOOT_IMG_DATA/efi ::

The method to build the iso was:

#!/bin/bash

orig_iso="$HOME"/foxclone/foxclone025-01.iso
new_iso="$HOME"/foxclone/foxclone025-02.iso
new_files=$HOME/foxclone/newiso
mbr_template=isohdpfx.bin

xorriso -as mkisofs \
    -r -V 'Foxclone' \
    -o "$new_iso" \
    -J -J -joliet-long -cache-inodes \
    -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
    -b isolinux/isolinux.bin \
    -c isolinux/boot.cat \
    -boot-load-size 4 -boot-info-table -no-emul-boot \
    -eltorito-alt-boot \
    -e --interval:appended_partition_2:all:: \
    -append_partition 2 0xef efi.img \
    -no-emul-boot -isohybrid-gpt-basdat \
    "$new_files"

Results of dumpet

larry@larry-Satellite-C55-A:~/foxclone$ dumpet -i foxclone025-02.iso
Validation Entry:
    Header Indicator: 0x01 (Validation Entry)
    PlatformId: 0x00 (80x86)
    ID: ""
    Checksum: 0x55aa
    Key bytes: 0x55aa
Boot Catalog Default Entry:
    Entry is bootable
    Boot Media emulation type: no emulation
    Media load segment: 0x0 (0000:7c00)
    System type: 0 (0x00)
    Load Sectors: 4 (0x0004)
    Load LBA: 38 (0x00000026)
Section Header Entry:
    Header Indicator: 0x91 (Final Section Header Entry)
    PlatformId: 0xef (EFI)
    Section Entries: 1
    ID: ""
Boot Catalog Section Entry:
    Entry is bootable
    Boot Media emulation type: no emulation
    Media load address: 0 (0x0000)
    System type: 0 (0x00)
    Load Sectors: 8192 (0x2000)
    Load LBA: 275968 (0x00043600)

I'd appreciate some help on this, Larry

2 Answers 2

1

There are enough subtle things that can go wrong, I don't see any outright mistakes in your script but that doesn't mean there are none; if nothing else, check out the excellent Rod's books on the topic and maybe my ISO generator script -- it's hugely overcomplicated for your particular task (and still too simple for mine) but maybe you spot something crucial there.

PS: note that the script is based around refind (which is just as awesome as those books to me); there's an effort to add grub support underway but not there yet.

While at that, if you're not actually tied to Ubuntu 18.04 and just need a custom ISO with UEFI boot capability (including signed shim) you might be interested in ALT's mkimage, the above script is part of it, and mkimage-profiles that provides a framework to build distribution configurations for subsequent baking of their images (e.g. ALT Starterkits are made with it, as well as our 9.0 releases; making a derivative tends to be pretty easy and technological but most of the docs are in Russian by now).

Sorry for the shameless plug, I just happen to be someone who did both UEFI support in ALT Linux and designed m-p -- so couldn't resist asking :-)

1

I love to try to understabd why ,and I hate to tell how to do for that works; since once understood I would know "My Way". There is strong probability that once booted in uefi you only see grub's prompt is simply your grub's mkimage "does not find any grub.cfg it looks for

Usually,on debian like (a.k.a ubuntu )the "embedded fat-efi-partition" - initiated long ago by the famous mjg59 in 2012 -has a "memdisk" containing the grub.cfg (it' s really embedded grub.cfg in side the efi.img) telling where to look at your next grug.cfg -the "custom" "user" final grub.cfg -call it as you want-but that must be the isoimage's grub.cfg ( what you see in the isofs tree structure -isotree /boot/grub/grub.cfg + of course grub's tree for full grub support.) The directive -p /boot/grub in your grub-mkimage tells you the prefix /boot/grub for grub to look at grub.cfg but that is still in the fat's space ,there is no reason that could see the isotree space !(what you like it looks for )

Your grub-mkimage needs a memdisk with a module's directive -m memdisk.tar which allows you to "reach" the grub.cfg of the iso tree , the memdisk is kind of tarfs containing the directive to look for and go read the iso tree's grub.cfg

To illustrate all this "blah blah"

1 Once boot "your" iso into your grub's prompt ;simply type "ls" to see all the disk drive grub is able to see ,and you should not see any "memdisk"

2 Boot in uefi mode (almost) any ubuntu (pseudo)"iso" image ( by pseudo I mean not a pureiso a.k.a isohybrid is not pureiso) at the menu to get the "Try ubuntu...blabla" type "ESC" to get into grub's console then type "ls" again and compare with your isoimage .

grub> ls (memdisk)/ to see what are behind this tarfs disk ,eventually

grub> cat (memdisk)/grub.cfg or similar (memdisk)/boot/grub/grub.cfg to see the way they try to switch partition and get the iso tree's grub.cfg

3 Short cut try : just replace your efi.img by the ubuntu's efi.img ; Beware that ubuntu's embedded grub.cfg requires presence of file in $isotree/.disk/[info mini-info] so you have to add to your isotree something like mkdir $isotree/.disk && touch $isotree/.disk/info when you build your iso with xorriso chances are high that works ,but that is a bad way to learn

4 Rebuild your grub-mkimage with at the end the directive "-m memdsk" where "tar cf memdsk grub.cfg" grub.cfg is what you manually steal from ubuntu ; better is just write your own

5 To have fun boot in uefi any ubuntu.iso image on usb ;

  Type ESC to get into grub console
  Check your isofs partition as hd0 (since you booton it) by
      grub>ls (hd0)/   this will reveal the isofs tree
  Chroot to isofs partition with
      grub>set root=(hd0)

A Switch grub config in standard way grub>configfile /boot/grub/grub.cfg

B Switch grub config by using grub-cmd "syslinux_configfile" (not usually shown on the google_search !!!) grub>syslinux_configfile /isolinux/isolinux.cfg

  Observe and play (where is legacy-bios or uefi boot now ?)

That's it

wangji

see https://sourceforge.net/projects/toysbox/files/Exo_on_grub-mkimage/

https://sourceforge.net/projects/toysbox/files/practice_on_bootx64.efi/Practices_on_bootx64.pdf/download

You must log in to answer this question.

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