Sunday, July 10, 2022

Ubuntu - Disable Sleep or Suspend Mode

 I have a small Ubuntu 18.04 system (should work on 16.04) that is running headless and appears to be going to sleep on me.  

I found references to changing the settings for a laptop when the lid was closed, but this isn't a laptop and so I didn't believe that would be the cause of my system sleeping.   If simply pressed the power button quickly, the system responded to ping/ssh, etc and I could see that the system showed it had been up for several days (since my last known reboot).  

I also ran the command below and saw that it "reached target Sleep"

me@ubuntu:~$systemctl status sleep.target

● sleep.target - Sleep

     Loaded: loaded (/lib/systemd/system/sleep.target; static; vendor preset: enabled)

     Active: inactive (dead) since Sun 2022-07-10 22:47:44 UTC; 17min ago

       Docs: man:systemd.special(7)


Jul 10 17:16:33 ubuntu systemd[1]: Reached target Sleep.

Jul 10 22:47:44 ubuntu systemd[1]: Stopped target Sleep.

To disable Suspend mode, I ran the following command:

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target


To re-enable it run:

sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target

For good measure, I also changed the Power Mangement Settings (which can also be done in the GUI if you are running one). 

Power Management Settings (without a GUI)

gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout '0' && gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout '0'

Friday, July 8, 2022

VMware Fusion - How to power off suspeneded Virtual Machine

 Today I upgraded VMware Fusion and a suspended Virtual Machine would not start.  The recommendation was to change some CPU advanced settings and restart, however, my VM was in a Suspended state and would not start and would not power down in a typical way.

I found this little trick to power down the VM. 

If your VM has been suspended and you can't make the above changes, then you can go to the menu 

-> Virtual Machines -> Hold down the Option (Windows users -> Alt) key and choose "Power Off".

After that, you should be able to make the changes so you can boot your VM again.

NOTE: When I first brought up the menu, "Power Off" was greyed out but sure enough, when you hold the option key (OSX) you are able to select it.