I'd like to use a GCE server and VNC to run some desktop programs I've written. However, I'd like to not have the GCE server running all the time (to save money) and I'd like to have the setup of my VNC desktop persisted (to save time). It seems like the easiest way to accomplish this is to somehow hibernate the GCE instance. Is there a way to do this either from a script or from the command line?
2 Answers
The only currently supported technique that I'm aware of would be to use a bootable persistent disk, which outlives the virtual machine so you could delete and restart the VM with moderately quick (under 30s) startup time but I don't think that would meet your needs because unless your app has built-in, robust checkpoint/resume logic, you might not be able to pick up where you left off on the desktop.
Another way to approach this would be to use a lightweight container, like Docker, which has suspend/resume and checkpointing built into its design. You can't currently run Docker containers on Google Compute Engine but we're interested in exploring the potential of Docker on GCE so stay tuned.
Sounds like what you'd really like is a native suspend capability with near instantaneous resume and no or very low charge for VMs in the suspended state. I think that's an interesting idea - I've submittted an internal feature request to the Compute Engine engineering team for future consideration.

- 3,742
- 2
- 19
- 19
-
1I was hoping for something like pm-hibernate (http://www.cyberciti.biz/faq/linux-command-to-suspend-hibernate-laptop-netbook-pc/) but I guess the GCE kernels don't support that. Thanks for adding the feature request though. – Thomas Johnson Nov 04 '13 at 03:37
Compute Engine has alpha support for suspending virtual machines. A quote from that documentation:
gcloud alpha compute instances suspend
is used to suspend a Google Compute Engine virtual machine. Suspending a VM is the equivalent of sleep or standby mode: the guest receives an ACPI S3 suspend signal, after which all VM state is saved to temporary storage. An instance can only be suspended while it is in the RUNNING state. A suspended instance will be put in SUSPENDED state.
The command is not yet available in the Compute Engine web UI but can be invoked from the command line like:
gcloud alpha compute instances suspend my-vm

- 3,131
- 1
- 30
- 23
-
9Does a VM in suspended state still accrue charges like it is in the running state ? – killjoy Mar 17 '17 at 11:14
-
Any updates? This feature appears to still be in alpha and signup is required. Anyone know where to signup or can shed light on @killjoy question about charges while suspended? – jrmerz Dec 07 '18 at 20:33
-
1@killjoy Here they describe charge-related aspects, but generally yes, you'll pay for a suspended VM but at a reduced charge-rate + PDs + IPs + storage to store state https://cloud.google.com/compute/docs/reference/rest/beta/instances/suspend – Hennadii Omelchenko Apr 03 '19 at 11:46