I am attempting to create an instance template from an existing powered off VM. The VM is a pretty basic Centos Linux box. After a bit of googling the problem I came up with the following but I can't figure out how to format the disk device name. There are not a lot of examples out there I can find. Thanks in advance for any light you can shed on the subject.
$gcloud compute instance-templates create plainid-pocv12-cent8-autostart --source-instance ajm-centos8 --configure-disk=device-name=/dev/sda,instantiate-from=source-image,auto-delete=true
ERROR: (gcloud.compute.instance-templates.create) Could not fetch resource:
- Invalid value for field 'resource.sourceInstanceParams.diskConfigs[0].deviceName': '/dev/sda'. Device name specified in disk instantiation config not found in source instance: '/dev/sda'.
Per the suggestions below, I ran the describe. Looks like the device name is also 'ajm-centos8'
$gcloud compute instances describe ajm-centos8
canIpForward: false
confidentialInstanceConfig:
enableConfidentialCompute: false
cpuPlatform: Intel Haswell
creationTimestamp: '2020-10-05T06:04:50.611-07:00'
deletionProtection: false
description: ''
disks:
- autoDelete: true
boot: true
deviceName: ajm-centos8
diskSizeGb: '30'
guestOsFeatures:
- type: UEFI_COMPATIBLE
- type: VIRTIO_SCSI_MULTIQUEUE
- type: SEV_CAPABLE
index: 0
interface: SCSI
kind: compute#attachedDisk
licenses:
- https://www.googleapis.com/compute/v1/projects/centos-cloud/global/licenses/centos-8
mode: READ_WRITE
source: https://www.googleapis.com/compute/v1/projects/plainid-presales/zones/us-east1-b/disks/ajm-centos8
type: PERSISTENT
So now I am running the following command. It creates a template yay! However, the new template does not have any of the software I installed on the original VM installed on it.
$gcloud compute instance-templates create plainid-pocv12-cent8-autostart --source-instance ajm-centos8 --configure-disk=device-name=ajm-centos8,instantiate-from=source-image,auto-delete=true
Created [https://www.googleapis.com/compute/v1/projects/plainid-presales/global/instanceTemplates/plainid-pocv12-cent8-autostart].
NAME MACHINE_TYPE PREEMPTIBLE CREATION_TIMESTAMP
plainid-pocv12-cent8-autostart custom (e2, 2 vCPU, 6.00 GiB) 2020-10-09T13:55:02.563-07:00