Last active
August 29, 2015 13:57
-
-
Save proppy/9795314 to your computer and use it in GitHub Desktop.
bootstrap a GCE persistent disk w/ raw data
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 | |
set -ex | |
USAGE='usage: dd if=<source> | DISK= BUCKET= [ZONE= SIZE=] pdstrap.sh' | |
DISK=${DISK:?missing ${USAGE}} | |
BUCKET=${BUCKET:?missing ${USAGE}} | |
ZONE=${ZONE:-us-central1-a} | |
SIZE=${SIZE:-200} | |
TMPDIR=$(mktemp -d) | |
dd of=${TMPDIR}/disk.raw | |
tar -Szcf ${TMPDIR}/${DISK}.tar.gz -C ${TMPDIR} disk.raw | |
gsutil cp ${TMPDIR}/${DISK}.tar.gz gs://${BUCKET}/ | |
gcutil addimage ${DISK} gs://${BUCKET}/${DISK}.tar.gz | |
gcutil adddisk ${DISK} --size=${SIZE} --source_image=${DISK} --zone=${ZONE} | |
echo disk ${DISK} created | |
echo "create similar disk with: \`gcutil adddisk <disk name> --size=<disk size> --source_image=${DISK}\`" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment