【问题标题】:Google Compute Engine: "attach-disk" command doesn't mount disk on the machineGoogle Compute Engine:“attach-disk”命令不会在机器上挂载磁盘
【发布时间】:2017-01-25 15:59:10
【问题描述】:

我想通过以下命令将磁盘附加到 Google Compute Engine 上的实例。

gcloud compute instances create pg-disk-formatter --image ubuntu-1604-lts --custom-cpu 1 --custom-memory 1
gcloud compute disks create pg-data-disk --size 50GB
gcloud compute instances attach-disk pg-disk-formatter --disk pg-data-disk

但是,即使我登录了机器并 cd 到 /dev/disk/by-id/,它也没有出现在列表中。

mkouhei0910@pg-data-disk:~$ cd /dev/disk/by-id/
google-persistent-disk-0                             scsi-0Google_PersistentDisk_persistent-disk-0
google-persistent-disk-0-part1                       scsi-0Google_PersistentDisk_persistent-disk-0-part1
google-pg-data-disk2                                 scsi-0Google_PersistentDisk_pg-data-disk2

我注意到它在我从 Google 平台控制台 附加新磁盘映像后显示,但我怎样才能纯粹通过 gloud 命令行实现它?

【问题讨论】:

    标签: google-compute-engine


    【解决方案1】:

    您的第一个命令不正确。应该是:

    gcloud compute instances create pg-disk-formatter --image-project ubuntu-os-cloud --image-family ubuntu-1604-lts --custom-cpu 1 --custom-memory 1
    

    第二个和第三个命令都不错。他们将创建一个磁盘并将其附加到 VM 实例。附加磁盘列在您提供的ls 命令的输出中:

    google-pg-data-disk2
    

    如果您希望客户机操作系统看到附加磁盘的不同名称,您可以使用 --device-name 标志和 the command

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-21
      • 2015-01-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多