【发布时间】:2020-10-09 20:10:21
【问题描述】:
我正在尝试从现有的已关闭虚拟机创建实例模板。 VM 是一个非常基本的 Centos Linux 机器。经过一番谷歌搜索后,我想出了以下问题,但我不知道如何格式化磁盘设备名称。我找不到很多例子。提前感谢您对这个主题的任何启发。
$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'.
根据以下建议,我运行了描述。看起来设备名称也是'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
所以现在我正在运行以下命令。它创建了一个模板耶!但是,新模板上没有安装我在原始 VM 上安装的任何软件。
$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
【问题讨论】:
-
设备名称更像是人类使用的符号链接。据我所知,/dev 中的条目是自动的。有关示例,请参阅this article。
-
你能分享源实例的细节吗?例如使用此命令
gcloud compute instances describe ajm-centos8 -
根据您的推荐使用描述数据编辑帖子。谢谢。
标签: google-cloud-platform google-compute-engine gcloud