Decrease Compute Engine instances shutdown time

This document explains how to decrease the shutdown time for a Compute Engineinstance by configuring the instance to skip the guest OS shutdown on stop ordeletion.

If you configure an instance to skip the guest OS shutdown on stop or deletion,then Compute Engine immediately shuts down the guest OS when theinstance state changes toSTOPPING. This action helps you release quota orresources faster by speeding up an instance stop or deletion. To learn moreabout the phases that an instance goes through during stop or deletion,including the default interval for clean guest OS shutdown, seeStop operation.

Warning: An abrupt shutdown of the guest OS can cause permanent data loss orfile system corruption. Configure an instance to skip the guest OS shutdown onlyif you plan to delete the instance, or if you plan to stop an instance but youaren't concerned about the integrity of the data on the instance boot disk.

Before you begin

Required roles

To get the permissions that you need to configure an instance to skip the guest OS shutdown, ask your administrator to grant you theCompute Instance Admin (v1) (roles/compute.instanceAdmin.v1) IAM role on your project. For more information about granting roles, seeManage access to projects, folders, and organizations.

This predefined role contains the permissions required to configure an instance to skip the guest OS shutdown. To see the exact permissions that are required, expand theRequired permissions section:

Required permissions

The following permissions are required to configure an instance to skip the guest OS shutdown:

  • To create an instance:
    • compute.instances.create on the project
    • To use a custom image to create the VM:compute.images.useReadOnly on the image
    • To use a snapshot to create the VM:compute.snapshots.useReadOnly on the snapshot
    • To use an instance template to create the VM:compute.instanceTemplates.useReadOnly on the instance template
    • To assign alegacy network to the VM:compute.networks.use on the project
    • To specify a static IP address for the VM:compute.addresses.use on the project
    • To assign an external IP address to the VM when using a legacy network:compute.networks.useExternalIp on the project
    • To specify a subnet for the VM:compute.subnetworks.use on the project or on the chosen subnet
    • To assign an external IP address to the VM when using a VPC network:compute.subnetworks.useExternalIp on the project or on the chosen subnet
    • To set VM instance metadata for the VM:compute.instances.setMetadata on the project
    • To set tags for the VM:compute.instances.setTags on the VM
    • To set labels for the VM:compute.instances.setLabels on the VM
    • To set a service account for the VM to use:compute.instances.setServiceAccount on the VM
    • To create a new disk for the VM:compute.disks.create on the project
    • To attach an existing disk in read-only or read-write mode:compute.disks.use on the disk
    • To attach an existing disk in read-only mode:compute.disks.useReadOnly on the disk
  • To create an instance template:compute.instanceTemplates.create on the project
  • To update an instance:compute.instances.update on the instance

You might also be able to get these permissions withcustom roles or otherpredefined roles.

Configure instances to skip guest OS shutdown

To configure a compute instance to skip the guest OS shutdown when you stop ordelete the instance, use one of the following methods:

Configure guest OS shutdown in an existing instance

You can only configure a compute instance to skip the guest OS shutdown if theinstance is stopped (TERMINATED).

To configure an instance to skip the guest OS shutdown, select one of thefollowing options:

gcloud

  1. If you haven't already, thenstop the instance.

  2. To configure an instance to skip the guest OS shutdown, use thegcloud beta compute instances set-scheduling commandwith the--skip-guest-os-shutdown flag:

    gcloud compute instances set-schedulingINSTANCE_NAME \    --skip-guest-os-shutdown \    --zone=ZONE

    Replace the following:

    • INSTANCE_NAME: the name of the instance.

    • ZONE: the zone where the instance exists.

REST

  1. If you haven't already, thenstop the instance.

  2. To configure an instance to skip the guest OS shutdown, make aPOSTrequest to theinstances.setScheduling method.In the request body, include theskipGuestOsShutdown field and set ittotrue:

    POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME/setScheduling{  "skipGuestOsShutdown": true}

For more information on how to update an instance, seeUpdate instance properties.

Configure guest OS shutdown while you create an instance

To create a compute instance that is configured to skip the guest OS shutdown,select one of the following options:

gcloud

To create an instance that is configured to skip the guest OS shutdown, usethegcloud compute instances create commandwith the--skip-guest-os-shutdown flag:

gcloud compute instances createINSTANCE_NAME \    --machine-type=MACHINE_TYPE \    --skip-guest-os-shutdown \    --zone=ZONE

Replace the following:

  • INSTANCE_NAME: the name of the instance.

  • MACHINE_TYPE: the machine type to use for theinstance.

  • ZONE: the zone where you want to create the instance.

REST

To create an instance that is configured to skip the guest OS shutdown, makeaPOST request to theinstances.insert method.In the request body, include theskipGuestOsShutdown field set totrue:

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances{  "name": "INSTANCE_NAME",  "machineType": "zones/ZONE/machineTypes/MACHINE_TYPE",  "disks": [    {      "boot": true,      "initializeParams": {        "sourceImage": "projects/IMAGE_PROJECT/global/images/IMAGE"      }    }  ],  "networkInterfaces": [    {      "network": "global/networks/default"    }  ],  "scheduling": {    "skipGuestOsShutdown": true  }}

Replace the following:

  • PROJECT_ID: the ID of the project where you want tocreate the instance.

  • ZONE: the zone where you want to create the instance.

  • INSTANCE_NAME: the name of the instance.

  • MACHINE_TYPE: the machine type to use for theinstance.

  • IMAGE_PROJECT: the image project that contains theimage—for example,debian-cloud. For more information about thesupported image projects, seePublic images.

  • IMAGE: specify one of the following:

    • A specific version of the OS image—for example,debian-12-bookworm-v20240617.

    • Animage family, which you mustformat asfamily/IMAGE_FAMILY. This valuespecifies the most recent, non-deprecated OS image. For example, ifyou specifyfamily/debian-12, Compute Engine uses thelatest version in the Debian 12 image family. For more informationon how to use image families, seeImage families best practices.

For more information on how to create an instance, seeCreate and start a Compute Engine instance.

Configure guest OS shutdown while you create instances in bulk

To create compute instances in bulk that are configured to skip the guest OSshutdown, select one of the following options:

gcloud

To create instances in bulk that are configured to skip the guest OSshutdown, use thegcloud compute instances bulk create commandwith the--skip-guest-os-shutdown flag.

For example, to create instances in bulk that use a name pattern in a singlezone, run the following command:

gcloud compute instances bulk create \    --count=COUNT \    --machine-type=MACHINE_TYPE \    --name-pattern="NAME_PATTERN" \    --skip-guest-os-shutdown \    --zone=ZONE

Replace the following:

  • COUNT: the number of instances to create.

  • MACHINE_TYPE: the machine type to use for theinstances.

  • NAME_PATTERN: the name pattern for the instances. Toreplace a sequence of numbers in an instance name, use a sequence ofhash (#) characters. For example, if you useinstance-# as a namepattern, Compute Engine generates instances with names thatstart withinstance-1,instance-2, and it continues this incrementalpattern up to the number of instances that you specify inCOUNT.

  • ZONE: the zone where you want to create instances.

REST

To create instances in bulk that are configured to skip the guest OSshutdown, make aPOST request to theinstances.bulkInsert method.In the request body, include theskipGuestOsShutdown field set totrue.

For example, to create instances in bulk that use a name pattern in a singlezone, make aPOST request as follows:

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/bulkInsert{  "count":COUNT,  "namePattern": "NAME_PATTERN",  "instanceProperties": {    "machineType": "MACHINE_TYPE",    "disks": [      {        "boot": true,        "initializeParams": {          "sourceImage": "projects/IMAGE_PROJECT/global/images/IMAGE"        }      }    ],    "networkInterfaces": [      {        "network": "global/networks/default"      }    ],    "scheduling": {      "skipGuestOsShutdown": true    }  }}

Replace the following:

  • PROJECT_ID: the ID of the project where you want tocreate instances in bulk.

  • ZONE: the zone where you want to create instances.

  • COUNT: the number of instances to create.

  • NAME_PATTERN: the name pattern for the instances. Toreplace a sequence of numbers in an instance name, use a sequence ofhash (#) characters. For example, if you useinstance-# as a namepattern, Compute Engine generates instances with names thatstart withinstance-1,instance-2, and it continues this incrementalpattern up to the number of instances that you specify inCOUNT.

  • MACHINE_TYPE: the machine type to use for theinstances.

  • IMAGE_PROJECT: the image project that contains theimage—for example,debian-cloud. For more information about thesupported image projects, seePublic images.

  • IMAGE: specify one of the following:

    • A specific version of the OS image—for example,debian-12-bookworm-v20240617.

    • Animage family, which you mustformat asfamily/IMAGE_FAMILY. This valuespecifies the most recent, non-deprecated OS image. For example, ifyou specifyfamily/debian-12, Compute Engine uses thelatest version in the Debian 12 image family. For more informationon how to use image families, seeImage families best practices.

For more information on how to create instances in bulk, seeCreate instances in bulk.

Configure guest OS shutdown while you create an instance template

After you create an instance template configured to skip the guest OS shutdownwhen you stop or delete compute instances, you can use the instance template todo the following:

To create an instance template that is configured to skip the guest OS shutdown,select one of the following options:

gcloud

To create an instance template that is configured to skip the guest OSshutdown, use thegcloud compute instance-templates create commandwith the--skip-guest-os-shutdown flag.

For example, to create a regional instance template that specifies to skipthe guest OS shutdown, run the following command. If you want to create aglobal instance template, then use the same command without the--instance-template-region flag.

gcloud compute instance-templates createINSTANCE_TEMPLATE_NAME \    --instance-template-region=REGION \    --machine-type=MACHINE_TYPE \    --skip-guest-os-shutdown

Replace the following:

  • INSTANCE_TEMPLATE_NAME: the name of the instancetemplate.

  • REGION: the region where you want to create theinstance template.

  • MACHINE_TYPE: the machine type to specify in theinstance template.

REST

To create an instance template that is configured to skip the guest OSshutdown, make aPOST request to one of the following methods:

In the request body, include theskipGuestOsShutdown field set totrue.

For example, to create a regional instance template that specifies to skipthe guest OS shutdown, make aPOST request as follows:

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/regions/REGION/instanceTemplates{  "name": "INSTANCE_TEMPLATE_NAME",  "properties": {    "disks": [      {        "boot": true,        "initializeParams": {          "sourceImage": "projects/IMAGE_PROJECT/global/images/IMAGE"        }      }    ],    "machineType": "MACHINE_TYPE",    "networkInterfaces": [      {        "network": "global/networks/default"      }    ],    "scheduling": {      "skipGuestOsShutdown": true    }  }}

Replace the following:

  • PROJECT_ID: the ID of the project where you want tocreate the instance template.

  • REGION: the region where you want to create theinstance template.

  • INSTANCE_TEMPLATE_NAME: the name of the instancetemplate.

  • IMAGE_PROJECT: the image project that contains theimage—for example,debian-cloud. For more information about thesupported image projects, seePublic images.

  • IMAGE: specify one of the following:

    • A specific version of the OS image—for example,debian-12-bookworm-v20240617.

    • Animage family, which must beformatted asfamily/IMAGE_FAMILY. This specifiesthe most recent, non-deprecated OS image. For example, if youspecifyfamily/debian-12, the latest version in the Debian 12image family is used. For more information about using imagefamilies, seeImage families best practices.

  • MACHINE_TYPE: the machine type to specify in theinstance template.

For more information about creating an instance template, seeCreate instance templates.

View guest OS shutdown setting

You can check whether Compute Engine skips the guest OS shutdown whenyou stop or delete a compute instance.

To view the guest OS shutdown time in an instance, select one of the followingoptions:

gcloud

To view the details of an instance and whether it skips the guest OSshutdown, use thegcloud compute instances describe command:

gcloud compute instances describeINSTANCE_NAME \    --zone=ZONE

Replace the following:

  • INSTANCE_NAME: the name of the instance.

  • ZONE: the zone where the instance exists.

If you configured the instance to skip the guest OS shutdown, then theoutput contains theskipGuestOsShutdown field set totrue, such as inthe following example:

...scheduling:  automaticRestart: trueskipGuestOsShutdown: true  onHostMaintenance: MIGRATE  preemptible: false  provisioningModel: STANDARD...

Otherwise, if theskipGuestOsShutdown field is missing or is set tofalse, the guest OS uses thedefault shutdown time.

REST

To view the details of an instance and whether it skips the guest OSshutdown, make aGET request to theinstances.get method:

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

Replace the following:

  • PROJECT_ID: the ID of the project where the instanceexists.

  • ZONE: the zone where the instance exists.

  • INSTANCE_NAME: the name of the instance.

If you configured the instance to skip the guest OS shutdown, then theoutput contains theskipGuestOsShutdown field set totrue, such as inthe following example:

{  ...  "scheduling": {    "automaticRestart": true,"skipGuestOsShutdown": true,    "onHostMaintenance": "MIGRATE",    "preemptible": false,    "provisioningModel": "STANDARD"  },  ...}

Otherwise, if theskipGuestOsShutdown field is missing or is set tofalse, the guest OS uses thedefault shutdown time.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.