mvallim / live-custom-ubuntu-from-scratch

(Yes, the project is still alive 😃) This procedure shows how to create a bootable and installable Ubuntu Live (along with the automatic hardware detection and configuration) from scratch.
https://mvallim.github.io/live-custom-ubuntu-from-scratch/
GNU General Public License v3.0
397 stars 186 forks source link

Update xorriso paramters for 22.04 #47

Open piexil opened 1 year ago

piexil commented 1 year ago

I have been doing a lot of trial and error in my own from scratch ubuntu project to get 22.04 working with bios installers without the use of isolinux and also to fix rufus persistent mode. My project is very different than yours and not publicly available yet but yours has been very helpful so I thought I would share what I have discovered.

As stated these flags should work without isolinux files (i am still using the folder name, i plan to change this) and enable both EFI/BIOS on a usb key while also getting Rufus ISO & Persistent mode to work again.

   xorriso -as mkisofs -r \
  -volid "${image_name}" \
  -full-iso9660-filenames \
  -J -J -joliet-long \
  -output "../$output_name" \
  --grub2-mbr /usr/lib/grub/i386-pc/boot_hybrid.img \
  -partition_offset 16 \
  --mbr-force-bootable \
  -append_partition 2 28732ac11ff8d211ba4b00a0c93ec93b isolinux/efiboot.img \
  -appended_part_as_gpt \
  -iso_mbr_part_type a2a0d0ebe5b9334487c068b6b72699c7 \
  -eltorito-boot isolinux/bios.img \
   -no-emul-boot \
   -boot-load-size 4 \
   -boot-info-table \
   --eltorito-catalog boot/grub/boot.cat \
   --grub2-boot-info \
  -eltorito-alt-boot \
  -e '--interval:appended_partition_2:::' \
    -no-emul-boot \
  "."
kgilmer commented 1 year ago

Thanks @piexil , I will certainly take a look at this for the next regolith ISO release

kgilmer commented 1 year ago

After blindly copy/pasting got the following error (regolith ISO generation):

 xorriso 1.5.4 : RockRidge filesystem manipulator, libburnia project.

Drive current: -outdev 'stdio:/home/runner/work/regolith-ubuntu-iso-builder/regolith-ubuntu-iso-builder/scripts/Regolith.iso'
Media current: stdio file, overwriteable
Media status : is blank
Media summary: 0 sessions, 0 data blocks, 0 data, 29.6g free
xorriso : WARNING : -volid text does not comply to ISO 9660 / ECMA 119 rules
Added to ISO image: directory '/'='/home/runner/work/regolith-ubuntu-iso-builder/regolith-ubuntu-iso-builder/scripts/image'
xorriso : UPDATE :      19 files added in 1 seconds
libisofs: FAILURE : Cannot find directory for El Torito boot catalog in ISO image: '/boot/grub'
libisofs: FAILURE : A requested node does not exist
xorriso : FAILURE : Could not attach El-Torito boot image to ISO 9660 image
xorriso : UPDATE :      19 files added in 1 seconds
xorriso : aborting : -abort_on 'FAILURE' encountered 'FAILURE'
piexil commented 1 year ago

@kgilmer I think it's because the classic bios boot files need to be generated. The given parameter's are how most similar to how modern (>21.10) ubuntu builds their hybrid image.
As I said my project is different so this won't be exact copy-paste to this one, but here's the aprt of my scripts that generates the grub images and makes an ISO.

# # generate grub images
working_dir="$(pwd)"
cd "$iso_rw"

#grub uefi
grub-mkstandalone \
   --format=x86_64-efi \
   --output=isolinux/bootx64.efi \
   --modules="part_gpt part_msdos" \
   --locales="" \
   --fonts="" \
   "boot/grub/grub.cfg=isolinux/grub.cfg"

#fat16 uefi disk image containing bootloader
(
   cd isolinux &&
      dd if=/dev/zero of=efiboot.img bs=1M count=10 &&
      sudo mkfs.vfat efiboot.img &&
      LC_CTYPE=C mmd -i efiboot.img EFI EFI/BOOT &&
      LC_CTYPE=C mcopy -i efiboot.img ./bootx64.efi ::EFI/BOOT/
)

#grub bios images
grub-mkstandalone \
   --format=i386-pc \
   --output=isolinux/core.img \
   --install-modules="linux16 linux normal iso9660 biosdisk memdisk search tar ls" \
   --modules="linux16 linux normal iso9660 biosdisk search" \
   --locales="" \
   --fonts="" \
   "boot/grub/grub.cfg=isolinux/grub.cfg"

#combine
cat /usr/lib/grub/i386-pc/cdboot.img isolinux/core.img >isolinux/bios.img

# some broken UEFIs wont boot unless I do this
cp isolinux/efiboot.img EFI/BOOT/efiboot.img
cp isolinux/bios.img boot/grub/bios.img
cp isolinux/bootx64.efi EFI/BOOT/BOOTx64.EFI
cd "$working_dir"
LC_CTYPE=C mcopy -i ${iso_rw}/isolinux/efiboot.img -s ::EFI/ ${iso_rw}/EFI

# set seed files
cp installer/ubiquity/preseed/* "${iso_rw}/preseed/" || true

# this file will tell grub to look here
touch ${iso_rw}/$OS_NAME

# Regenerate the md5sum over the ISO contents.
working_dir="$(pwd)"
cd "$iso_rw"
rm md5sum.txt || true

/bin/bash -c "(find . -type f -print0 | xargs -0 md5sum | grep -v -e 'md5sum.txt' -e 'bios.img' -e 'efiboot.img' > md5sum.txt)"
cd "$working_dir"
working_dir="$(pwd)"
cd "$iso_rw"
# Create the ISO.
   xorriso -as mkisofs -r \
  -volid "${image_name}" \
  -full-iso9660-filenames \
  -J -J -joliet-long \
  -output "../$output_name" \
  --grub2-mbr /usr/lib/grub/i386-pc/boot_hybrid.img \
  -partition_offset 16 \
  --mbr-force-bootable \
  -append_partition 2 28732ac11ff8d211ba4b00a0c93ec93b isolinux/efiboot.img \
  -appended_part_as_gpt \
  -iso_mbr_part_type a2a0d0ebe5b9334487c068b6b72699c7 \
  -eltorito-boot isolinux/bios.img \
   -no-emul-boot \
   -boot-load-size 4 \
   -boot-info-table \
   --eltorito-catalog boot/grub/boot.cat \
   --grub2-boot-info \
  -eltorito-alt-boot \
  -e '--interval:appended_partition_2:::' \
    -no-emul-boot \
  "../${iso_rw}"

cd "$working_dir"
kgilmer commented 1 year ago

Thanks for the additional details @piexil . I am unable to determine what the following paths are set to in your setup as they don't exist in the mvallim repo:

working_dir
iso_rw

I looked for a fork of yours to see the diff but didn't see one listed on the github forks page. LMK if I missed it. TIA

yveszoundi commented 1 year ago

@kgilmer, I was able to following closely notes from piexil without much effort and I'm now able to use only Grub for both BIOS/Legacy and UEFI boot modes (in my own project, unrelated to this one and for a Debian-based Live CD).

Answers to your questions

Other notes

Example

This is not meant for a "blind copy paste", but to better understand what you might need for "regolith" specifically.

Scripted step resulting in the ISO image creation for my application called Entrusted