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
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

View File

@@ -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 ""