Created
October 1, 2018 14:22
-
-
Save 4ndrej/bf31bbc0afb783a8d06063910e47fbe5 to your computer and use it in GitHub Desktop.
stitch xva's Ref/* files into raw image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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