How to change machine type of GCE instance?

后端 未结 3 1747
遇见更好的自我
遇见更好的自我 2020-12-03 18:25

As there isn\'t any direct option to change machine type and i have to create a new instance. What are the steps to do so that the configuration/software that I had installe

3条回答
  •  情书的邮戳
    2020-12-03 18:41

    You can't change the instance type of a VM on-the-fly. To upgrade or downgrade the VM type, you should do the following:

    1. VERY IMPORTANT: make sure to not delete VM's boot disk while shutting down the VM; see this answer for details

    2. shut down the VM cleanly while taking into account the information from step #1 if you're doing this via Google Developers Console or via gcloud on the CLI by using the --keep-disks option or by having already set those disks to not auto-delete as described in this answer:

      gcloud compute instances delete VM \
           --keep-disks=all \
           --project $PROJECT
           --zone $ZONE
      

      Note that --keep-disks accepts any of the following options: boot, data, or all. In your case, you want at least boot but if you've attached other disks, you want to specify all. See the docs for more info.

    3. create a new VM and choose a larger/smaller instance type: again, this can be done via Google Developers Console or via gcloud on the CLI and instead of creating a new boot disk, select the boot disk from the original VM, e.g.,

      gcloud compute instances create $VM \
           --disk name=${DISK_NAME},boot=yes \
           --machine-type ${MACHINE_TYPE} \
           --project $PROJECT
           --zone $ZONE
      

      See the docs for more info.

提交回复
热议问题