dehydrate-fs is a family of tools for separating out files from disk images for the efficient storage of both.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

26 Zeilen
877B

  1. #!/usr/bin/env bash
  2. set -eo pipefail
  3. image="$1"; [ -z "$1" ] && { echo "No image file specified!" >&2; exit 1; }
  4. mfile="$2"; [ -z "$2" ] && { echo "No mapfile specified!" >&2; exit 1; }
  5. [ -z "$3" -a -t 1 ] && { echo "The output of this script is unsafe for raw display." >&2
  6. exit 1; } \
  7. || ofile=${3:-/dev/stdout}
  8. BLOCKSIZE=`sed -nE 's/^#BLOCKSIZE=([0-9]+)$/\1/p' "$mfile"`
  9. [ -z "$BLOCKSIZE" ] && { echo "Mapfile does not specify blocksize!" >&2; exit 1; }
  10. shopt -s expand_aliases
  11. alias dd="dd bs=$BLOCKSIZE status=none"
  12. {
  13. i=0
  14. while read -r -d$'\n' _ block lengt _; do
  15. #Leaves the remainder block for convenience
  16. dd if="$image" skip=$i count=$((block-i))
  17. dd if=/dev/zero count=$((lengt-1))
  18. i=$((block+lengt-1))
  19. done < <(grep -v ^\# "$mfile" | sed -En '/[a-f0-9]{64}/!p' | sort -unk2)
  20. dd if="$image" skip=$i
  21. } > "$ofile"