#!/usr/bin/env bash # Additional details from # https://www.opengeeks.me/2015/04/build-your-hybrid-debian-distro-with-xorriso/ # https://wiki.archlinux.org/index.php/Chroot # Install required packages apt install debootstrap squashfs-tools syslinux isolinux syslinux-common xorriso # Make a working dir and a chroot dir mkdir -p livebuild/chroot # Bootstrap Debian into chroot cd livebuild debootstrap --arch=amd64 testing chroot # Mount filesystemd and chroot mount -t proc /proc chroot/proc/ mount --rbind /sys chroot/sys/ mount --rbind /dev chroot/dev/ mount --rbind /run chroot/run/ chroot chroot /bin/bash # Install and configure live system the way you like echo "DebianLive" > /etc/hostname echo -e '127.0.0.1\tlocalhost' > /etc/hosts echo -e '127.0.1.1\tDebianLive' >> /etc/hosts echo '' >> /etc/hosts echo -e '::1\t\tlocalhost ip6-localhost ip6-loopback' >> /etc/hosts echo -e 'ff02::1\t\tip6-allnodes' >> /etc/hosts echo -e 'ff02::2\t\tip6-allrouters' >> /etc/hosts apt install linux-image-amd64 linux-headers-amd64 firmware-* memtest86+ live-boot debian-installer-launcher debootstrap apt-file aria2 bash-completion ntfs-3g btrfs-progs btrfs-compsize btrfs-heatmap btrfsmaintenance build-essential ccache checkinstall chrony cifs-utils cmake command-not-found cryptsetup curl deb-multimedia-keyring dosfstools duperemove e2fsprogs ethtool fail2ban fuse git xfsprogs nano vim man less testdisk wireguard zfs-dkms grub-efi-amd64 grub-pc-bin haveged hwinfo iftop iotop iptables iputils-ping jq localepurge locales lsb-base lshw lz4 net-tools nfs-common network-manager* nodm openconnect pigz python python-pip python-dev python3 python3-pip python3-dev rsync screen smartmontools sudo sshpass strace tcpdump terminology tlp tp-smapi-dkms tshark ttf-mscorefonts-installer wget wireshark xz-utils zlib1g zstd zfs-initramfs chntpw cmospwd lsof dnsutils xfce4* imagemagick spellutils wamerican-insane xsensors zip unzip rar unar p7zip mdadm udftools udisks2* ffmpeg vlc* fancontrol paprefs pasystray pavumeter pavucontrol-qt i2c-tools f2fs-tools nilfs-tools reiserfsprogs libdvdcss2 libdvdread4 apt autoremove --purge apt clean apt autoclean rm -rf /tmp/* # Exit from chroot exit # Unmount chrooted environment umount --recursive chroot # Start building ISO mkdir -p image/{live,isolinux} cp chroot/boot/vmlinuz* image/live/vmlinuz cp chroot/boot/initrd* image/live/initrd cp chroot/boot/memtest86+.bin image/live/memtest86+.bin cp chroot/boot/memtest86+_multiboot.bin image/live/memtest86+_multiboot.bin cp /usr/lib/ISOLINUX/isolinux.bin image/isolinux/ cp /usr/lib/syslinux/modules/bios/* image/isolinux/ echo > image/isolinux/isolinux.cfg << EOF UI menu.c32 prompt 0 menu title Debian Live timeout 30 label Debian Live menu label ^Debian Live menu default kernel /live/vmlinuz append initrd=/live/initrd boot=live label hdt menu label ^Hardware Detection Tool (HDT) kernel hdt.c32 text help HDT displays low-level information about the systems hardware. endtext label Memtest86+ menu label ^Memory Failure Detection (memtest86+) /live/memtest86+.bin label Memtest86+ (multiboot) menu label ^Memory Failure Detection (memtest86+) /live/memtest86+_multiboot.bin EOF # Make squashfs mksquashfs chroot/ image/live/filesystem.squashfs -e boot # Create hybrid ISO xorriso -as mkisofs -r -J -joliet-long -l -cache-inodes -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin -partition_offset 16 -A "Debian Live" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o debianlive.iso image