Starting the upgrade
The following sections guide you through the process of upgrading your VM instance.
In the Google Cloud console, open
Cloud Shell
by clicking the
Activate Cloud Shell
button.
Go to the Google Cloud console
Set the default project ID. Replace
PROJECT_ID
with
the name of your Compute Engine project:
gcloud config set project
PROJECT_ID
Run the following command to start the upgrade:
gcloud beta compute os-config os-upgrade
VM_NAME
\
--zone=
ZONE
\
--source-os=windows-2008r2 \
--target-os=windows-2012r2 \
--async \
--auto-rollback
Replace the following:
VM_NAME
: the name of the VM instance to upgrade
ZONE
: the zone the VM instance is running in
The
--async
flag tells the gcloud CLI to run the upgrade in the
background by using
Cloud Build
.
Running the upgrade in the background lets you upgrade multiple VM instances
in parallel and also ensures that the process continues even if you close
your Cloud Shell session. You can find a link to the Cloud Build
job in the command output:
Created [https://cloudbuild.googleapis.com/v1/projects/...].
...
logUrl: https://console.cloud.google.com/build/builds/...
...
status: QUEUED
...
Observing the upgrade process
Depending on the configuration of your VM instance, the upgrade might take
between 40 and 90 minutes to complete. You can check the status of the upgrade
process by opening the Cloud Build log:
- Click the URL shown next to
logUrl
in the command output of the gcloud CLI.
- Under
Build log
, you can see the current status of the upgrade process.
When the upgrade finishes successfully, the build is marked as
Successful
and
you can see the following output in the build log:
Successfully upgraded instance 'projects/...!'
If the gcloud CLI encounters a problem during the upgrade, it marks
the build as
Failed
. If the
--auto-rollback
option is specified,
the gcloud CLI also initiates an automatic rollback. You can find
further details about the problem encountered in the build log.
If the upgrade is still running after 90 minutes and you suspect that the upgrade
is not progressing, use one of the approaches described in
Troubleshooting the in-place upgrade
to find out whether the upgrade process failed or is stalled.
Completing the upgrade
After the upgrade is complete, start the VM instance and run Windows Update to
download and install the latest security updates:
Start the VM instance:
gcloud compute instances start
VM_NAME
--zone=
ZONE
Replace the following:
VM_NAME
: the name of the VM instance
ZONE
: the zone the VM instance is running in
Connect to the machine by using an RDP client. For more information, see
Connecting to instances
.
Use Windows Update to
install the latest Windows updates
.
You might have to restart the VM instance multiple times during this process.
Verify that all your applications work as expected.
Rolling back an upgrade
If the upgrade fails, the gcloud CLI automatically initiates a
roll-back. If the upgrade succeeds, you might still find that one of your
applications does not work as expected. In that case, roll back the upgrade by
changing the VM instance to use the original boot disk again:
Stop the VM instance:
gcloud compute instances stop
VM_NAME
--zone=
ZONE
Replace the following:
VM_NAME
: the name of the VM instance
ZONE
: the zone the VM instance is running in
In the build log, find the lines indicating the name of the original boot
disk and the name of the attachment:
4. Original boot disk:
ORIGINAL_DISK_NAME
- Device name of the attachment:
DEVICE_NAME
Detach the disk containing the malfunctioning operating system from your instance:
gcloud compute instances detach-disk
VM_NAME
\
--device-name=
DEVICE_NAME
\
--zone=
ZONE
Replace the following:
VM_NAME
: the name of the VM instance
DEVICE_NAME
: the device name as indicated by the build log
ZONE
: the zone the VM instance is running in
Reattach the original boot disk:
gcloud compute instances attach-disk
VM_NAME
\
--disk=
ORIGINAL_DISK_NAME
\
--device-name=
DEVICE_NAME
\
--zone=
ZONE
Replace the following:
- VM_NAME
: the name of the VM instance
ORIGINAL_DISK_NAME
: the name of the original boot disk as indicated by the build log
DEVICE_NAME
: the device name as indicated by the build log
ZONE
: the zone the VM instance is running in
Start the VM instance:
gcloud compute instances start
VM_NAME
--zone=
ZONE
Replace the following:
VM_NAME
: the name of the VM instance
ZONE
: the zone the VM instance is running in