It's been a couple of years since I last had a go at getting hibernate / suspend to disk working on my Slackware system. Back then the problem seemed to be that the Nvidia drivers just didn't like hibernate. They didn't like sleep / suspend either, but that wasn't as bad. The idea was that when I press the power button my PC would leave everything running and hibernate so that the next day I didn't have to re-open everything.
I already had the
resume=/dev/sda1 in my Linux kernel options, where sda1 is my swap partition which is big enough to store the memory. So all I had to do was set the power button to hibernate instead of shutdown.
Slackware now uses
elogind and I found the setting I wanted in
/etc/elogind/logind.conf. I just need to uncomment
HandlePowerKey right?, like so:
After changing the settings I told elogind to reload its conf using
killall -HUP elogind-daemon and pressed my power button.
It worked, kind of.. The PC hibernated and when I pressed a button on my keyboard it woke up again and started restoring the memory from disk. But then it shut down. I tried again after restarting the PC, maybe elogind hadn't really reloaded the config properly with just the HUP signal? This time the PC just closed everything and shutdown, but when I turned it back on it starting suspending to disk before reaching my X login screen.
It turns out my problem was that elogind was fighting with acpid over who acts on power button events so elogind was trying to hibernate at the same time as
acpid was trying to poweroff. My system has been running Slackware current for a long time so a lot has changed since it was first installed, maybe
acpid isn't required any more? I would have to check on a fresh system, but I don't need it if I am going to use elogind to handle my power button so I
chmod -x /etc/rc.d/rc.acpid and now my hibernation on power button is acting as expected.
Just need to wait and see how well the Nvidia drivers handle it now.