About startup scripts

Linux Windows

A startup script is a file that contains commands that run when a virtualmachine (VM) instance boots. Compute Engine provides support for runningstartup scripts on Linux VMs and Windows VMs.

Prerequisites

To run scripts stored in metadata on a VM instance, theguest environment must be installed and running.

  • The guest environment includes theguest agent (for example, google-guest-agent on Linux)that reads the script content or URL from the instance's metadata and initiates execution.
  • All public Compute Engine images come with the guest environmentpreinstalled.
  • If you create a custom image, you mustmanually install the Google Guest Environment to ensurescripts from metadata and other Google Cloud features function properly.

The following table contains links to documentation that describes how to usestartup scripts.

Startup script taskBest used forLink to procedure
Pass a startup script directlyScripts up to 256 KB
Linux VMsWindows VMs
Pass a startup script from a local fileScripts up to 256 KB
Linux VMsWindows VMs
Pass a startup script from Cloud StorageScripts greater than 256 KB
Linux VMsWindows VMs
Access metadata from a startup scriptPassing different values to each VM that uses the same script
Linux VMsWindows VMs
Rerun a startup scriptRunning a script without restarting the VM
Linux VMsWindows VMs
View the output from a startup scriptMonitoring the progress of a script
Linux VMsWindows VMs

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.