Which method is best to create Google Cloud VM from existing VM? - google-cloud-platform

Cloning VM from console?
I tried this solution but changes inside VM before cloning are not available in new VM
Create snapshot from bootdisk and then use snapshot to create VM.
Use existing boot disk when creating VM from select boot disk popup.
Create new Image form snapshot and use that Image to create the VM.

Since you asked the best, it will be #4 (Create new Image form snapshot and use that Image to create the VM.). This will give you an option to refer to the image by family name while doing the automation. Also it will help you version the image and deprecate the older image etc.

Related

How can I migrate a google VM instance from one account to another

Me and my colleague have a two independent google accounts. If possible, I want to migrate one of my VM instance into his account, where he can start using it with the disk that contains the applications and operating system needed to start the VM that I want to migrate.
On my account, I have created a custom image and afterwards I give an Owner permission to my college's account using IAM & Admin.
Then my college(from different google account) created an Instance by using the custom image under My First Project section. But when he connected into created instance, its home directory was empty even its created from the custom image that I created from my disk.
Boot Disk => Custom Images => Select my shared Project => Selected the Custom Image that is created on my shared Project => Create
I observe that even I was able to create a image from different project, its contents was not migrated.
I was wondering is it possible to migrate a google VM instance from one account to another? If yes, how can I do it?
Related:
Is it possible to migrate a google VM instance from one account to another keeping its external IP?
I would suggest creating a snapshot of your VM's boot disk. Then create an image from that snapshot and share it with your colleague.
As John Hanley pointed out in the comments to your question, you might be looking in the wrong place! Google will create separate user home directories based on the username.

Create Custom Image from GCP VM with OS and data disks

I set up centos and windows VMs in Google Cloud which has many custom installations and configuration, with 1 boot disk and 4 data disks.
I am trying to create an image of both VMs. Only options I see in google cloud to create an image from disk, snapshot, another image, cloud file or virtual disk.
Looking for some way to create an image at VM level, which I can reuse to create new VMs something similar to custom ami in AWS or custom image in Azure.
The intention is if I create VM out of that image, my new VM will come up with all 5 disks. On GCP console, when I try to create an image, it has no option of using whole VM as a source instead, I can choose single disk as source.
Is there any way or workaround to achieve this in Google Cloud?
Thanks in advance.
I found GCP Instance Templates as a solution to my problem. I can reuse Instance Templates to deploy my custom VMs.

GCP - moving VMs across projects with the Google Cloud SDK

I want to move some VMs across projects on GCP using the Cloud SDK.
I'd like the process on a high level, and then possibly also some links out to the relevant docs, although I can RTFM when I know what the general high-level steps are.
I think what I want to do is
Create a snapshot
Save it somewhere
Create two Cloud SDK contexts?
Prepare a destination in the context for the new project
Copy the snapshots over to the new context and its associated storage
Rehydrate from the copied snapshot in the new project once everything is copied.
Please help. I'm new with this stuff and want to know whether this is really how it should be done.
Thanks!
You can use this guide
Quick summary of steps needed
Detach the boot disk from the VM that you intend to move by deselecting “Delete boot disk on instance delete” and terminating the VM
Create an image from the detached boot disk
Upload the image to Google Cloud Storage and share it with the new project
Create a custom image under the new project based on the image you uploaded to Google Cloud Storage
Create a new VM instance under the new project based on the custom image

Create Google Cloud instance with custom ISO

I want to create a new Google Cloud Compute Engine instance with Ubuntu 18.04 LTS. I tried doing it with the inbuilt image and tried to set up an Ubuntu desktop with VNC. I did end up getting everything to work but felt it was too much of a hassle to install a desktop environment and set up a VNC service.
So I was wondering how I could upload a desktop Ubuntu ISO to Google Cloud and using that as the starting image for a Google Cloud Compute Engine instance.
In order to create custom images there are two possible way:
You can create custom images of boot disks and use these images to create new instances. This is ideal for situations where you have created and modified a persistent boot disk to a certain state and need to save that state to create new instances.
Alternatively, you can import boot disk images to Compute Engine from your existing systems and add them to your custom images list.
There is a whole section of the Google Documentation "How-to" regarding the creation of Custom images that I advise you to follow.
In particular I believe you are interested how to import a Boot Disk to Compute engine.
Shortly the steps are the following:
Plan your import path. You must identify where you are going to prepare your boot disk image before you upload it, and how you are going to connect to that image after it boots in the Compute Engine environment.
Prepare your boot disk so it can boot within the Compute Engine environment and so you can access it after it boots.
Create and compress the boot disk image file.
Upload the image file to Google Cloud Storage and import the image to Compute Engine as a new custom image.
Use the imported image to create a virtual machine instance and make sure it boots properly.
If the image does not successfully boot, you can troubleshoot the issue by attaching the boot disk image to another instance and reconfiguring it.
Optimise the image and install the Linux Guest Environment so that your imported operating system image can communicate with the metadata server and use additional Compute Engine features.

How do I save a customized AWS EC2 image (AMI)?

So, I am using an ubuntu AMI (amazon machine image). I have installed a couple of compiler, softwares, packages etc on this image. Now I want to save this image; so that I can use it to spawn multiple identical instances of this same AMI. How can I save my create and image of my current AMI instance in order to replicate it to create multiple identical instances?
Create a new AMI Image
Go to the AWS console
go to your EC2 dashboard : in the instances list
select your instance, right click on your instance
select image / create image
This will create an AMI image that you can reuse later