Skip to content

Instantly share code, notes, and snippets.

@4ndrej 4ndrej/xva2raw.sh
Created Oct 1, 2018

Embed
What would you like to do?
stitch xva's Ref/* files into raw image
#!/bin/bash
# stolen from now defunct http://wiki.sysconfig.org.uk/display/howto/Convert+Citrix+XenServer+images+to+plain+Xen
#
# To summarize the .xva format:
# - it's a tar file
# - it contains a folder
# - the folder contains chunks of 1MB each
# - they can be concatenated, but blank space needs to be filled
dd if=/dev/zero of=blank bs=1024 count=1k
test -f image.img && rm -f image.img
touch image.img
max=`ls ???????? | sort | tail -n1`
for i in `seq 0 $max`; do
fn=`printf "%08d" $i`
echo -n "$fn of $max"
if [ -f "$fn" ]; then
echo " - appending chunk"
cat $fn >> image.img
else
echo " - filling blank"
cat blank >> image.img
fi
done
rm -f blank
echo "Done."
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.