Skip to content

Commit

Permalink
Add isohybrid to simpleiso to make the ISO compatible with USB drives (
Browse files Browse the repository at this point in the history
…#126)

* Add isohybrid to simpleiso.

* Add comment.

* Add --uefi flag to isohybrid.

* Try to replace mkisofs with xorriso.

* Change xorriso flags.

* Add kernel, initramfs and grub.cfg to the EFI image.

* Make the fat16 partition bigger.
  • Loading branch information
robertodauria authored Jul 17, 2019
1 parent 06b63b4 commit 218e970
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN apt-get install -y unzip python-pip git vim-nox make autoconf gcc mkisofs \
isolinux bc texinfo libncurses5-dev linux-source debootstrap gcc-4.8 \
strace cpio squashfs-tools curl lsb-release gawk \
mtools dosfstools syslinux syslinux-utils parted kpartx grub-efi \
linux-source-4.4.0=4.4.0-104.127 golang-1.9
linux-source-4.4.0=4.4.0-104.127 golang-1.9 xorriso
ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/go-1.9/bin
ENV GOROOT /usr/lib/go-1.9
# TODO: remove pinned version on linux-source-4.4.0.
Expand Down
46 changes: 23 additions & 23 deletions simpleiso
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ set -euxo pipefail
INITRAMFS=
BOOT_PARAMS=

# From genisoimage package.
MKISOFS=/usr/bin/mkisofs
# From xorriso package.
MKISOFS=/usr/bin/xorriso
# From the isolinux package.
ISOLINUX_BIN=/usr/lib/ISOLINUX/isolinux.bin
# From the syslinux-common package.
Expand Down Expand Up @@ -97,7 +97,7 @@ menuentry 'linux: ${ISO_NAME}' {
}
EOF

make_bootefi_img ${efiboot_img}
make_bootefi_img ${efiboot_img} ${isofs_dir}

# Copy isolinux bootloader.
install -D -m 644 ${ISOLINUX_BIN} ${isofs_dir}/isolinux/isolinux.bin
Expand All @@ -109,21 +109,23 @@ EOF

function make_bootefi_img() {
local bootefi_img=$1
local isofs_dir=$2
local tmp=$( mktemp --directory )

local raw_size_k=$(
du --dereference --summarize --block-size=1K ${isofs_dir} \
| awk '{ print $1; }'
)

local size=$(( $raw_size_k + 4096 ))

# Make the grub efi boot loader image.
grub-mkimage -o ${tmp}/bootx64.efi -p / -O x86_64-efi fat iso9660 part_gpt \
part_msdos normal boot linux linuxefi efinet lsefi lsefisystab lsefimmap \
configfile loopback chain efifwsetup efi_gop efi_uga ls search \
search_label search_fs_uuid search_fs_file gfxterm gfxterm_background \
gfxterm_menu test all_video loadenv exfat ext2 ntfs udf

local raw_size_k=$(
du --dereference --summarize --block-size=1K ${tmp}/bootx64.efi \
| awk '{ print $1; }'
)
local size=$(( $raw_size_k + 4096 ))

# Ignore meaningless sector alignment failures.
export MTOOLS_SKIP_CHECK=1

Expand All @@ -134,6 +136,9 @@ function make_bootefi_img() {
# Creates the necessary subdirectories.
mmd -i ${tmp}/data.fat16 ::/efi ::/efi/boot
mcopy -bsQ -i ${tmp}/data.fat16 ${tmp}/bootx64.efi ::/efi/boot
mcopy -bsQ -i ${tmp}/data.fat16 ${isofs_dir}/grub.cfg ::/
mcopy -bsQ -i ${tmp}/data.fat16 ${isofs_dir}/vmlinuz ::/
mcopy -bsQ -i ${tmp}/data.fat16 ${isofs_dir}/initramfs ::/

# Copy the fat16 formatted data as the complete bootefi img file.
cp ${tmp}/data.fat16 ${bootefi_img}
Expand All @@ -149,24 +154,19 @@ function main() {
setup_isofs $isodir ${isodir}/efiboot.img "$VMLINUZ" "$INITRAMFS" "${BOOT_PARAMS}"

# Generate the ISO image. File paths are relative to the ${isodir}.
${MKISOFS} -untranslated-filenames \
-publisher "M-Lab" \
-appid "ePoxy" \
-volid "Dual ISO x86_64" \
-joliet \
-joliet-long \
-rational-rock \
-verbose \
-translation-table \
-output ${ISO_NAME} \
-eltorito-boot isolinux/isolinux.bin \
-eltorito-catalog isolinux/boot.cat \
${MKISOFS} -as mkisofs \
-isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
-c isolinux/boot.cat \
-b isolinux/isolinux.bin \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
-eltorito-alt-boot \
-efi-boot efiboot.img \
-no-emul-boot ${isodir}
-e efiboot.img \
-no-emul-boot \
-isohybrid-gpt-basdat \
-output ${ISO_NAME} \
${isodir}

# Clean up temporary directory.
rm -fr ${isodir}
Expand Down

0 comments on commit 218e970

Please sign in to comment.