Last active
April 10, 2024 06:24
-
-
Save LordVeovis/faa8d952c0ad784e33d49251bca17504 to your computer and use it in GitHub Desktop.
PXE v2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
tftp_root=/srv/tftp3/root | |
alias de='docker exec' | |
[ -d "$tftp_root" ] || mkdir -p "$tftp_root" | |
mkdir $tftp_root/isos | |
mkdir -p /mnt/iso | |
# download grub for ubuntu | |
# https://ubuntu.com/server/docs/install/netboot-amd64 | |
mkdir -p $tftp_root/boot/ubuntu/grub | |
mkdir -p $tftp_root/grub/x86_64-efi | |
docker pull ubuntu | |
dc_ubuntu=$(docker run --rm -d --name ubuntu ubuntu bash -c "while true; do sleep 30; done") | |
de "$dc_ubuntu" apt-get update | |
de "$dc_ubuntu" apt-get upgrade -y | |
de "$dc_ubuntu" apt-get install cd-boot-images-amd64 | |
de -u _apt -w /tmp "$dc_ubuntu" apt-get download shim-signed | |
de "$dc_ubuntu" bash -c "dpkg-deb --fsys-tarfile /tmp/shim-signed*deb | tar x ./usr/lib/shim/shimx64.efi.signed.latest -O" > "$tftp_root"/boot/ubuntu/bootx64.efi | |
de -u _apt -w /tmp "$dc_ubuntu" apt-get download grub-efi-amd64-signed | |
de "$dc_ubuntu" bash -c "dpkg-deb --fsys-tarfile /tmp/grub-efi-amd64-signed*deb | tar x ./usr/lib/grub/x86_64-efi-signed/grubnetx64.efi.signed -O" > "$tftp_root"/boot/ubuntu/grubx64.efi | |
de -u _apt -w /tmp "$dc_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 "$dc_ubuntu" apt-get install -y grub-efi-amd64-bin | |
docker cp "$dc_ubuntu":/usr/lib/grub/x86_64-efi/command.lst "$tftp_root"/grub/x86_64-efi/ | |
docker cp "$dc_ubuntu":/usr/lib/grub/x86_64-efi/fs.lst "$tftp_root"/grub/x86_64-efi/ | |
docker cp "$dc_ubuntu":/usr/lib/grub/x86_64-efi/crypto.lst "$tftp_root"/grub/x86_64-efi/ | |
docker cp "$dc_ubuntu":/usr/lib/grub/x86_64-efi/terminal.lst "$tftp_root"/grub/x86_64-efi/ | |
#de "$dc_ubuntu" tar cv --exclude 'monolithic' /usr/lib/grub/x86_64-efi/{command,fs,crypto,terminal}.lst | tar xv --strip-components 3 -C "$tftp_root"/grub/x86_64-efi | |
de -e DEBIAN_FRONTEND=noninteractive "$dc_ubuntu" apt-get install -y console-setup grub-common | |
de "$dc_ubuntu" grub-kbdcomp -o /tmp/prout fr | |
docker kill "$dc_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.4-live-server-amd64.iso http://ubuntu.mirrors.ovh.net/ubuntu-releases/jammy/ubuntu-22.04.4-live-server-amd64.iso | |
mount -t iso9660 -o loop,ro "$tftp_root"/isos/ubuntu-22.04.4-live-server-amd64.iso /mnt/iso/ | |
cp /mnt/iso/casper/hwe-* "$tftp_root"/ubuntu/22.04/ | |
umount /mnt/iso |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local-service | |
dhcp-range=192.168.45.0,proxy,255.255.255.0 | |
dhcp-vendorclass=BIOS,PXEClient:Arch:00000 | |
dhcp-vendorclass=UEFI32,PXEClient:Arch:00006 | |
dhcp-vendorclass=UEFI,PXEClient:Arch:00007 | |
dhcp-vendorclass=UEFI64,PXEClient:Arch:00009 | |
dhcp-boot=boot/ubuntu/bootx64.efi,,192.168.45.102 | |
pxe-service=net:#ipxe,x86PC, "prout",1 | |
log-dhcp | |
conf-dir=/etc/dnsmasq.d/,*.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set default="0" | |
set timeout=3 | |
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 | |
menuentry 'Ubuntu 22.04 - NUC13' --class ubuntu --class gnu-linux --class gnu --class os { | |
gfxmode $linux_gfx_mode | |
linuxefi /ubuntu/22.04/hwe-vmlinuz ip=dhcp netboot=nfs nfsroot=192.168.45.102:/mnt/ubuntu-22.04.4-live-server-amd64.iso $vt_handoff autoinstall ds=nocloud\;s=http://192.168.45.102/cloud-init/__dmi.system-serial-number__/ --- | |
initrdefi /ubuntu/22.04/hwe-initrd | |
} | |
# 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 'ESXi 8.0u1a' --class esxi --class os { | |
chainloader /esxi/mboot.efi -V -c boot.cfg | |
} | |
menuentry 'Memtest86' { | |
chainloader /memtest/BOOTX64.efi | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sv-alp-pxe:/etc# tree /srv/tftp3 | |
/srv/tftp3 | |
└── root | |
├── boot | |
│ └── ubuntu | |
│ ├── bootx64.efi | |
│ ├── grub | |
│ │ └── x86_64-efi | |
│ │ ├── command.lst | |
│ │ ├── crypto.lst | |
│ │ ├── fdt.lst | |
│ │ ├── fs.lst | |
│ │ ├── moddep.lst | |
│ │ ├── partmap.lst | |
│ │ ├── parttool.lst | |
│ │ ├── terminal.lst | |
│ │ └── video.lst | |
│ └── grubx64.efi | |
├── grub | |
│ ├── grub.cfg | |
│ └── x86_64-efi | |
│ ├── command.lst | |
│ ├── crypto.lst | |
│ ├── fs.lst | |
│ └── terminal.lst | |
├── isos | |
│ └── ubuntu-22.04.4-live-server-amd64.iso | |
└── ubuntu | |
└── 22.04 | |
├── hwe-initrd | |
└── hwe-vmlinuz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment