Gappa
Gappa

Reputation: 827

how to manage google compute engine group of instances disk image?

We are trying to create a horizontaly Scalable web service via Google Compute Engine.

In order to do so, we have created an Instance Template and a Group of Instances based on this new template. The group of instances create a new virtual machine (we chose Debian) in which we can install our NodeJs application and other stuff.

We unlucky found out that when the VM is turned off everything inside the VM is erased. We would like to create a Snapshot or a Disk Image in order to avoid completely rebuild an instance from sketch, but we encountered two problems:

  1. You can't create a Disk Image while the VM is running but if we turn it off we would lose all data in it.
  2. It is possible to create a Snapshot of a VM while it is running but when you create a new instance from the Snapshot we can't link/join the new instance to the Group of Instances.

How can we get to the solution with those tools? Thanks

Upvotes: 0

Views: 56

Answers (1)

John Hanley
John Hanley

Reputation: 81346

Although it is recommended to shutdown your VM instance before creating an image, it is possible to create an image of a running system.

  1. Connect to your instance (SSH, RDP, etc.)
  2. Shutdown the applications that you can such as databases, etc. This purpose is to minimize disk activity and changes to the file system.
  3. Sync the file system to disk. Linux sudo sync. Windows: Sysinternals wrote Sync which will help. Sysinternals's Sync
  4. Go to the Google Console -> Compute Engine ->Disks.
  5. Select your the disk drive for the VM instance.
  6. At the top of the screen will be a button CREATE IMAGE.
  7. Click the button and complete the dialog.
  8. Make sure that you click the button Keep instance running (not recommended).
  9. Once the image completes, I would launch a new instance and verify that you have everything and that everything is working as expected.

Note: You can also create a disk snapshot.

Disk Image

Upvotes: 0

Related Questions