Decrease Compute Engine instances shutdown time Stay organized with collections Save and categorize content based on your preferences.
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.
Before you begin
- If you haven't already, set upauthentication. Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:
Select the tab for how you plan to use the samples on this page:
gcloud
Install the Google Cloud CLI. After installation,initialize the Google Cloud CLI by running the following command:
gcloudinit
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.- Set a default region and zone.
REST
To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
Install the Google Cloud CLI. After installation,initialize the Google Cloud CLI by running the following command:
gcloudinit
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.For more information, seeAuthenticate for using REST in the Google Cloud authentication documentation.
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.createon the project- To use a custom image to create the VM:
compute.images.useReadOnlyon the image - To use a snapshot to create the VM:
compute.snapshots.useReadOnlyon the snapshot - To use an instance template to create the VM:
compute.instanceTemplates.useReadOnlyon the instance template - To assign alegacy network to the VM:
compute.networks.useon the project - To specify a static IP address for the VM:
compute.addresses.useon the project - To assign an external IP address to the VM when using a legacy network:
compute.networks.useExternalIpon the project - To specify a subnet for the VM:
compute.subnetworks.useon the project or on the chosen subnet - To assign an external IP address to the VM when using a VPC network:
compute.subnetworks.useExternalIpon the project or on the chosen subnet - To set VM instance metadata for the VM:
compute.instances.setMetadataon the project - To set tags for the VM:
compute.instances.setTagson the VM - To set labels for the VM:
compute.instances.setLabelson the VM - To set a service account for the VM to use:
compute.instances.setServiceAccounton the VM - To create a new disk for the VM:
compute.disks.createon the project - To attach an existing disk in read-only or read-write mode:
compute.disks.useon the disk - To attach an existing disk in read-only mode:
compute.disks.useReadOnlyon the disk
- To create an instance template:
compute.instanceTemplates.createon the project - To update an instance:
compute.instances.updateon 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 while you create instances in bulk
Configure guest OS shutdown while you create an instance template
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
If you haven't already, thenstop the instance.
To configure an instance to skip the guest OS shutdown, use the
gcloud beta compute instances set-schedulingcommandwith the--skip-guest-os-shutdownflag:gcloud compute instances set-schedulingINSTANCE_NAME \ --skip-guest-os-shutdown \ --zone=ZONEReplace the following:
INSTANCE_NAME: the name of the instance.ZONE: the zone where the instance exists.
REST
If you haven't already, thenstop the instance.
To configure an instance to skip the guest OS shutdown, make a
POSTrequest to theinstances.setSchedulingmethod.In the request body, include theskipGuestOsShutdownfield 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=ZONEReplace 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 as
family/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=ZONEReplace 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 as
family/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:
You can configure the instances in a managed instance group (MIG) to skipthe guest OS shutdown on stop or deletion when you do 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-shutdownReplace 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:
To create a global instance template:
instanceTemplates.insertmethodTo create a regional instance template:
regionInstanceTemplates.insertmethod
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 as
family/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=ZONEReplace 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_NAMEReplace 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.