GCP compute engine: how to check instance type (custom Linux) from the instance terminal?

247 views Asked by At

I have custom Linux that I can boot up on AWS and GCP. In AWS I can check EC2 instance type easily from terminal:

aws-instance-xyz:/ # dmidecode -s system-product-name
m6i.4xlarge

I would like to be able to check instance type of compute engine in GCP however dmidecode command is of no use here:

gcp-instance-xyz:/ # dmidecode -s system-product-name
Google Compute Engine

I have to be able to check the instance type using a command in terminal. I can't install GCP cli on that linux environment so any gcloud/gutils commands are not an option.

1

There are 1 answers

3
Sai Chandra Gadde On

As per this official doc sudo dmidecode -s system-product-name is used to detect if the VM is running in Compute Engine.

To get the metadata details you need to use the curl command as mentioned in this official doc.Use the below command to get instance type:

curl "http://metadata.google.internal/computeMetadata/v1/instance/machine-type" -H "Metadata-Flavor: Google"

Output: enter image description here

It will be flexible if you use gcloud and adding here the installation document for your reference.