Linux Live ISO Builder
Goal: a bootable, reproducible live ISO built from a version-controlled config, not hand-edited images. Reply in the user's language.
1. Settle the brief first
Ask (or infer) and write down: purpose (rescue, privacy, education, kiosk, gaming, pentest lab, installer), base distro the user knows, target hardware (x86_64 / ARM, BIOS / UEFI / Secure Boot), desktop or CLI, size limit (CD 700 MB, DVD 4.7 GB, USB), persistence needed, languages and keyboard (e.g. Persian layout and a Persian font such as Vazirmatn), included software, branding.
2. Pick the toolchain
| Base | Tool | When |
|---|---|---|
| Debian | live-build (lb config, lb build) | Default: stable, well documented, iso-hybrid |
| Ubuntu | live-build or Cubic (GUI remaster) | Ubuntu packages, quick remaster |
| Arch | archiso (mkarchiso) | Rolling, minimal, full control |
| Fedora | kiwi-ng or livemedia-creator | Fedora/RHEL ecosystem |
| Alpine | mkimage.sh (aports/scripts) | Tiny, RAM-based |
| From scratch | Buildroot / Linux From Scratch | Embedded or learning; much more work |
Recommend Debian live-build unless the user has a reason otherwise.
3. Where it runs
Building needs root on a Linux host (chroot, loop mounts, squashfs). A sandboxed workspace usually cannot do loop mounts, so: write the full config and a build.sh here, then the user runs it on their Linux machine, a VM, or a privileged container (docker run --privileged debian:stable). Say this up front.
4. Debian live-build recipe
sudo apt install live-build qemu-system-x86 ovmf
mkdir myiso && cd myiso
lb config \
--distribution bookworm \
--archive-areas "main contrib non-free non-free-firmware" \
--binary-images iso-hybrid \
--debian-installer none \
--bootappend-live "boot=live components quiet splash" \
--iso-application "MyLive" --iso-volume "MyLive"
- Packages:
config/package-lists/desktop.list.chroot(one package per line, e.g.task-xfce-desktop,firmware-linux,network-manager). - Files copied into the system:
config/includes.chroot/(mirror the target path, e.g.etc/skel/, wallpapers,etc/os-releaseoverrides). - Scripts run inside the chroot:
config/hooks/normal/0100-custom.hook.chroot(chmod +x). - Bootloader branding:
config/bootloaders/(copy from/usr/share/live/build/bootloaders). - Build:
sudo lb build 2>&1 | tee build.log. Output:live-image-amd64.hybrid.iso. Clean:sudo lb clean.
5. Arch archiso recipe
sudo pacman -S archiso
cp -r /usr/share/archiso/configs/releng myiso
# edit myiso/packages.x86_64, myiso/airootfs/, myiso/profiledef.sh (iso_name, label)
sudo mkarchiso -v -w /tmp/work -o out myiso
6. Boot, persistence, size
- Support both BIOS (isolinux/syslinux) and UEFI (GRUB); live-build and archiso do both by default. Secure Boot needs the distro's signed shim/GRUB; custom kernels break it unless signed.
- Persistence (Debian): boot param
persistence, plus a USB partition labelledpersistencecontainingpersistence.confwith/ union. - Size: squashfs with xz (
--chroot-squashfs-compression-type xz), drop docs/locales you don't need, avoid full desktop tasks for a CD.
7. Test before anyone writes a USB
qemu-system-x86_64 -enable-kvm -m 4G -cdrom out.iso # BIOS
qemu-system-x86_64 -enable-kvm -m 4G -bios /usr/share/ovmf/OVMF.fd -cdrom out.iso # UEFI
Check: boots in both modes, network, sound, keyboard layouts, fonts, persistence, shutdown. Then publish sha256sum out.iso > SHA256SUMS.
Writing to USB (dd if=out.iso of=/dev/sdX bs=4M status=progress oflag=sync) erases the target disk: always have the user confirm the device with lsblk first, and never run it yourself.
8. Distribution checklist
- Keep the whole config in git; builds must be reproducible from it.
- GPL: if you distribute the ISO, provide (or offer) the corresponding source; keep non-free firmware licences in mind.
- Don't reuse another distro's name or logo as your own branding.
- Document default users/passwords; never ship a known root password without telling users.
Five verified build tiers — run them, do not trust them
tools/liveiso/build_min.sh and tools/liveiso/verify.py in this repository build a hybrid BIOS+UEFI ISO and then prove it boots rather than asserting it.
Tier 1 — structure (build_min.sh), 5/5 verified 2026-11-28
| Check | Result |
|---|---|
| ISO built and non-trivial (11.6 MiB) | PASS |
| El Torito catalogue carries a BIOS boot image | PASS |
| El Torito catalogue carries a UEFI boot image | PASS |
| GRUB 2.12 started under QEMU over serial | PASS |
| Default entry executed and printed its marker | PASS |
Required packages (Debian/Ubuntu): xorriso squashfs-tools grub-pc-bin grub-efi-amd64-bin mtools dosfstools qemu-system-x86.
Tier 2 — a real Linux live system (build_live.sh), 7/7 verified 2026-11-28
Kernel plus a busybox initramfs, so the image reaches userspace, not just a bootloader.
| Check | Result |
|---|---|
| ISO built (27 MiB) | PASS |
| El Torito carries BIOS and UEFI boot images | PASS |
| GRUB started under QEMU | PASS |
| Linux kernel booted | PASS |
| userspace reached and printed its marker | PASS |
| live system powered down cleanly | PASS |
Captured from the serial console of the real boot: kernel 6.8.0-151-generic, arch x86_64, 458 MB RAM, busybox v1.36.1 as init, clean reboot: Power down at 4.5 s. |
./build_live.sh out.iso [payload-dir] [label]
python3 verify.py --mode live # build and boot-test in one command
python3 verify.py --mode live --iso out.iso
Payload. A directory passed as the second argument is copied to /payload in the live system, and /payload/autorun.sh runs automatically at boot. Verified: an ISO carrying this repository's skill list booted, ran the payload and printed the names back over serial. This is how a live image becomes a tool rather than a demo — put your script, dataset or installer in the payload directory.
Interactive mode. The second GRUB entry boots with miras.shell on the kernel command line and drops to a real shell on the console instead of powering off. Everything runs from RAM; nothing on the host disk is mounted or modified.
Kernel selection. build_live.sh takes the newest /boot/vmlinuz-* by default; override with KERNEL=/path/to/vmlinuz. Needs busybox-static, cpio, gzip, grub-pc-bin, grub-efi-amd64-bin, mtools, xorriso, and qemu-system-x86 to test.
Tier 3 — a Knoppix-style Debian live CD (build_debian_live.sh), 8/8 verified 2026-11-28
A full Debian root filesystem in squashfs, mounted read-only and made writable by an overlay in RAM. This is the Knoppix architecture, and it is what most people mean by "a live CD".
| Check | Result |
|---|---|
| ISO built (178 MiB, Debian 12 bookworm) | PASS |
| El Torito carries BIOS and UEFI boot images | PASS |
| GRUB started under QEMU | PASS |
| live medium found by the initramfs | PASS |
| squashfs root mounted with a RAM overlay | PASS |
| live root assembled | PASS |
| Debian userspace booted to a login prompt | PASS |
Captured from the real serial console:
[live] looking for the live medium
[live] medium: /dev/sr0
[live] overlay root ready (read-only squashfs + RAM upper layer)
MIRAS-LIVE-SQUASHFS-ROOT-OK
Debian GNU/Linux 12 MIRAS-live ttyS0
MIRAS-live login:
sudo ./build_debian_live.sh out.iso [rootfs-dir] [label] # bootstraps Debian if no rootfs given
sudo python3 verify.py --mode debian --iso out.iso
How the live root is assembled, which is the part worth understanding:
- GRUB loads the kernel and a small busybox initramfs.
- The initramfs inserts
isofsandoverlay, then scans/dev/sr0,/dev/cdrom,/dev/sda,/dev/vdafor a medium carryinglive/filesystem.squashfs, retrying for ten seconds — CD-ROM devices often appear late. - It mounts the squashfs read-only, a tmpfs sized at 60% of RAM for writes, and joins them with
overlayfs. If overlay is unavailable it falls back to a read-only root and says so rather than failing silently. switch_roothands control to systemd inside the Debian root.
Three real defects found and fixed while building this — each one is the kind that makes a live image look broken for no visible reason:
console=ttyS0,115200 console=tty0sends output to the last console listed, so everything went to the graphics screen and the serial log stayed empty. The order must beconsole=tty0 console=ttyS0,115200.debootstrap --variant=minbasedoes not include udev, so systemd never created/dev/ttyS0as a device unit,serial-gettytimed out after 90 seconds, and no login prompt ever appeared. Addingudevanddbusto the include list fixed it.- Kernel modules on Ubuntu are
.ko.zst; busyboxinsmodcannot read them, so they must be decompressed withzstdinto the initramfs first.
Extend it from here. Put your packages in the --include list or install them into the rootfs before mksquashfs; add a desktop, a toolchain or a rescue set the same way. The ISO is hybrid, so dd it to a USB stick and it boots on real hardware. Persistence is the natural next step: give the overlay's upper directory a partition instead of tmpfs.
Tier 4 — a privacy profile, partly verified (PROFILE=privacy)
Tails-like properties, built and measured rather than claimed. Six verified, three not — and the three are named here rather than left for someone to discover.
| Property | Status | Evidence |
|---|---|---|
| Amnesic root | verified | root is overlay over a read-only squashfs; nothing persists without an explicit volume |
| No swap, ever | verified | swap active: 0 device(s) — swap is the classic way an amnesic system leaks to disk |
| Host disks never auto-mounted | verified | host disks mount: 0, enforced by a udev rule |
| Encrypted persistence | verified across a reboot | a LUKS volume is unlocked and mounted at /persistent; a marker written on one boot was read back on the next: MIRAS-PERSIST-READ: persisted-at-204953 |
| Tor present and running | verified | tor service: active |
| Self test on every boot | verified | the system reports its own policy rather than being trusted |
| Transparent Tor firewall | NOT working | iptables: can't initialize table 'nat' — see below |
| MAC randomisation | not verified | the service runs, but the QEMU NIC kept 52:54:00:12:34:56; untested on real hardware |
| RAM wipe at shutdown | not verified | the unit is installed and ordered before shutdown.target, but nothing here can observe memory after power off |
Why the firewall fails, stated plainly. The image boots the host's Ubuntu kernel with a Debian userspace, so iptable_nat is not loadable and the NAT table never appears — which means the transparent redirect into Tor is not in force. The fail-closed policy is written into the script, but a rule set that does not load protects nothing. Do not treat this profile as anonymity. Four defects were found and fixed along the way (module copy landed one directory level too high; Ubuntu .ko.zst and Debian .ko.xz both need decompressing for busybox insmod; iptables-nft needs nf_tables where iptables-legacy needs ip_tables; modules.dep must be rebuilt in the live system), and the firewall still did not come up.
The real fix is architectural: a live system should boot the kernel from its own distribution, so userspace and modules match. USE_ROOTFS_KERNEL=1 selects it, and Debian's kernel then needs every storage driver in the initramfs that Ubuntu builds in. That path currently stops at no live medium found and is unfinished.
sudo PROFILE=privacy ./build_debian_live.sh out.iso
sudo PROFILE=privacy TEST_KEYFILE=/path/key.bin DEFAULT_ENTRY=1 ./build_debian_live.sh out.iso # test only
TEST_KEYFILE places a key on the medium so persistence can be tested unattended. A key on the medium is not a secret — real use types the passphrase on the console.
Against real Tails, this is not a replacement. Tails ships a hardened kernel, AppArmor confinement, a vetted application set, a verified boot chain, MAT for metadata, an emergency shutdown on medium removal, and years of review by people whose safety depends on it. Anyone who needs anonymity to stay safe should use Tails itself, not this. What is here is a reproducible way to build and measure such properties.
Tier 5 — the real live-build pipeline (build_zal_live.sh), 9/9 verified 2026-11-28
Tiers 1–4 assemble the rootfs by hand. Tier 5 uses Debian's own live-build, so the
result is an ordinary Debian 13 system with apt, systemd and live-config — the
thing a Knoppix or Tails user expects. It cost fifteen defects to get there, every
one of them found by running the build, and every one written down with its evidence
in tools/liveiso/LIVE-BUILD-DEFECTS.md.
Five are configuration (wrong security archive path; a Contents-*.gz fetch that 404s
and was never needed; live-config-sysvinit injected against systemd-sysv;
--debian-installer none rejected; win32-loader gone from trixie). Nine are in
live-build itself at this version — including one that overwrites the host's
/bin/true by writing a stub through a symlink that escapes the chroot, and a
bootloader template whose symlinks still point at syslinux paths from 2012. One is in
the payload: the image shipped a test suite it had no pytest to run.
sudo ./build_zal_live.sh /tmp/work /path/to/payload # payload lands in /opt/zal
python3 verify.py --mode livebuild --iso zal-live.iso
ISO exists and is non-trivial | PASS
El Torito has a BIOS boot image | PASS
El Torito has a UEFI boot image | PASS
GRUB started under QEMU | PASS
initramfs ran the live-boot scripts | PASS
the squashfs on the medium became the root | PASS
systemd reached its default target | PASS
Debian 13 userspace identified itself | PASS
a login prompt was offered on the serial console | PASS
9/9 checks passed (iso: 1108316 KiB)
Beyond the automated checks, the login was used: uid=1000(zal) … 27(sudo), Python
3.13.5, and the payload ran inside the booted system — a mission submitted, executed
(completed_demo) and 6 notes written to SQLite, all from the live medium.
Two lessons worth keeping. First, live-build builds the chroot well and the ISO
badly: let it make the squashfs, then assemble the image yourself with grub-mkrescue,
which produces the BIOS and UEFI entries live-build's grub2 stage does not.
Second, put serial --unit=0 --speed=115200 in grub.cfg and
console=tty0 console=ttyS0,115200 on the kernel line — that is what turns "it boots"
from a claim into a line a script can assert on.
What these five tiers prove and what they do not. Together they prove the ISO
structure, the hybrid BIOS+UEFI boot path, GRUB execution, a real Linux kernel boot, a
squashfs root with a RAM overlay, a Debian userspace reaching a login prompt, and — at
tier 5 — a full live-build Debian 13 system that logs in and runs its payload. What
is still not proven: UEFI boot was confirmed only as a catalogue entry, never
booted under OVMF; nothing was tested on physical hardware; hostname= on the kernel
line had no effect while username= did, and that is undiagnosed; there is no
graphical desktop and no signed Secure Boot chain. For persistence, point the overlay's
upper directory at a partition instead of tmpfs. For Secure Boot, sign the EFI binary
with a key enrolled in the firmware. verify.py --iso yourimage.iso applies the same
checks to any ISO, however it was built.
Serial console is the trick that makes a live ISO testable at all. Adding serial --unit=0 --speed=115200 plus terminal_input/terminal_output serial console to grub.cfg lets QEMU capture the boot in text with -nographic, so boot success becomes an assertion in a script instead of a human squinting at a screenshot.