Switch image scripts to zstd compression

- 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 <noreply@anthropic.com>
This commit is contained in:
Aaron D. Lee
2026-01-03 00:56:41 -05:00
parent c6f816d61f
commit 45b99d2c5e
2 changed files with 23 additions and 14 deletions

View File

@@ -49,15 +49,24 @@ fi
# Detect compression # Detect compression
COMPRESSED=false COMPRESSED=false
COMP_TYPE=""
if [[ "$IMAGE" == *.xz ]]; then if [[ "$IMAGE" == *.xz ]]; then
COMPRESSED=true COMPRESSED=true
COMP_TYPE="xz"
if ! command -v xzcat &> /dev/null; then if ! command -v xzcat &> /dev/null; then
echo -e "${RED}Error: xz is required for .xz files but not installed.${NC}" echo -e "${RED}Error: xz is required for .xz files but not installed.${NC}"
exit 1 exit 1
fi 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 elif [[ "$IMAGE" == *.gz ]]; then
COMPRESSED=true COMPRESSED=true
COMP_CMD="zcat" COMP_TYPE="gz"
if ! command -v zcat &> /dev/null; then if ! command -v zcat &> /dev/null; then
echo -e "${RED}Error: gzip is required for .gz files but not installed.${NC}" echo -e "${RED}Error: gzip is required for .gz files but not installed.${NC}"
exit 1 exit 1
@@ -182,11 +191,11 @@ echo -e "${GREEN}Flashing image to $SELECTED...${NC}"
echo "" echo ""
if [ "$COMPRESSED" = true ]; then if [ "$COMPRESSED" = true ]; then
if [[ "$IMAGE" == *.xz ]]; then case "$COMP_TYPE" in
pv "$IMAGE" | xzcat | dd of="$SELECTED" bs=4M conv=fsync 2>/dev/null xz) pv "$IMAGE" | xzcat | dd of="$SELECTED" bs=4M conv=fsync 2>/dev/null ;;
else zst) pv "$IMAGE" | zstdcat | dd of="$SELECTED" bs=4M conv=fsync 2>/dev/null ;;
pv "$IMAGE" | zcat | dd of="$SELECTED" bs=4M conv=fsync 2>/dev/null gz) pv "$IMAGE" | zcat | dd of="$SELECTED" bs=4M conv=fsync 2>/dev/null ;;
fi esac
else else
pv "$IMAGE" | dd of="$SELECTED" bs=4M conv=fsync 2>/dev/null pv "$IMAGE" | dd of="$SELECTED" bs=4M conv=fsync 2>/dev/null
fi fi

View File

@@ -4,7 +4,7 @@
# Auto-detects SD card, copies with progress, shrinks, and compresses # Auto-detects SD card, copies with progress, shrinks, and compresses
# #
# Usage: ./pull-image.sh [output-name] # 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 set -e
@@ -17,7 +17,7 @@ BOLD='\033[1m'
NC='\033[0m' NC='\033[0m'
# Check for required tools # 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 if ! command -v $cmd &> /dev/null; then
echo -e "${RED}Error: $cmd is required but not installed.${NC}" echo -e "${RED}Error: $cmd is required but not installed.${NC}"
exit 1 exit 1
@@ -34,14 +34,14 @@ fi
if [ -n "$1" ]; then if [ -n "$1" ]; then
OUTPUT="$1" OUTPUT="$1"
else else
OUTPUT="stegasoo-rpi-$(date +%Y%m%d).img.xz" OUTPUT="stegasoo-rpi-$(date +%Y%m%d).img.zst"
fi fi
# Remove .xz extension for intermediate file # Remove .zst extension for intermediate file
IMG_FILE="${OUTPUT%.xz}" IMG_FILE="${OUTPUT%.zst}"
if [[ "$IMG_FILE" == "$OUTPUT" ]]; then if [[ "$IMG_FILE" == "$OUTPUT" ]]; then
IMG_FILE="${OUTPUT}.img" IMG_FILE="${OUTPUT}.img"
OUTPUT="${OUTPUT}.img.xz" OUTPUT="${OUTPUT}.img.zst"
fi fi
echo -e "${BLUE}" echo -e "${BLUE}"
@@ -167,8 +167,8 @@ else
fi fi
echo "" echo ""
echo -e "${GREEN}[3/3]${NC} Compressing with xz..." echo -e "${GREEN}[3/3]${NC} Compressing with zstd..."
pv "$IMG_FILE" | xz -9 -T0 > "$OUTPUT" pv "$IMG_FILE" | zstd -19 -T0 -q > "$OUTPUT"
rm -f "$IMG_FILE" rm -f "$IMG_FILE"
echo "" echo ""