Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Interest in a lower compression iso optimized for USB booting?
#53
I have written a script that remasters DSL 2024 ISOs with zstd compression. This way they will boot approximately as quickly as LZ4 but take up less space on your USB drive. The script requires the live SquashFS filesystem to be located at /antiX/linuxfs inside the ISO, which has been the case so far.

Example usage:

Code:
./zstandardize.sh dsl-2024.rc3.iso dsl-2024.rc3.zstd.iso

Script:

Code:
#! /bin/bash
# zstandardize.sh - a script that remasters a DSL 2024 ISO image
# with Zstandard compression for the SquashFS filesystem.
#
# Run this script as root.
# Not running unsquashfs(1) and mksquashfs(1) as root
# will result in a partially broken live CD
# due to incorrect file ownership.
# As of DSL 2024 RC3,
# the live CD will have no wireless networks listed in Connman,
# and sudo(1) and su(1) will not work.
#
# This script has been tested using RC3 ISO images
# on Debian 12 and Ubuntu 22.04.
#
# Dependencies on Debian 12 and similar distributions:
# $ sudo apt install squashfs-tools xorriso
#
# Copyright (c) 2024 D. Bohdan.
# License: MIT.
# https://dbohdan.mit-license.org/@2024/license.txt

set -eu -o pipefail

COMPRESSION_LEVEL=19

usage() {
    printf 'usage: %s src.iso dest.iso\n' "$(basename "$0")"
}

if [[ $# -ne 2 ]]; then
    usage > /dev/stderr
    exit 2
fi

src="$1"
dest="$2"
work_dir="$dest.work"

if ! [[ -f $src ]]; then
    echo "source ISO image path isn't a file" > /dev/stderr
    exit 1
fi

mkdir -p "$work_dir"

# Extract the SquashFS filesystem from the ISO image.
rm "$work_dir"/linuxfs || true

xorriso \
    -osirrox on \
    -indev "$src" \
    -extract /antiX/linuxfs "$work_dir"/linuxfs \
    ;

# Recompress the SquashFS filesystem with Zstandard compression.
rm -rf "$work_dir"/linuxfs-contents || true

unsquashfs \
    -d "$work_dir"/linuxfs-contents \
    "$work_dir"/linuxfs \
    ;

rm "$work_dir"/linuxfs.new || true

mksquashfs \
    "$work_dir"/linuxfs-contents \
    "$work_dir"/linuxfs.new \
    -comp zstd \
    -Xcompression-level "$COMPRESSION_LEVEL" \
    ;

md5sum "$work_dir"/linuxfs.new \
    | awk '{ print $1, " linuxfs" }' > "$work_dir"/linuxfs.new.md5 \
    ;

# Create a new ISO image with the recompressed filesystem.
rm "$dest" || true

xorriso \
    -boot_image isolinux keep \
    -indev "$src" \
    -outdev "$dest" \
    -map "$work_dir"/linuxfs.new /antiX/linuxfs \
    -map "$work_dir"/linuxfs.new.md5 /antiX/linuxfs.md5 \
    ;
Reply


Messages In This Thread
RE: Interest in a lower compression iso optimized for USB booting? - by dbohdan - 04-10-2024, 07:44 AM

Forum Jump:


Users browsing this thread: 6 Guest(s)