Skip to content

Instantly share code, notes, and snippets.

@slmaxk
Forked from abn/convert-raw-to-vmdk.sh
Created April 30, 2021 19:06
Show Gist options
  • Select an option

  • Save slmaxk/d6f561c1dbefab0eefb3afb98d84380e to your computer and use it in GitHub Desktop.

Select an option

Save slmaxk/d6f561c1dbefab0eefb3afb98d84380e to your computer and use it in GitHub Desktop.
Convert all xz compressed raw images in current directory to vmdk and xz compress them.
find ./ -type f -name "*.raw.xz" \
-exec echo "Uncompressing {} ..." \; \
-exec unxz --keep {} \; \
-exec bash -c \
'for file do
INPUT_IMG=${file/.xz/}
OUTPUT_IMG=${file/raw.xz/vmdk}
echo "Converting to vmdk: ${INPUT_IMG}";
qemu-img convert -f raw -O vmdk ${INPUT_IMG} ${OUTPUT_IMG};
echo "Compressing ...";
xz --compress --verbose ${OUTPUT_IMG};
rm --force ${INPUT_IMG};
done' -- {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment