Repository navigation
Flashing Modes and Multiboot
Cinderboot automatically inspects source images without mounting or extracting them and selects the optimal flashing strategy, while also allowing explicit mode overrides via CLI (--mode) or the desktop UI.
image.Inspect (internal/image/detect.go) classifies images in the following order:
Detected Kind
|
Detection Criteria | Recommended Mode | Strategy |
|---|---|---|---|
compressed-raw |
File ends in .gz, .bz2, or .zip
|
raw |
Transparently decompresses on the fly and streams bit-for-bit to the USB drive |
windows-iso |
Valid UDF 1.02 or ISO9660 containing both sources/boot.wim and sources/install.wim (or sources/install.esd) |
windows-fat32 |
Formats GPT + FAT32, extracts all files, auto-splits >4 GiB .wim into .swm, injects optional autounattend.xml
|
hybrid-linux-iso |
Valid UDF/ISO9660 with a non-empty MBR partition entry (0x55AA at sector 0) or a GPT header (EFI PART at sector 1) |
raw |
Streams ISO bit-for-bit, verifies SHA-256, and relocates Backup GPT to disk tail if needed |
standard-iso |
Valid UDF/ISO9660 with neither hybrid MBR nor GPT headers | iso-fat32 |
Formats GPT + FAT32 and extracts all ISO files directly |
raw-image |
Any other file (e.g., .img, .raw, .bin) |
raw |
Streams bit-for-bit with optional SHA-256 read-back verification |
When 2 or more images are supplied (or --mode multiboot is selected explicitly), flash.Execute enters Multi-Distro Linux UEFI Multiboot mode (ModeMultiboot).
Implemented in internal/flash/raw.go, Raw mode is used for hybrid Linux ISOs, raw disk images, and .gz/.bz2/.zip compressed images.
-
Pre-Write Wipe (
fs.WipePartitionTables): Zeroes up to 1 MiB at both the beginning and physical end of the target USB drive so leftover MBR/GPT metadata cannot conflict with the new image. - Capacity Check: Rejects images whose known size (or decompressed stream size) exceeds the target drive's reported capacity.
-
2 MiB Aligned Streaming + Live SHA-256:
- Reads and writes in 2 MiB chunks (
rawChunkSize), keeping throughput high while remaining responsive to user cancellation. - Hashes exact logical image bytes before padding any final partial block with zeroes to the device's sector boundary (
sectorSize, default 512 bytes). - Calls
Sync()every 16 MiB (rawSyncInterval) to prevent kernel dirty-page writeback stalls on slow USB controllers.
- Reads and writes in 2 MiB chunks (
-
Transient USB I/O Recovery:
- Both writes (
writeWithRecovery) and verification reads (readWithRecovery) automatically retry transient errors up to 3 times (maxRetryAttempt = 3) with linear backoff (250 ms,500 ms,750 ms), seeking back to the exact byte offset and emitting arecoveringprogress event. - Immediately aborts without retrying on fatal errors:
context.Canceled,context.DeadlineExceeded,ENOSPC,EROFS,EACCES,EPERM,ENODEV(orio.EOFduring verify).
- Both writes (
-
Final Flush & SHA-256 Read-Back Verification (enabled by default,
--verify=true):- Syncs and closes the write descriptor, reopens read-only (
device.OpenRawRead), drops the Linux block device page cache viaBLKFLSBUF(device.FlushReadCache) so bytes are verified from physical flash rather than RAM, reads back the exact written byte count, and compares the read-back SHA-256 digest against the streamed write digest.
- Syncs and closes the write descriptor, reopens read-only (
-
Post-Flash Backup GPT Relocation (
fs.RelocateBackupGPT):- Many modern hybrid Linux ISOs (such as Ubuntu 22.04/24.04+) embed a GPT table sized to the ISO file rather than the larger USB stick, placing the Backup GPT in the middle of the disk.
- Strict UEFI firmwares may reject such a GPT table and fail to see the EFI System Partition.
- After SHA-256 verification completes, Cinderboot checks for a valid Primary GPT whose
AlternateLBA != totalSectors - 1, relocates the Backup Partition Array and Backup GPT Header to the physical end of the USB drive, updatesAlternateLBA,LastUsableLBA, CRC32s, and the Protective MBR sector count, and zeroes the stray mid-disk backup header.
-
Partition Table Rescan: Calls
device.RereadPartitionTablePath(BLKRRPARTon Linux,IOCTL_DISK_UPDATE_PROPERTIESon Windows) so the host OS recognizes the new partitions.
Implemented in internal/flash/multiboot.go, internal/image/efi.go, and internal/image/distro.go, Cinderboot creates multi-distro UEFI bootable USB drives without bundling any third-party bootloader binaries and without hitting FAT32's 4 GiB file size limit.
flowchart LR
PMBR["LBA 0: Protective MBR"]
PGPT["LBA 1..33: Primary GPT"]
P1["Partition 1: 64 MiB FAT32 ESP (CINDERBOOT_ESP) - Extracted GRUB2 + Menu + Chainload EFIs"]
P2["Partition 2: Raw ISO #1 (1 MiB aligned, Unique PARTUUID)"]
P3["Partition 3: Raw ISO #2 (1 MiB aligned, Unique PARTUUID)"]
PN["Partition N+1: Raw ISO #N (1 MiB aligned, Unique PARTUUID)"]
BGPT["Tail 33 Sectors: Backup GPT"]
PMBR --> PGPT --> P1 --> P2 --> P3 --> PN --> BGPT
Because each Linux ISO is written raw into its own 1 MiB-aligned GPT partition (GPTTypeBasicData):
- ISOs larger than 4 GiB work natively with no splitting or repacking.
- Every distro preserves its exact native ISO9660 filesystem, volume label, and modification UUID.
- Every distro receives a cryptographically random, unique GPT
PARTUUID, preventing initramfs collisions when multiple live distros exist on the same USB stick.
Cinderboot extracts signed UEFI bootloaders (BOOTX64.EFI, grubx64.efi, shimx64.efi, mmx64.efi, plus loader/ and boot/grub/ configs) directly from each selected ISO using a 4-stage fallback cascade:
-
GPT EFI System Partition (
GPTTypeEFI) — modern Ubuntu 20.10+, Fedora, Debian 12+, Mint, openSUSE, EndeavourOS, Pop!_OS. -
MBR
0xEFEFI Partition — Arch, Manjaro, and older hybrid ISOs. -
El Torito EFI Boot Catalog Entry (
0x90/0x91header +0xEFplatform ID +0x88bootable entry) — handles xorriso/mkisofs deferred sector counts (secCnt <= 1). -
ISO9660
/EFITree Fallback — scans/EFI/BOOT/*and*.efifiles directly (capped at 16 MiB per file).
To host the primary multiboot menu on Partition 1, Cinderboot prefers an ISO providing both Shim and GRUB2 (HasShim && HasGRUB), falling back to any ISO with GRUB2. It also writes vendor-specific GRUB stub configs in:
EFI/BOOT/grub.cfgEFI/ubuntu/grub.cfgEFI/pop/grub.cfgEFI/fedora/grub.cfgEFI/debian/grub.cfgEFI/opensuse/grub.cfg- plus a
.disk/infomarker on Partition 1 so Ubuntu's signedgrubx64.efibinds to Partition 1 first instead of jumping straight to Partition 2.
For each ISO, Cinderboot parses authentic boot configuration files in priority order to preserve distro-specific kernel flags (such as NVIDIA modules_load=nvidia or custom live-media-path):
-
GRUB2 Configs:
boot/grub/grub.cfg,boot/grub2/grub.cfg,efi/boot/grub.cfg,boot/grub/loopback.cfg(checked in both ISO9660 and extracted ESP). -
systemd-boot Loader Entries:
loader/entries/*.conffrom both ISO9660 and appended FAT ESP (prioritizingpop/live/currententries ahead ofrecovery/fallback/memtest). -
ISOLINUX / SYSLINUX Configs:
isolinux/isolinux.cfg,isolinux/live.cfg,isolinux/txt.cfg,syslinux/syslinux.cfg,boot/syslinux/syslinux.cfg(followingincludedirectives recursively up to depth 4).
Parsed kernel/initrd paths are validated against the ISO9660 tree (resolving ESP-relative paths back to exact ISO9660 paths such as /casper_pop-os_.../vmlinuz.efi).
| Family | Typical Distros | Live Root Pinning Injected by BuildKernelArgs
|
|---|---|---|
pop-os |
Pop!_OS (Intel / NVIDIA) |
boot=casper, live-media-path=/<casper_dir>, live-media=/dev/disk/by-partuuid/<PARTUUID> (inserted before ---) |
ubuntu |
Ubuntu, Linux Mint, Zorin, Elementary |
boot=casper, live-media-path (if non-standard), live-media=/dev/disk/by-partuuid/<PARTUUID>
|
fedora |
Fedora, Rocky, Alma, Nobara, Bazzite |
root=live:PARTUUID=<PARTUUID> (replaces root=live:CDLABEL=...) |
void |
Void Linux |
root=live:PARTUUID=<PARTUUID> with Void live kernel flags |
arch |
Arch Linux, EndeavourOS, CachyOS, Garuda | Strips archisolabel/archisosearchuuid, sets archisodevice=/dev/disk/by-partuuid/<PARTUUID> (loads Intel/AMD microcode initrds when present) |
manjaro |
Manjaro |
misobasedir=manjaro, misolabel=<VolumeLabel> (loads intel_ucode.img/amd_ucode.img when present) |
debian |
Debian, Kali, Parrot, Tails, MX Linux |
boot=live, live-media=/dev/disk/by-partuuid/<PARTUUID>
|
opensuse |
openSUSE | root=live:PARTUUID=<PARTUUID> |
generic |
Other dracut / GRUB2 Linux ISOs | Replaces root=live:CDLABEL= / root=live:LABEL= with root=live:PARTUUID=<PARTUUID>, or falls back to configfile / UEFI chainloader
|
Partition 1's /boot/grub/grub.cfg locates each distro partition using search --no-floppy --fs-uuid --set=root <ISO9660-UUID> (falling back to --label, --file, or (hd0,gptN)), and automatically generates:
- One top-level
menuentryper selected Linux ISO. - A
Native UEFI Chainload (Secure Boot / Fallback)submenu containing each distro's own extracted EFI binaries stored under/EFI/cinderboot/d<N>/, useful when mixing distros signed by different Secure Boot vendor keys. -
UEFI Firmware Settings(fwsetup) andReboot(reboot) utility entries.
Note
Multiboot mode requires uncompressed ISO9660 Linux ISOs and rejects Windows ISOs or compressed .gz/.bz2/.zip archives with a clear error message. Windows ISOs should be flashed individually in windows-fat32 mode.
Source code is licensed under the GNU General Public License v3.0 (GPL-3.0) — by Buntato (buntatoes.dev). The Cinderboot name, flame-USB logo, icons, and branding remain All Rights Reserved.
Getting Started
Core Engine
- Architecture and Pure-Go Design
- Flashing Modes and Multiboot
- Windows ISO, WIM Splitting, and AutoUnattend
Safety, Platforms & Development
Links