How does one turn a debootstrap rootfs into a bootable custom EFI ISO with GRUB?
0
votes
0
answers
156
views
I'm experimenting with creating a "custom" specific-purpose Linux distro based on Debian (Clonezilla-style, or even GPartedOS-style). In my case, it's a Python script that runs at boot. Right now, it's a simple "Hello, World!" application that refreshes the screen with how many seconds the script has been running (just as a test).
I've created a script to generate a rootfs as well as compile and install Python 3.11 within it:
# Boot image build script
# Builds a small, specific-purpose bootable (UEFI-only) x64 ISO based on Debian.
# This script currently only supports running on Debian hosts!!!
set -e
ROOT_DIR="rootfs"
# Run debootstrap to create the rootfs if it doesn't exist
[ ! -d $ROOT_DIR ] && sudo debootstrap --arch=amd64 buster $ROOT_DIR
set +e # if this isn't here, any future failure will cause the script to stop, and the temporary directories won't be unmounted, which means host system will slowly break down until a reboot.
# Enter CHROOT and modify rootfs
cat /var/lib/dbus/machine-id
apt-get install linux-image-amd64 live-boot linux-headers-amd64 grub-efi -y
# apt-get install python3
apt-get clean -y
EOF
PYTHON_INSTALL_SCRIPT=$( cat build-python.sh )
cat build-python.sh | sudo chroot $ROOT_DIR
cat << EOF | sudo chroot $ROOT_DIR
# Cleanup before we leave
rm /var/lib/dbus/machine-id && rm -rf /tmp/*
umount /proc /sys /dev/pts
EOF
My goal is to turn this into a bootable UEFI-only ISO with GRUB, since this image will have tools not compatible with BIOS/CSM systems. How do I turn this into a bootable GRUB ISO image (I might want the final ISO image to have some extra files in it, so the ISO will be created from a directory.)
Asked by Joseph .M 101
(101 rep)
Oct 2, 2024, 03:12 PM