multimico / cluster

This repository contains all relevant information for our multimico edge cluster
Creative Commons Zero v1.0 Universal
0 stars 0 forks source link

Cloud-Init Boot USB Stick #14

Closed phish108 closed 2 years ago

phish108 commented 2 years ago

Ich habe erfolgreich ein angepasstes Ubuntu Iso erstellt.

Die initiale Idee und Logik kommt von https://gist.github.com/s3rj1k/55b10cd20f31542046018fcce32f103e

Anschliessend für aktuelle Ubuntu-Versionen noch die Verbesserungen von https://askubuntu.com/questions/1289400/remaster-installation-image-for-ubuntu-20-10

Die folgende Logik funktioniert nur unter Linux.

  1. Voraussetzungen:
apt-get install -y wget xorriso p7zip-full fakeroot binutils isolinux
  1. Image downloaden
RELEASE=21.10
EXTENSION=ZHAW

ISO="ubuntu-$RELEASE-live-server-amd64.iso"

wget https://releases.ubuntu.com/$RELEASE/$ISO
  1. Boot tools extrahieren:
OUTPUTISO=$(echo $ISO | sed -E "s/.iso/-$EXTENSION.iso/")
MBR=$(echo $ISO | sed -E "s/.iso/.mbr/")
EFI=$(echo $ISO | sed -E "s/.iso/.efi/")

# Extract the MBR template
dd if="$ISO" bs=1 count=446 of="$MBR"

# Extract EFI partition image
skip=$(/sbin/fdisk -l "$ISO" | fgrep '.iso2 ' | awk '{print $2}')
size=$(/sbin/fdisk -l "$ISO" | fgrep '.iso2 ' | awk '{print $4}')
dd if="$ISO" bs=512 skip="$skip" count="$size" of="$EFI"
  1. ISO Image extrahieren
mkdir iso_helper

xorriso -osirrox on -indev "$ISO" -extract / iso_helper && chmod -R +w iso_helper
  1. Anpassungen vornehmen
sed -i 's|---|ip=dhcp autoinstall "ds=nocloud-net;s=https://raw.githubusercontent.com/multimico/cluster/ci/" ---|g' iso_helper/boot/grub/grub.cfg

# Integritätscheck noch auffrischen. 
mv iso_helper/ubuntu .

(cd iso_helper; find '!' -name "md5sum.txt" '!' -path "./isolinux/*" -follow -type f -exec "$(which md5sum)" {} \; > ../md5sum.txt)

mv md5sum.txt ubuntu iso_helper/
  1. Image neu bauen
xorriso -as mkisofs \
  -r -V "Ubuntu $RELEASE Autoinstaller" -J -joliet-long -l \
  -iso-level 3 \
  -partition_offset 16 \
  --grub2-mbr "$MBR" \
  --mbr-force-bootable \
  -append_partition 2 0xEF "$EFI" \
  -appended_part_as_gpt \
  -c /boot.catalog \
  -b /boot/grub/i386-pc/eltorito.img \
    -no-emul-boot -boot-load-size 4 -boot-info-table --grub2-boot-info \
  -eltorito-alt-boot \
  -e '--interval:appended_partition_2:all::' \
    -no-emul-boot \
  -o "$OUTPUTISO" \
  iso_helper

Danach kann das neue ISO mit dd auf einen USB-Stick gebrannt werden: https://thornelabs.net/posts/create-a-bootable-ubuntu-usb-drive-in-os-x.html

bajkad commented 2 years ago

Eine weiterer wichtiger Schritt Richtung automatisiertem MultiMico Infrastruktur-Setup! 😃

phish108 commented 2 years ago

moved to multimico/imager