How can I create a 100% exact copy of a vm instance

307 views
Skip to first unread message

Nick A

unread,
Mar 23, 2018, 4:23:18 AM3/23/18
to gce-discussion
Hi everyone,

I want to create an exact copy of a vm instance.
Exact means: Everything relate to the vm instance (setup, ALL disks,...)

The reason I need this is because I have a Windows VM Instance (called client-01) with specific software pre-installed and has 3 disks.
I need to create 100% exact copies of these instances that then get a new name (client-02 / 3 / ...)
Then can start up and connect to a server machine.

But here are my options and none of them fit. :-(
1. Creating a VM Instance Template = no-go because it only creates an instance with a certain vm configuration (some boot disk image, memory, diskspace,...)
2. Creating a Snapshot = no-go because it only creates a copy of the contents of 1 disk without the vm configuration
3. Creating an Image = no-go because it only creates a full copy of a disk with OS/bootloader/... without the vm configuration
4. Creating a VM Instance = no-go because it's based on a clean boot disk image, with clean disks,...)
5. What does the 'Clone' button do on the VM Instance Details page? It seems to create a new VM Instance but without any of the above, just like you would click 'Create VM Instance' with new windows password no software installed anymore.

How can I do this; does a script exist to do this easily?
The next step would be to generate this clients; just by entering some command: I need 100 clients. (which are then generated and started up). Probably the instance groups fit for this.

I thought this would be very easy but it isn't and I'm not up to speed with scripting in gcloud either yet.

Thank you

Justin Reiners

unread,
Mar 23, 2018, 11:03:59 AM3/23/18
to Nick A, gce-discussion
Here's how I do it

1.) Take a snapshot of the primary disk
2.) Take a snapshot of secondary disks
3.) Create 3 vm's from snapshots you just created, from the 3 disks (or however many there are)
4.) Open secondary disk VM's in compute engine. Note the disk names it created.
5.) Edit secondary disk vm's and uncheck "Delete boot disk when the instance is deleted"
6.) Delete secondary disk VM's from compute engine,
7.) Open primary VM (with normal boot disk) and add secondary disks as additional disks to VM. 

I've had better luck if you log into the VM you want to snapshot, and comment out your non standard mount points. Also set a root password in case you have errors booting the new "Mega cloned" instance.


--
© 2018 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to the Google Groups "gce-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gce-discussion/c1fac1dc-d055-48ea-b7ea-9370f416e936%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
.com

Justin Reiners / System Administrator

800.308.9712/ jus...@hotlinesinc.com

Hotlines Inc Office: 800.807.2867 / Fax: 712-388-0258 
427 E. Kanesville Blvd. Suite 403, Council Bluffs, IA 51503
http://www.partshotlines.com

Sophia Yang

unread,
Mar 25, 2018, 11:54:53 PM3/25/18
to Justin Reiners, Nick A, gce-discussion
Hey Nick,

I have another suggestion for you with the newly updated Instance Template API.

1. Create custom image from each disk separately.

2. Create an instance template from that Windows VM, using this Beta API documented here, scroll down the the section "Creating an instance template based on an existing instance" where you use the "customImage" option for all disks.

3. Now you have your "golden" instance template. You can use that instance template to create as many instances you want and only provide instance name and zone, use this Beta API.

Please give it a try.

Thanks,
Sophia

To post to this group, send email to gce-dis...@googlegroups.com.



--
.com

Justin Reiners / System Administrator

--
© 2018 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-discussion@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to the Google Groups "gce-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gce-discussion+unsubscribe@googlegroups.com.
To post to this group, send email to gce-discussion@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
                                                                                            

Sophia Yang

Product Manager

Google Compute Engine

xiao...@google.com


Reply all
Reply to author
Forward
0 new messages