Search code examples
sshgoogle-cloud-platformgoogle-compute-enginediskspace

Google-Compute-Engine Virtual Machine Instance: Unable to login/SSH the VM instance after adding a disk


GCP VM instance: OS: Ubuntu (18.04 bionic) Disk size: 10GB. Later added another disk of 10 GB.

While working on the GCP VM instance, I was facing the issue for 'no-disk space left'. Then, I created another disk of 10 GB and added to this GCP VM instance as referred in https://cloud.google.com/compute/docs/disks/add-persistent-disk?&_ga=2.217520662.-1058595688.1590395241#formatting

Now, I exited the GCP VM instance and stopped it.

Later on, when I restarted the GCP VM instance, I am unable to connect. I tried to connect using the SSH connection option available on GCP, putty, WinSCP and telnet, but I am unable to connect now.

My understanding to this is that it might be possible that some services might have stopped on the GCP VM instance. Is there a way to check whether the services are running or not on the GCP VM instances. If yes,then how?

If you think, there is some other issue for connecting to the GCP VM instance then please let me know.


Solution

  • There may be several reasons;

    1. Firewall rules - check them to be sure nothing blocks SSH traffic to your machine.
    2. Have a look at the serial console output - you can do it via console gui or gcloud compute instances get-serial-port-output instance_name --zone=my_zone.

    If your drive gets full you may not be able to login (no matter how).

    Adding another persistend disk won't help if the first one is full.

    You can increase it's size though - also via console or gcloud compute disks resize example-disk-1 --size=11GB - this will add 1GB more and if it's the matter of disk space it should allow you to log in.

    1. If you're still not able to log in try enabling interaction with serial console gcloud compute instances add-metadata instance-name --metadata serial-port-enable=TRUE and connect to it gcloud compute connect-to-serial-port instance-name since this is the most full-proof method if everything else fails.

    If you're able to connect via serial console check if the SSH service is listening:

    sudo service ssh status - if not start it with sudo service ssh start and watch for any errors.

    Similar case was also discussed here.