Resetting or Restarting an Instance

This document describes how to perform a reset on a virtual machine instance and how to restart a stopped instance. To learn more about stopping an instance, read Stopping an instance.

You can reset an instance to return a virtual machine instance to its initial state, or restart a previously terminated instance.

Before you begin

Resetting an instance

Performing a reset on your instance is similar to pressing the reset button on your computer, which wipes the memory contents of the machine and resets the virtual machine to its initial state. The instance remains in RUNNING state through the reset.

You can perform a reset on a running instance by using the Reset button in the Cloud Platform Console, the instances reset command in gcloud, or by making a POST request in the API.

Console

  1. Go to the VM Instances page in the Google Cloud Platform Console.

    Go to the VM instances page

  2. Check the boxes next to one or more instances that you want to reset.
  3. At the top right-hand of the page, click the Reset button to reset the instances.

gcloud

To reset your instance using gcloud compute:

gcloud compute instances reset example-instance

API

In the API, make a POST request to the following URI, replacing the project, zone, and instance name appropriately:

https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-f/instances/example-instance/reset

To reset your instance using the client libraries, construct a request to the instances().reset method:

def resetInstance(auth_http, gce_service):
  request = gce_service.instances().reset(project="myproject", zone="us-central1-a", instance="example-instance")
  response = request.execute(auth_http)

  print response

For more information on this method, see the instances().reset reference documentation.

After running the reset command, the subsequent zone operation will return as DONE once the instance has completely shut down.

Restarting a stopped instance

If you have stopped a virtual machine instance, you can restart the instance with its original configuration, using the instances().start method. This method boots up a powered-down virtual machine instance that is currently in TERMINATED state

The start method restarts an instance in a TERMINATED state, whereas methods such as reset() and sudo reboot only works on instances that are currently running. Almost all instances can be restarted, as long as the instance is in a TERMINATED state. However, preemptible instances cannot be restarted after they are terminated.

Console

  1. Go to the VM Instances page in the Google Cloud Platform Console.

    Go to the VM instances page

  2. Select the instances that you want to restart.
  3. At the top right-hand of the page, click the Start button to restart the instances.

gcloud

To reset your instance using gcloud compute:

gcloud compute instances start example-instance

API

In the API, make a POST request to the following URI, replacing the project, zone, and instance name appropriately:

https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-f/instances/example-instance/start

To restart your instance using the client libraries, construct a request to the instances().start method:

def restartInstance(auth_http, gce_service):
  request = gce_service.instances().start(project="myproject", zone="us-central1-a", instance="example-instance")
  response = request.execute(auth_http)

  print response

For more information on this method, see the instances().start reference documentation.

Using other restart methods

You can also choose to reset your instance using the following methods as well:

  • sudo reboot (Linux only) - Called from within the instance. Wipes the memory and re-initializes the instance with the original metadata, image, and persistent disks. It will not pick up any updated versions of the image, and the instance will retain the same ephemeral IP address. This is similar to restarting your computer.
  • Rebooting a Windows instance - You can reboot a Windows instance, similar to sudo reboot above, using the Start menu. In the Start menu, click on the arrow next to Log off and click Restart.
  • gcloud compute instances delete followed by gcloud compute instances create - This is a completely destructive restart, and will initialize the instance with any information passed into gcloud compute instances create. You can then select any new images or other resources you'd like to use. The restarted instance will probably have a different IP address. This method potentially swaps the physical machine hosting the instance.

What's next

Send feedback about...

Compute Engine Documentation