0
0
GCPcloud~5 mins

Boot disk images in GCP - Commands & Configuration

Choose your learning style9 modes available
Introduction
Boot disk images are pre-made snapshots of operating systems that help start virtual machines quickly. They solve the problem of setting up a new server by providing a ready-to-use system image.
When you want to create a new virtual machine with a specific operating system quickly.
When you need to ensure all your virtual machines start with the same software setup.
When you want to test software on different operating systems without installing them manually.
When you want to restore a virtual machine to a known good state using a saved image.
When you want to customize a base image and reuse it for multiple virtual machines.
Commands
This command lists all available boot disk images in the Debian Cloud project. It helps you find the exact image name to use when creating a VM.
Terminal
gcloud compute images list --project=debian-cloud
Expected OutputExpected
NAME FAMILY DEPRECATED STATUS debian-11-bullseye-v20240612 debian-11 READY debian-10-buster-v20240612 debian-10 READY ...
--project - Specifies the project that holds the images to list.
This command creates a new virtual machine named example-vm in the us-central1-a zone using the Debian 11 boot disk image. It shows how to launch a VM with a specific boot image.
Terminal
gcloud compute instances create example-vm --zone=us-central1-a --image=debian-11-bullseye-v20240612 --image-project=debian-cloud
Expected OutputExpected
Created [https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/instances/example-vm]. NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS example-vm us-central1-a e2-medium 10.128.0.2 34.68.123.45 RUNNING
--zone - Specifies the zone where the VM will be created.
--image - Specifies the boot disk image to use for the VM.
--image-project - Specifies the project that contains the boot disk image.
This command shows detailed information about the example-vm instance, including the boot disk image used. It helps verify the VM's configuration.
Terminal
gcloud compute instances describe example-vm --zone=us-central1-a
Expected OutputExpected
name: example-vm zone: projects/my-project/zones/us-central1-a disks: - boot: true initializeParams: sourceImage: projects/debian-cloud/global/images/debian-11-bullseye-v20240612 deviceName: example-vm type: PERSISTENT status: RUNNING
--zone - Specifies the zone of the VM to describe.
Key Concept

If you remember nothing else from this pattern, remember: boot disk images are ready-made operating system snapshots that let you start virtual machines quickly and consistently.

Common Mistakes
Using an incorrect or misspelled image name when creating a VM.
The VM creation fails because the specified image does not exist.
Always list available images with 'gcloud compute images list' and copy the exact image name.
Not specifying the correct image project with --image-project flag.
The command cannot find the image because it looks in the wrong project.
Use the --image-project flag to specify the project that owns the image, like 'debian-cloud'.
Summary
List available boot disk images to find the right operating system snapshot.
Create a virtual machine using a specific boot disk image and zone.
Verify the VM's boot disk image by describing the instance details.