简体   繁体   English

如何在谷歌计算引擎中访问启动盘作为数据盘

[英]How to access boot disk as data disk in google compute engine

I have to been trying to follow steps mentioned in this https://cloud.google.com/marketplace/docs/partners/vm/build-vm-image#create_a_licensed_vm_image guide to offer VM solution on google cloud marketplace.我必须尝试按照此https://cloud.google.com/marketplace/docs/partners/vm/build-vm-image#create_a_licensed_vm_image指南中提到的步骤在谷歌云市场上提供 VM 解决方案。

With reference to step number 5 in the above link:-参考上述链接中的第 5 步:-

The data disk shows up on my system with its boot and a data partition, but it is not mounted anywhere.数据磁盘显示在我的系统上,带有它的引导和数据分区,但它没有安装在任何地方。 I am able to access my installed application files on my current boot disk, which is weird since I did not install my application on this boot disk.我可以访问当前启动磁盘上已安装的应用程序文件,这很奇怪,因为我没有在此启动磁盘上安装我的应用程序。

Here is my gcloud command for first instance.这是我的第一个实例的 gcloud 命令。

gcloud compute instances create vm \
--image-family centos-7 \
--image-project centos-cloud \
--no-restart-on-failure \
--maintenance-policy=TERMINATE --preemptible

Here is my gcloud command for second instance.这是我用于第二个实例的 gcloud 命令。

gcloud compute instances create vm2 \
--image-family centos-7 \
--image-project centos-cloud \
--no-restart-on-failure \
--maintenance-policy=TERMINATE --preemptible \
--disk=name=vm,mode=rw,boot=no

Could someone please explain me step number 5 regarding boot disk cleanup in the link I mentioned above.有人可以在我上面提到的链接中向我解释有关引导磁盘清理的第 5 步。

I figured it out.我想到了。 It seems that even though I am attaching the previous boot disk as data disk, the 2nd instance boots up with the previous boot disk (this behavior is random).似乎即使我将以前的引导磁盘附加为数据磁盘,第二个实例也会使用以前的引导磁盘启动(这种行为是随机的)。 lsblk outputs two identical boot disks. lsblk 输出两个相同的引导盘。 Now if i find my application running, then it means that I booted from the first boot disk otherwise the second.现在,如果我发现我的应用程序正在运行,那么这意味着我从第一个引导磁盘启动,否则是第二个。 The only workaround I found for this issue is to spawn the 2nd instance first, wait for it to completely boot and then attach the previous boot disk as data disk.我为这个问题找到的唯一解决方法是首先生成第二个实例,等待它完全启动,然后将之前的启动磁盘附加为数据磁盘。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM