Reboot or reset a Compute Engine instance

Linux Windows

This document explains how to reboot or reset a Compute Engine instance. To learn more about the effects of resetting an instance, as well as the differences between suspending, stopping, or resetting an instance, see Suspend, stop, or reset Compute Engine instances.

Rebooting or resetting an instance can help ensure optimal performance and stability, or help resolve issues like a frozen, slow, or crashing guest operating system (OS). Based on the state of the guest OS of your instance, do one of the following:

  • Reboot the instance. If your guest OS is slow or frozen, then rebooting gives it enough time to finish running tasks before shutting down.

  • Reset the instance. Reset an instance only if the guest OS has crashed or is unresponsive, and you have no other options. Resetting an instance doesn't allow the guest OS to cleanly shut down. This action can discard unsaved data and might corrupt the file systems of any disks.

Before you begin

Required roles

To get the permissions that you need to reset or reboot a compute instance, ask your administrator to grant you the Compute Instance Admin (v1) (roles/compute.instanceAdmin.v1) IAM role on the instance. For more information about granting roles, see Manage access to projects, folders, and organizations.

This predefined role contains the permissions required to reset or reboot a compute instance. To see the exact permissions that are required, expand the Required permissions section:

Required permissions

The following permissions are required to reset or reboot a compute instance:

  • To reset an instance: compute.instances.reset
  • To reboot an instance from within its guest OS: compute.instances.setMetadata

You might also be able to get these permissions with custom roles or other predefined roles.

Rebooting a compute instance allows the guest OS in the instance to finish running tasks before Compute Engine sends the ACPI shutdown signal. This helps to ensure a clean shutdown of the guest OS.

Rebooting an instance erases the memory used by the instance. If you're using RAM disks with your instances, and you need to preserve that data, then back up the data before rebooting the instance.

To reboot an instance, select one of the following options:

Linux

  1. If you haven't already, then connect to the instance.

  2. To reboot the instance, run the following command:

    sudo reboot
    

Windows

  1. If you haven't already, then connect to the instance using one of the following methods:

  2. To reboot the instance, run the following command:

    shutdown /r /t 0
    
  3. Optional: To monitor the process of shutting down and restarting the instance, enable the Windows Boot Manager menu.

Reset an instance

Resetting an instance erases all data in the memory of the instance, including any temporary files stored on RAM disks. This data is permanently lost and Compute Engine doesn't create backups before resetting the instance.

You can reset multiple instances simultaneously or individual instances. For multiple instances, use the Google Cloud console or, for instances located in the same zone, the Google Cloud CLI. For individual instances, select any of the following options:

Console

  1. In the Google Cloud console, go to the VM instances page.

    Go to VM instances

  2. Select the instances to reset.

  3. Click Reset, and then click Reset to confirm.

gcloud

To reset one or more running instances in a single zone, use the gcloud compute instances reset command:

gcloud compute instances reset INSTANCE_NAMES \
    --zone=ZONE

Replace the following:

  • INSTANCE_NAMES: a whitespace-separated list of names of instances—for example, instance-01 instance-02 instance-03.

  • ZONE: the zone where the instances are located.

Go

Java

Node.js

PHP

Python

REST

To reset a running instance, make a POST request to the instances.reset method:

 POST https://compute.googleapis.com//compute/v1/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME/reset

Replace the following:

  • INSTANCE_NAME: the name of the instance.

  • PROJECT_ID: the ID of the project where the instance is located.

  • ZONE: the zone where the instance is located.

What's next