In the previous post we have learned how you can change your machine type of running VM instance on Google Compute Engine. This post will guide you how you can move your running instance from one project to some other project.

Steps :-

1) We need to make image of instance and copy it on Google Bucket. For this SSH into instance that you want to move.
 Developer Console -> Compute Engine -> VM Instance -> SSH (any-instance)

2) Make temporary directory to copy the image of running instance 

sudo mkdir /mnt/tmp
3) Now list the drives
ls -l /dev/disk/by-id/google-*

4) Check disk that you want to export to bucket (as we are moving instance and it is mostly installed on sda)

5) As we are going to create image on temporary folder so there must have enough space for new image file. For this we can mount non persistent disk if not enough space on prime drive (sda). In case you don’t have external disk you can create new one from Developer Console and attach it to running instance.

 6)  The following command will format and mount the external non persistent disk (sdb) 

sudo /usr/share/google/safe_format_and_mount -m "mkfs.ext4 -F" /dev/sdb /mnt/tmp 
7) Now using imagebunde package create image of vm instance
sudo gcimagebundle -d /dev/sda -o /mnt/tmp/ --log_file=/tmp/abc.log 
8) Now check the new tar file in location
   ls -l /mnt/tmp
9) To export this on Google Bucket we need to provide owner permission to service account. For this check the service account by this command
curl "http://metadata/computeMetadata/v1/instance/service-   accounts/" -H "Metadata-Flavor:Google"
10) Now provide this service account the owner permission on Google Bucket from Developer Console


11) Change the permission of your newly created image (tar file)



chmod u=rwx,g=rwx,o=rwx      mnt/tmp/d0e9184d539ae7c0274590942ef05af13450.image.tar.gz

12 ) Copy this tar file to Google Bucket using

gsutil cp /mnt/tmp/d0e9184d539ae7c0274590942ef05af13450.image.tar.gz gs://bucket_name

13 ) Check this file on Google Bucket and share it publicly.

 14) Now under new project create a new image from Developer Console

Developer Console -> Compute Engine -> Images -> New Image -> Select image source from google bucket 

and type


15) Make an instance from Developer Console using this image created above.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Google Compute Engine

Delete project from Google Developer Console

Delete Compute Engine Instances Login with gmail id where instances are located. Select Project Search for compute engine Select Instance name and click stop and then delete. Deleting DB instances Search for SQL Select Read more…

Google Compute Engine

Access Google Instances SSH, WinSCP and RDP

Use One of the following methods :- SSH from Developer Console Using WinSCP RDP Windows Server SSH from Developer Console 1) Open 2) Gmail Account Login 3)  Select Compute Engine Project 4) Click On Read more…

Google Compute Engine

Google Compute Engine : Change Machine Type of Running VM

Google Cloud Platform is a suite of public cloud computing services offered by Google. The platform includes a range of hosted services for compute, storage and application development that run on Google hardware. Google Compute Engine is one Read more…