Skip to content

Commit

Permalink
fix(dev): Fixed image extraction to tar.gz (#1569)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Wiseblatt committed Apr 14, 2017
1 parent 28a8d22 commit ea2caeb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
5 changes: 4 additions & 1 deletion dev/build_google_image.sh
Expand Up @@ -328,6 +328,9 @@ function create_prototype_disk() {
echo "`date` Creating disk '$BUILD_INSTANCE' from image '$SOURCE_IMAGE'"
gcloud compute instances create ${BUILD_INSTANCE} \
--no-boot-disk-auto-delete \
--boot-disk-type pd-ssd \
--boot-disk-size 10GB \
--machine-type n1-standard-4 \
--project $PROJECT \
--account $ACCOUNT \
--zone $ZONE \
Expand Down Expand Up @@ -360,7 +363,7 @@ function create_prototype_disk() {
--project $PROJECT \
--account $ACCOUNT \
--zone $ZONE \
--machine-type n1-standard-1 \
--machine-type n1-standard-2 \
--boot-disk-type pd-ssd \
--boot-disk-size 10GB \
--image $BASE_IMAGE \
Expand Down
4 changes: 3 additions & 1 deletion dev/clean_google_image.sh
Expand Up @@ -27,7 +27,9 @@ disk_id=$1

# Mount the dirty disk
mkdir -p /mnt/disks/${disk_id}
mount -o discard,defaults /dev/disk/by-id/google-${disk_id}-part1 /mnt/disks/${disk_id}
mount -t ext4 -o discard,defaults \
/dev/disk/by-id/google-${disk_id}-part1 \
/mnt/disks/${disk_id}
cd /mnt/disks/${disk_id}
echo "FYI, disk Usage is `df -kh .`"

Expand Down
11 changes: 7 additions & 4 deletions dev/extract_disk_to_gcs.sh
Expand Up @@ -29,15 +29,18 @@ if [[ "$gcs_path" != gs://*.tar.gz ]]; then
exit -1
fi

# This might need to literally be "disk.raw" inside tar file.
# https://cloud.google.com/compute/docs/images/import-existing-image#plan_import
echo "`date` Dumping disk $disk_id"
sudo dd if=/dev/disk/by-id/google-${disk_id}-part1 of=./disk.raw bs=4096
sudo dd if=/dev/disk/by-id/google-${disk_id} \
of=./disk.raw \
bs=4M \
conv=sparse

echo "`date` Creating tar file"
sudo tar czf disk.raw.tz disk.raw
sudo tar -Sczf disk.raw.tar.gz disk.raw

echo "`date` Writing $gcs_path"
gsutil -q cp disk.raw.tz ${gcs_path}
gsutil -q cp disk.raw.tar.gz ${gcs_path}

echo "`date` Finished"

Expand Down

0 comments on commit ea2caeb

Please sign in to comment.