#!/bin/bash usage="Usage: $0 DEVICE FILE Try \`$0 --help' for more information." help="Usage: $0 DEVICE FILE Make an image of the disk drive DEVICE on file FILE. The disk drive is assumed to have exactly one NTFS partition defined on it. Example: $0 /dev/sda /mnt0/image.gz image.gz will contain the first 63 blocks of /dev/sda, followed by an ntfsclone image of /dev/sda1, all compressed with gzip -9. Author: Stephen Thomas 24-Mar-2006" if [ -z "$1" ] then echo "$usage" exit 1 fi if [ "$1" == "--help" -o "$1" == "-h" ] then echo "$help" exit 1 fi disk="$1" partition="$disk"1 file="${2:-image.gz}" if [ -f "$file" ] then echo "About to overwrite $file with image of $disk." read -p "Is this OK? (y/n) " if [ "${REPLY:0:1}" != y -a "${REPLY:0:1}" != Y ] then exit 1 fi fi { dd if="$disk" bs=512 count=63 ntfsclone --save-image --output - "$partition" } | gzip -9 >"$file"