I'd recommend working this issue in steps.
First,to get hibernate tested and working on your laptop, please read the Ubuntu documentation regarding hibernation. Important: make sure your swap file is larger than your physical RAM, and that it's enabled.
Once you know your laptop can hibernate properly, you can assign laptop actions to trigger hibernation. In your case, you'd like to hibernate on lid close. There's plenty of documentation out in the aether on this topic, but let's go to the source documentation on this: the systemd login configuration file manpage. Of particular interest is the section that describes the HandleLidSwitch
option.According to the documentation, that option
Can be one of "ignore", "poweroff", "reboot", "halt", "kexec",
"suspend", "hibernate", "hybrid-sleep", and "lock".
You want hibernate
(in my own case, I use hybrid-sleep
). So, now it's a matter of editing the logind.conf
file to accommodate this setting (you must be root to do this).
In /etc/systemd
you'll see a file called logind.conf
. Open it for edit, and scroll down to a line that looks like this:
#HandleLidSwitch=suspend
The prepended #
means that this line is currently disabled, so you need to remove it, and then set HandleLidSwitch
to the correct option
HandleLidSwitch=hibernate
Save the logind.conf
file and reboot.
anyway I have only 512MB on my swap so I don't think that I can hibernate according to what has been said above..
– tsachi blau Dec 21 '17 at 19:07