From 45b99d2c5ecaad3912deaaf8b84ffe7bd1ea3b24 Mon Sep 17 00:00:00 2001 From: "Aaron D. Lee" Date: Sat, 3 Jan 2026 00:56:41 -0500 Subject: [PATCH] Switch image scripts to zstd compression MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - pull-image.sh now uses zstd -19 instead of xz -9 (much faster, similar ratio) - flash-image.sh supports .zst, .xz, and .gz formats - Default output is now .img.zst 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- rpi/flash-image.sh | 21 +++++++++++++++------ rpi/pull-image.sh | 16 ++++++++-------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/rpi/flash-image.sh b/rpi/flash-image.sh index 193aca1..b0598cd 100755 --- a/rpi/flash-image.sh +++ b/rpi/flash-image.sh @@ -49,15 +49,24 @@ fi # Detect compression COMPRESSED=false +COMP_TYPE="" if [[ "$IMAGE" == *.xz ]]; then COMPRESSED=true + COMP_TYPE="xz" if ! command -v xzcat &> /dev/null; then echo -e "${RED}Error: xz is required for .xz files but not installed.${NC}" exit 1 fi +elif [[ "$IMAGE" == *.zst ]]; then + COMPRESSED=true + COMP_TYPE="zst" + if ! command -v zstdcat &> /dev/null; then + echo -e "${RED}Error: zstd is required for .zst files but not installed.${NC}" + exit 1 + fi elif [[ "$IMAGE" == *.gz ]]; then COMPRESSED=true - COMP_CMD="zcat" + COMP_TYPE="gz" if ! command -v zcat &> /dev/null; then echo -e "${RED}Error: gzip is required for .gz files but not installed.${NC}" exit 1 @@ -182,11 +191,11 @@ echo -e "${GREEN}Flashing image to $SELECTED...${NC}" echo "" if [ "$COMPRESSED" = true ]; then - if [[ "$IMAGE" == *.xz ]]; then - pv "$IMAGE" | xzcat | dd of="$SELECTED" bs=4M conv=fsync 2>/dev/null - else - pv "$IMAGE" | zcat | dd of="$SELECTED" bs=4M conv=fsync 2>/dev/null - fi + case "$COMP_TYPE" in + xz) pv "$IMAGE" | xzcat | dd of="$SELECTED" bs=4M conv=fsync 2>/dev/null ;; + zst) pv "$IMAGE" | zstdcat | dd of="$SELECTED" bs=4M conv=fsync 2>/dev/null ;; + gz) pv "$IMAGE" | zcat | dd of="$SELECTED" bs=4M conv=fsync 2>/dev/null ;; + esac else pv "$IMAGE" | dd of="$SELECTED" bs=4M conv=fsync 2>/dev/null fi diff --git a/rpi/pull-image.sh b/rpi/pull-image.sh index 373f0e2..74c7d68 100755 --- a/rpi/pull-image.sh +++ b/rpi/pull-image.sh @@ -4,7 +4,7 @@ # Auto-detects SD card, copies with progress, shrinks, and compresses # # Usage: ./pull-image.sh [output-name] -# Output will be: stegasoo-rpi-YYYYMMDD.img.xz (or custom name) +# Output will be: stegasoo-rpi-YYYYMMDD.img.zst (or custom name) # set -e @@ -17,7 +17,7 @@ BOLD='\033[1m' NC='\033[0m' # Check for required tools -for cmd in dd pv xz lsblk; do +for cmd in dd pv zstd lsblk; do if ! command -v $cmd &> /dev/null; then echo -e "${RED}Error: $cmd is required but not installed.${NC}" exit 1 @@ -34,14 +34,14 @@ fi if [ -n "$1" ]; then OUTPUT="$1" else - OUTPUT="stegasoo-rpi-$(date +%Y%m%d).img.xz" + OUTPUT="stegasoo-rpi-$(date +%Y%m%d).img.zst" fi -# Remove .xz extension for intermediate file -IMG_FILE="${OUTPUT%.xz}" +# Remove .zst extension for intermediate file +IMG_FILE="${OUTPUT%.zst}" if [[ "$IMG_FILE" == "$OUTPUT" ]]; then IMG_FILE="${OUTPUT}.img" - OUTPUT="${OUTPUT}.img.xz" + OUTPUT="${OUTPUT}.img.zst" fi echo -e "${BLUE}" @@ -167,8 +167,8 @@ else fi echo "" -echo -e "${GREEN}[3/3]${NC} Compressing with xz..." -pv "$IMG_FILE" | xz -9 -T0 > "$OUTPUT" +echo -e "${GREEN}[3/3]${NC} Compressing with zstd..." +pv "$IMG_FILE" | zstd -19 -T0 -q > "$OUTPUT" rm -f "$IMG_FILE" echo ""