Skip to content

Instantly share code, notes, and snippets.

@LordVeovis
Last active June 19, 2023 18:33
Show Gist options
  • Save LordVeovis/48af9a5c4d775be800a8e70be083cf6a to your computer and use it in GitHub Desktop.
Save LordVeovis/48af9a5c4d775be800a8e70be083cf6a to your computer and use it in GitHub Desktop.
grub.cfg (pxe alpha)
#!/bin/sh
tftp_root=$1
workdir=$(mktemp -d)
url='https://www.memtest86.com/downloads/memtest86-usb.zip'
command -v apt
if [ "_$?" = "_0" ]; then
apt-get update
apt-get install -y wget unzip
fi
cd "$workdir"
wget "$url"
unzip memtest86-usb.zip
mkdir "$workdir"/img
losetup -rP -f "$workdir"/memtest86-usb.img
mount -t vfat -o ro /dev/loop0p2 "$workdir"/img
mkdir "$tftp_root"/memtest
cp -r "$workdir"/img/EFI/BOOT/* "$tftp_root"/memtest/
umount "$workdir"/img
losetup -d /dev/loop0
#!/bin/sh
tftp_root=/srv/tftp2/root
alias de='docker exec'
[ -d "$tftp_root" ] || mkdir -p "$tftp_root/grub"
mkdir $tftp_root/isos
mkdir -p /mnt/iso
# download grub
# https://ubuntu.com/server/docs/install/netboot-amd64
docker pull ubuntu
docker run --rm -d --name ubuntu ubuntu bash -c "while true; do sleep 30; done"
de ubuntu apt-get update
de ubuntu apt-get upgrade -y
de ubuntu apt-get install cd-boot-images-amd64
de ubuntu apt-get download shim-signed
de ubuntu bash -c "dpkg-deb --fsys-tarfile shim-signed*deb | tar x ./usr/lib/shim/shimx64.efi.signed.latest -O" > "$tftp_root"/bootx64.efi
de ubuntu apt-get download grub-efi-amd64-signed
de ubuntu bash -c "dpkg-deb --fsys-tarfile grub-efi-amd64-signed*deb | tar x ./usr/lib/grub/x86_64-efi-signed/grubnetx64.efi.signed -O" > "$tftp_root"/grubx64.efi
de ubuntu apt-get download grub-common
de ubuntu bash -c "dpkg-deb --fsys-tarfile grub-common*deb | tar x ./usr/share/grub/ascii.pf2 -O" > "$tftp_root"/ascii.pf2
de ubuntu bash -c "dpkg-deb --fsys-tarfile grub-common*deb | tar x ./usr/share/grub/euro.pf2 -O" > "$tftp_root"/euro.pf2
de ubuntu bash -c "dpkg-deb --fsys-tarfile grub-common*deb | tar x ./usr/share/grub/unicode.pf2 -O" > "$tftp_root"/unicode.pf2
de ubuntu apt-get install -y grub-efi-amd64-bin
de ubuntu tar cv --exclude 'monolithic' /usr/lib/grub/x86_64-efi/*.lst | tar xv --strip-components 3 -C "$tftp_root"/grub
de -e DEBIAN_FRONTEND=noninteractive ubuntu apt-get install -y console-setup grub-common
de ubuntu grub-kbdcomp -o /tmp/prout fr
docker kill ubuntu
[ -d "$tftp_root"/ubuntu/22.04 ] || mkdir -p "$tftp_root"/ubuntu/22.04
#wget -O "$tftp_root"/isos/ubuntu-22.04.2-live-server-amd64.iso https://releases.ubuntu.com/22.04.2/ubuntu-22.04.2-live-server-amd64.iso
wget -O "$tftp_root"/isos/ubuntu-22.04.2-live-server-amd64.iso http://ubuntu.mirrors.ovh.net/ubuntu-releases/jammy/ubuntu-22.04.2-live-server-amd64.iso
mount -t iso9660 -o loop,ro "$tftp_root"/isos/ubuntu-22.04.2-live-server-amd64.iso /mnt/iso/
cp /mnt/iso/casper/hwe-* "$tftp_root"/ubuntu/22.04/
umount /mnt/iso
set default="0"
set timeout=-1
if loadfont unicode ; then
set gfxmode=auto
set locale_dir=$prefix/locale
set lang=en_US
fi
terminal_output gfxterm
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
#if background_color 44,0,0; then
# clear
#fi
function gfxmode {
set gfxpayload="${1}"
if [ "${1}" = "keep" ]; then
set vt_handoff=vt.handoff=7
else
set vt_handoff=
fi
}
set linux_gfx_mode=keep
export linux_gfx_mode
# https://github.com/canonical/cloud-init/blob/main/doc/rtd/explanation/kernel-cmdline.rst
menuentry 'Ubuntu 22.04' --class ubuntu --class gnu-linux --class gnu --class os {
gfxmode $linux_gfx_mode
linuxefi /ubuntu/22.04/hwe-vmlinuz ip=dhcp url=http://192.168.45.137/isos/ubuntu-22.04.2-live-server-amd64.iso $vt_handoff language=fr country=FR de=nocloud-net root=/dev/ram0 ramdisk_size=1500000
initrdefi /ubuntu/22.04/hwe-initrd
}
menuentry 'Memtest86' {
chainloader /memtest/BOOTX64.efi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment