Can't hibernate

22 replies [Last post]
GNUbahn
Offline
Joined: 02/19/2016

Why can't I choose hibernation?

I have 8GB of RAM and 8+GB of swap

AttachmentSize
Power management.png48.72 KB
nickylodeon
Offline
Joined: 07/22/2017

>Well, if you're sure you need to use hibernation, I suggest you to upgrade your kernel (v4.9 and newer will deal with it).*
>Your graphics card may require some proprietary drivers to successfully deal with hibernation.*

*I don't suggest you to use versions newer than 4.9, cause you will have problems with graphics. Gnome app installer is known to have problems with rendering when used in systems with linux-libre v4.12 (as an example).
*Do not even try to use non-free drivers. $$ fglrx-driver 'FGLRX / AMD Catalyst' for the ATI/AMD RadeonHD and FireGL graphics cards is recognized to deal with hanging (as an example) $$. This way (which you don't want to go for sure) requires installation and manual renewing of xorg.conf^^

^You will have to do this every time you wish to update your kernel, or when you receive one.
^You will recognize noticeable downgrade performance as well..

You can get a newer version of linux-libre via APT repositories if you wish.\

This ordained minister in the Church of the Flying Spaghetti Monster will help you: *** https://jxself.org/linux-libre/ ***

Magic Banana

I am a member!

Offline
Joined: 07/24/2010

If you encrypted your swap (did you?), it is normal you cannot hibernate. Same thing if your swap file/partition is too small. In both cases, this command would tell:
$ swapon -s

GNUbahn
Offline
Joined: 02/19/2016

I didn't for this setup.

$ swaopn -s

gives me

Filename Type Size Used Priority

And nothing more

Magic Banana

I am a member!

Offline
Joined: 07/24/2010

Well, you do not have any swap (or it is deactivated): it is normal you cannot hibernate. You can create either a swap partition (from a live system, using fdisk or GNU parted or GParted, its graphical interface, which is far less intimidating) or, easier (especially if you have no partition to shrink; XFS cannot be shrunk), a swap file (here /swap, of size 4 GiB but setting it to the size of your RAM makes sense: you will be able to hibernate even if your RAM is full):
$ sudo dd if=/dev/zero of=/swap bs=1024 count=4194304
$ sudo mkswap /swap
$ sudo swapon /swap

For the swap to be enabled at init (rather than manually executing 'swapon' after every reboot), one line must be appended to /etc/fstab (here for the swap file above, indicate the partition instead of the file if you chose a swap partition):
$ echo '/swap swap swap defaults 0 0' | sudo tee -a /etc/fstab

EDIT: actually, there is more to do to be able to hibernate using a swap file (rather than a swap partition). See https://wiki.debian.org/Hibernation/Hibernate_Without_Swap_Partition for those additional steps.

GNUbahn
Offline
Joined: 02/19/2016

What are the advantages and disadvantages of either solution, i.e. partition vs file?

Magic Banana

I am a member!

Offline
Joined: 07/24/2010

None in terms of performance. We could say that it is easier to make and share (between systems) a swap partition as long as you have free disk space (typically before an install), whereas it is easier to make a swap file as an afterthought. Also, it is easier to change the size of a swap file. However, as I recently discovered (and commented on above), having a swap file work for hibernation requires additional steps.

GNUbahn
Offline
Joined: 02/19/2016

For some reason it was not activated. This is the first time I have experienced swap not being active after a fresh install.

Actually. when I open Gparted the partition was there but indicated with black (and a warning triangle, if I remember correctly).

I deleted that partition and created a new swap. Running the 'swapon -s' command still showed no swap. I restarted, still no swap. Then I opened Gparted again and noticed that swap wasn't on.

Like I said, this is the first time I have experienced this. Have done something wrong during installation?

GNUbahn
Offline
Joined: 02/19/2016

After restarting the computer the swap is again not active!

What will I have to do to make it permanently active?

Magic Banana

I am a member!

Offline
Joined: 07/24/2010

You can first try to manually activate your swap partition (here assuming it is /dev/sda1: adapt the command to your case; 'lsblk' helps to know what is your swap partition):
$ sudo swapon /dev/sda1

If it works ('sudo swapon -s' shows it), you can run this command (again, modify the partition to fit your case):
$ echo '/dev/sda1 swap swap defaults 0 0' | sudo tee -a /etc/fstab

The line appended to /etc/fstab, "/dev/sda1 swap swap defaults 0 0", asks for the activation of the swap at init.

GNUbahn
Offline
Joined: 02/19/2016

My swap is on sda2. I ran your first command and when checking swap was on. Then I ran your second command and restarted. Swap is not on!?

This is really weird. I mean, I am by no means either a savvy, a techie or anything, but I have installed GNU/linux a lot of times (to some extend because I am no savvy, techie etc.). And I have never experienced that swap did not work after installation.

What is going on?

Magic Banana

I am a member!

Offline
Joined: 07/24/2010

I do not know. Is it enabled when you execute 'sudo swapon -a'?

Show us the outputs of these commands:
$ lsblk
$ grep swap /etc/fstab
$ swapon -s

GNUbahn
Offline
Joined: 02/19/2016

sudo swapon -a

gives me

swapon: /dev/mapper/cryptswap1: stat failed: No such file or directory
swapon: /dev/sda1: read swap header failed: Invalid argument

Did I mention that I only encrypted /home?

The rest of your commands return:

gnubahn@libreT400s:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 119.2G 0 disk
├─sda1 8:1 0 23.3G 0 part /
├─sda2 8:2 0 8.4G 0 part
└─sda3 8:3 0 87.6G 0 part /home
sr0 11:0 1 4.8G 0 rom /media/gnubahn/DVDVolume
gnubahn@libreT400s:~$ grep swap /etc/fstab
# swap was on /dev/sda2 during installation
#UUID=ade109a9-fce9-4921-b762-9e15b3cde2b5 none swap sw 0 0
/dev/mapper/cryptswap1 none swap sw 0 0
/dev/sda1 swap swap defaults 0 0
gnubahn@libreT400s:~$ swapon -s
Filename Type Size Used Priority

Magic Banana

I am a member!

Offline
Joined: 07/24/2010

You wrote /dev/sda1 instead of /dev/sda2 in /etc/fstab. Also you (used to?) have your swap encrypted what does not allow (at least not naturally) hibernation. Edit /etc/fstab to remove the line "/dev/mapper/cryptswap1 none swap sw 0 0" and to turn "/dev/sda1 swap swap defaults 0 0" into "/dev/sda2 swap swap defaults 0 0" (here using the GEdit text editor):
$ gksu gedit /etc/fstab
Save the file and run this command to enable swapping:
$ sudo swapon -a
This command will tell if your swap aws really enables:
$ swapon -s
If so, it should be automatically enable at init.

GNUbahn
Offline
Joined: 02/19/2016

I got it to work - apparently permanent. But I have one more issue, which I experienced while I was only having a temporary solution and again in the end with the permanent solution: When waking up my machine from hibernation, it wakes up just a few seconds and then hibernates again (I am using 'FN+F4').

I consider reinstalling from fresh...

Magic Banana

I am a member!

Offline
Joined: 07/24/2010

I do not see how it would help. You can reformat the swap partition (that may help since it used to be encrypted, but I doubt so):
$ sudo swapoff -a
$ sudo mkswap /dev/sda2
$ sudo swapon -a

And you can try a more recent kernel: https://jxself.org/linux-libre/

GNUbahn
Offline
Joined: 02/19/2016

That gave no change.

Strangely though, using 'Fn+F12' to wake it up does work!

Could the problem be about assignation of keys?

Magic Banana

I am a member!

Offline
Joined: 07/24/2010

Apparently. I is a quite common problem.

GNUbahn
Offline
Joined: 02/19/2016

Do you think updating to a newer kernel would help?

Magic Banana

I am a member!

Offline
Joined: 07/24/2010

It can. Everything hardware-related deals with the kernel.

GNUbahn
Offline
Joined: 02/19/2016

Ok then, I'll give it a shot.

GNUbahn
Offline
Joined: 02/19/2016

Unfortunately no change...

GNUbahn
Offline
Joined: 02/19/2016

I find it not unusual that some problems which 'seem' OS related- for non-techies like myself - get solved by a re-installation.

But I will try your advise first, thanks.