Upgrading OS on GCP Compute Engine VM
Solution 1:
You can perform a full inplace OS upgrade but it's not recommended. If for example there's a need to confirm anything during the reboot process you won't be able to do it remotely. You may try to use serial console interaction but it's always a risk.
It's best to clone the VM an try the upgrade on the copy first.
For the test purposes I've tested upgrading from Debian 9 Stretch
to Debian 10 Buster
. Here's how:
First I've created a new GCP instance running Debian 9 (default settings); then I logged in via SSH and ran fallowing commands:
First I've changed /etc/apt/sources.list
all stretch
to buster
occurences (necessary to go from 9 to 10) with sudo sed -i 's/stretch/buster/g' /etc/apt/sources.list
and next ran:
-
lsb_release -a
- check current OS version
Distributor ID: Debian
Description: Debian GNU/Linux 9.13 (stretch)
Release: 9.13
Codename: stretch
sudo apt update
sudo apt upgrade -y
-
lsb_release -a
- verify after upgrade
If everything's OK you should see:
me@d9:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 10 (buster)
Release: 10
Codename: buster
I was able to SSH into my instance using GCP console with no issues. As you can see I've used just "apt upgrade" since it will just upgrade installed packages. You can check the difference between upgrade
vs dist-upgrade
in this answer.
I can't say if it's possible with Red Hat or CentOS but I can make and educated guess and say it's possible in the same way as with Debian.