Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
virtual machine image to tarball.
#!/bin/bash
if [ $# -ne 3 ]
then
echo "vmimg-to-tar.sh vm-image-path path-to-write tar-out-file"
exit 1
fi
IMG=$1
PATH_TO_WRITE=$2
TAR=$3
IMG_FILE=$(basename "$IMG")
TAR_FILE=$(basename "$TAR")
IMG_DIR=$(cd "$(dirname "$IMG")" || exit; pwd)
TAR_DIR=$(cd "$(dirname "$TAR")" || exit; pwd)
docker run -it --rm \
-v "$IMG_DIR":/root/in \
-v "$TAR_DIR":/root/out \
--entrypoint /usr/bin/virt-tar-out \
curator/guestfish \
-a "/root/in/$IMG_FILE" ${PATH_TO_WRITE} "/root/out/$TAR_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.