Search code examples
google-cloud-platformgoogle-compute-engineubuntu-18.04swapfile

Google Cloud Compute Engine not activating swap memory and cannot ssh to fix


Recently, I've been unable to access the VM. I've looked through the console logs on the instance page, and I'm confident that the reason I am unable to ssh into the instance is that there isn't enough memory.

In the logs during startup, there is the line

[[0;1;31mFAILED[0m] Failed to activate swap /swapfile1.

See 'systemctl status swapfile1.swap' for details.

The issue is, I can't actually access the system in order to troubleshoot or remedy any situations I've searched for on the web.


Solution

  • If you are unable to ssh into VM due to insufficient memory, then you can reset the instance to forcibly wipes the memory contents of the machine and resets the virtual machine to its initial state.

    When you reset an instance, none of the instance properties (like IP, persistent disk) change. Only data stored in memory is reset.

    Steps for resetting an instance

    enter image description here