Skip to content

Instantly share code, notes, and snippets.

@ayosec
Created December 8, 2021 22:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayosec/39bf0b789191705eecff52d241dccae7 to your computer and use it in GitHub Desktop.
Save ayosec/39bf0b789191705eecff52d241dccae7 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Combine multiple squashfs files.
#
# Usage:
#
# $ ../combine-squashfs file1.squashfs file2.squashfs …
set -xeuo pipefail
declare -a MOUNTS
unmount_all() {
for mount in "${MOUNTS[@]}"
do
umount "$mount"
rmdir "$mount"
done
}
TARGET=$(mktemp -d)
trap unmount_all EXIT
for ARG
do
mount="$TARGET/mount/${ARG%.squashfs}"
mkdir -p "$mount"
mount -o loop "$ARG" "$mount"
MOUNTS+=("$mount")
done
mksquashfs "$TARGET/mount" "$HOME/combined-$(date +%s).squashfs"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment