How to enable hibernation with swap partion on Linux Mint 19

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials,start your own thread in the appropriate sub-forum instead. Before you post please read this
goebbe
Level 1
Level 1
Posts: 9
Joined: Sun Jun 02, 2013 8:29 am

How to enable hibernation with swap partion on Linux Mint 19

Post by goebbe » Fri Jul 13, 2018 9:21 am

Hello,
this howto should help you to set up working hibernation with a swap partition on a fresh install of LM19.

Short background:
a. Hibernation basically writes the content of your memory into the swap space of your computer - when you start your computer, after hibernation, it should load/ read the content of the swap partition in order to resume.
b. There are two different methods to set up a swap-space on your disk. First: The use of a separate swap partition (set up when formatting your disk during install). Second, the use of a swap file (this is the new default).
c. Hibernation is known to cause problems on some computers. Be sure that you know howto boot and restore your system, before you enable hibernation. It is probably a good idea to have a working usb-stick with Linux Mint 19 around. :D

There may be different reasons, why some users use a separate swap partition. One reason could be that you want to use btrfs as a file system (and btrfs does not support swap-files).
This howto should guide you, when setting up hibernation and using a separate swap partition.

1. Step - Make sure, that the kernel will look at the right place when booting (after hibernation):
In order to achieve this, one has to add the option "resume=UUID= " to the file /etc/default/grub

1a. Copy your UUID of the swap partition from fstab:

Code: Select all

cat /etc/fstab
1b. Add the boot option to grub (your boot loader):

Code: Select all

xed admin:///etc/default/grub
Add the following boot option "resume=UUID=putYourSwapUUIDhere" to GRUB_CNMDLINE_LINUX_DEFAULT.
Example:

Code: Select all

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=putYourSwapUUIDhere"
Note that you have to copy your UUID from fstab to replace putYourSwapUUIDhere.

Save the grub file and update grub:

Code: Select all

sudo update-grub
2. Now check if hibernation works from the command line:
Open terminal and run command:

Code: Select all

systemctl hibernate
If hibernate works from the command line - but is not visible in the shutdown menu,
enable it in the menus via the following steps.

3. Enable hibernation in the shutdown menu
Open terminal and run the following commands to create and edit the configuration file:

Code: Select all

sudo touch /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
xed admin:///etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
When the file opens, copy and paste the following content into the file and save it:

Code: Select all

[Re-enable hibernate by default in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes

[Re-enable hibernate by default in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.handle-hibernate-key;org.freedesktop.login1;org.freedesktop.login1.hibernate-multiple-sessions;org.freedesktop.login1.hibernate-ignore-inhibit
ResultActive=yes
Hibernation should show up in the menu and the "Power Management" settings of LM19.
Comments are welcome.
Last edited by goebbe on Mon Jul 16, 2018 12:29 pm, edited 4 times in total.

gm10
Level 12
Level 12
Posts: 4152
Joined: Thu Jun 21, 2018 5:11 pm

Re: Howto enable hibernation with swap partion on Linux Mint 19

Post by gm10 » Fri Jul 13, 2018 9:51 am

goebbe wrote:
Fri Jul 13, 2018 9:21 am
Comments are welcome.
You should really use xed admin://</path/file>, there's no reason to run the editor itself with elevated privileges. Also sudo with GUI programs is just generally bad practice and can lead to issues in some cases.

Otherwise looking good, although hibernation had to be disabled in Mint 19 because it is really problematic with the Ubuntu 18.04 base, so good luck to those trying it.
Last edited by gm10 on Sun Aug 05, 2018 11:17 am, edited 1 time in total.

User avatar
catweazel
Level 17
Level 17
Posts: 7756
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: Howto enable hibernation with swap partion on Linux Mint 19

Post by catweazel » Fri Jul 13, 2018 10:33 am

goebbe wrote:
Fri Jul 13, 2018 9:21 am
c. Hibernation is known to cause problems on some computers.
The only thing I would suggest is that you add a small section on how to test if hibernate is supported on a particular machine. See, for example: http://ubuntuhandbook.org/index.php/201 ... ntu-17-10/ as there's no point if hibernation isn't supported.
¡uʍop ǝpısdn sı buıɥʇʎɹǝʌǝ os ɐıןɐɹʇsnɐ ɯoɹɟ ɯ,ı

goebbe
Level 1
Level 1
Posts: 9
Joined: Sun Jun 02, 2013 8:29 am

Re: Howto enable hibernation with swap partion on Linux Mint 19

Post by goebbe » Fri Jul 13, 2018 10:53 am

The only thing I would suggest is that you add a small section on how to test if hibernate is supported on a particular machine. See, for example: http://ubuntuhandbook.org/index.php/201 ... ntu-17-10/ as there's no point if hibernation isn't supported.
Thank you!

Is there a good way to check if hibernation is supported?
The only suggestion is to search in the internet for bug reports.
However this is likely to give false results, since hibernation depends on the version of the kernel, the version of the driver, the configuration, the implementation details.

In the end it always comes down to trial an error - which is basically what is suggested in your link: "sudo pm-hibernate" <- the equivalent to "sudo systemctl hibernate" in step 2.
However if one does not implement step 1 - hibernation will always fail. :-)
Last edited by goebbe on Fri Jul 13, 2018 10:56 am, edited 1 time in total.

goebbe
Level 1
Level 1
Posts: 9
Joined: Sun Jun 02, 2013 8:29 am

Re: Howto enable hibernation with swap partion on Linux Mint 19

Post by goebbe » Fri Jul 13, 2018 10:54 am

gm10 wrote:
Fri Jul 13, 2018 9:51 am
You should really use xed admin://</path/file>, there's no reason to run the editor itself with elevated privileges. Also sudo with GUI programs is just generally bad practice and can lead to issues in some cases.
Thank you! I edited my little howto, as suggested. :-)

User avatar
catweazel
Level 17
Level 17
Posts: 7756
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: Howto enable hibernation with swap partion on Linux Mint 19

Post by catweazel » Fri Jul 13, 2018 10:58 am

goebbe wrote:
Fri Jul 13, 2018 10:53 am
Is there a good way to check if hibernation is supported?
The only suggestion is to search in the internet for bug reports.
It's in the link I gave you. Step 1...
In the end it always comes down to trial an error
No, it does not.
which is basically what is suggested in your link: "sudo pm-hibernate"
An explicit step is not trial and error, it's a test or check. Nevertheless, if it's the same step as you say then leave it. No worries.
¡uʍop ǝpısdn sı buıɥʇʎɹǝʌǝ os ɐıןɐɹʇsnɐ ɯoɹɟ ɯ,ı

gm10
Level 12
Level 12
Posts: 4152
Joined: Thu Jun 21, 2018 5:11 pm

Re: Howto enable hibernation with swap partion on Linux Mint 19

Post by gm10 » Fri Jul 13, 2018 11:05 am

catweazel wrote:
Fri Jul 13, 2018 10:58 am
An explicit step is not trial and error, it's a test or check.
That really is exactly the same thing. ;)

OP, one more: sudo systemctl hibernate -- there's no reason to sudo that one, either. Don't be so generous with your sudo. Elevated privileges should be given sparingly. A program that runs elevated basically owns your system. Never forget. ;)

goebbe
Level 1
Level 1
Posts: 9
Joined: Sun Jun 02, 2013 8:29 am

Re: Howto enable hibernation with swap partion on Linux Mint 19

Post by goebbe » Fri Jul 13, 2018 2:49 pm

OP, one more: sudo systemctl hibernate -- there's no reason to sudo that one, either. Don't be so generous with your sudo. Elevated privileges should be given sparingly. A program that runs elevated basically owns your system. Never forget. ;)
Good catch! Thank you. I changed the howto.

sour_diesel
Level 1
Level 1
Posts: 2
Joined: Mon Jul 16, 2018 10:35 am

Re: Howto enable hibernation with swap partion on Linux Mint 19

Post by sour_diesel » Mon Jul 16, 2018 11:41 am

I just wanted to say thank you for this post. Worked perfectly for me! So glad I decided to visit the Mint Forums today!!

I recently migrated from Ubuntu to Mint and need hibernation .... can't live without it. The last part of your post for enabling the hibernation option in the quit menu did not work me.


However this is how I accomplished that:

Use this command in a terminal to create a text file:

Code: Select all

 sudo nano /var/lib/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkl 
Copy and paste this into your newly created file, save, and exit.

Code: Select all

[Re-enable hibernate by default in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes

[Re-enable hibernate by default in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate
ResultActive=yes
Restart your computer and then click the Menu / Quit / Hibernate :)

goebbe
Level 1
Level 1
Posts: 9
Joined: Sun Jun 02, 2013 8:29 am

Re: Howto enable hibernation with swap partion on Linux Mint 19

Post by goebbe » Mon Jul 16, 2018 12:44 pm

sour_diesel wrote:
Mon Jul 16, 2018 11:41 am
Use this command in a terminal to create a text file:

Code: Select all

 sudo nano /var/lib/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkl 
Thank you!
xed admin:// can only edit an existing file! So when using xed admin:/// one has to add an additional step, in order to create the file.
I edited the howto. :-) Of course, one can also use the nano editor, as suggested.
Last edited by goebbe on Mon Jul 16, 2018 2:01 pm, edited 1 time in total.

gm10
Level 12
Level 12
Posts: 4152
Joined: Thu Jun 21, 2018 5:11 pm

Re: Howto enable hibernation with swap partion on Linux Mint 19

Post by gm10 » Mon Jul 16, 2018 12:54 pm

goebbe wrote:
Mon Jul 16, 2018 12:44 pm
sour_diesel wrote:
Mon Jul 16, 2018 11:41 am
Use this command in a terminal to create a text file:

Code: Select all

 sudo nano /var/lib/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkl 
Thank you!
xed admin:// can only edit an existing file! So when using xed admin:/// one has to add an additional step, in order to create the file.
I edited the howto. :-) Or one can use the nano editor, as suggested.
You can even do it without an editor all in one go:

Code: Select all

sudo bash -c "cat >> /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla <<EOB
[Re-enable hibernate by default in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes

[Re-enable hibernate by default in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.handle-hibernate-key;org.freedesktop.login1;org.freedesktop.login1.hibernate-multiple-sessions;org.freedesktop.login1.hibernate-ignore-inhibit
ResultActive=yes
EOB"
Don't you love Linux?! :lol:

sour_diesel
Level 1
Level 1
Posts: 2
Joined: Mon Jul 16, 2018 10:35 am

Re: Howto enable hibernation with swap partion on Linux Mint 19

Post by sour_diesel » Tue Jul 17, 2018 11:56 am

Indeed I do. Love Linux sooo much!

dwisatriow
Level 1
Level 1
Posts: 2
Joined: Wed Jul 04, 2018 5:55 am

Re: Howto enable hibernation with swap partion on Linux Mint 19

Post by dwisatriow » Fri Jul 27, 2018 9:45 am

Hi, i've try

Code: Select all

systemctl hibernate
but it says "Failed to hibernate system via logind: Sleep verb not supported"

and when i try

Code: Select all

sudo pm-hibernate
nothing happen.

Then i try run

Code: Select all

sudo systemctl hibernate
the system off but when i turned it on it doesn't hibernate and there is a javaembeddedframe icon on panel which i can't close.

Can anyone help me?

goebbe
Level 1
Level 1
Posts: 9
Joined: Sun Jun 02, 2013 8:29 am

Re: Howto enable hibernation with swap partion on Linux Mint 19

Post by goebbe » Tue Jul 31, 2018 9:37 am

dwisatriow wrote:
Fri Jul 27, 2018 9:45 am
Hi, i've try

Code: Select all

systemctl hibernate
but it says "Failed to hibernate system via logind: Sleep verb not supported"
There are several known possibilities that could lead to this error message:
1. hibernation might not be supported by your hardware (computer) - did it work before installing Mint 19?
2. hibernation might not be supported by your Linux kernel - use the standard kernel, if possible.
3. hibernation is known to cause problems in combination with "secure boot" - disable secure boot if possible.
Take care: If you need secure boot e.g. in a dual boot setup, for booting Windows, this is not an option.
4. make sure that your swap partition is bigger than your memory (RAM).

Please report back, if you find the source of your problem.

dwisatriow
Level 1
Level 1
Posts: 2
Joined: Wed Jul 04, 2018 5:55 am

Re: Howto enable hibernation with swap partion on Linux Mint 19

Post by dwisatriow » Thu Aug 02, 2018 10:51 am

goebbe wrote:
Tue Jul 31, 2018 9:37 am
There are several known possibilities that could lead to this error message:
1. hibernation might not be supported by your hardware (computer) - did it work before installing Mint 19?
2. hibernation might not be supported by your Linux kernel - use the standard kernel, if possible.
3. hibernation is known to cause problems in combination with "secure boot" - disable secure boot if possible.
Take care: If you need secure boot e.g. in a dual boot setup, for booting Windows, this is not an option.
4. make sure that your swap partition is bigger than your memory (RAM).

Please report back, if you find the source of your problem.
Thanks for the reply, after considering the risk about enabling hibernation on dual boot system, i think i'm not going to enable it.

davido_
Level 1
Level 1
Posts: 10
Joined: Sat Oct 27, 2012 7:41 am

Re: Howto enable hibernation with swap partion on Linux Mint 19

Post by davido_ » Sun Aug 05, 2018 10:39 am

gm10 wrote:
Fri Jul 13, 2018 9:51 am
Otherwise looking good (if your cat /etc/initramfs-tools/conf.d/resume already has the correct UUID then you can skip most of your steps but no matter), although hibernation had to be disabled in Mint 19 because it is really problematic with the Ubuntu 18.04 base, so good luck to those trying it.
You're giving a null-info. Tell us, what are the "most" steps to skip?

However, I could not skip any step. After finally adding swap UUID to /etc/default/grub everything works.

gm10
Level 12
Level 12
Posts: 4152
Joined: Thu Jun 21, 2018 5:11 pm

Re: Howto enable hibernation with swap partion on Linux Mint 19

Post by gm10 » Sun Aug 05, 2018 11:19 am

davido_ wrote:
Sun Aug 05, 2018 10:39 am
You're giving a null-info. Tell us, what are the "most" steps to skip?
Valid point. I simply removed that part from my post. Just follow the OP's good tutorial, no reason to potentially cause confusion with a side-discussion.

andrekappert
Level 1
Level 1
Posts: 6
Joined: Tue Nov 19, 2013 5:36 am

Re: How to enable hibernation with swap partion on Linux Mint 19

Post by andrekappert » Tue Aug 07, 2018 11:47 am

This will create confusion. The original method speaks of the file “/etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla”. The alternative method speaks of the file “/var/lib/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkl”. Different directory and different extension!

What worked for me:
if you created the file “/etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla”, then delete it.
Create the file “/var/lib/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla” with the new text from sour_diesel Mon Jul 16, 2018 11:41 am.

I have taken the original extension. The extension just describes what sort file it is. I believe that just any file in this sort of directory is parsed, whatever the name is. Why the directory var/lib works and etc not, only an expert will know. Using points in filenames is by the way a weird/dangerous habit. Is the extension part after the first or last point. I thought it would be the last, a filename manipulation function of free pascal thinks the first. In the past, this created a strange error for me.

User avatar
BG405
Level 7
Level 7
Posts: 1551
Joined: Fri Mar 11, 2016 3:09 pm
Location: England

Re: How to enable hibernation with swap partion on Linux Mint 19

Post by BG405 » Thu Aug 09, 2018 2:16 pm

andrekappert wrote:
Tue Aug 07, 2018 11:47 am
This will create confusion. The original method speaks of the file “/etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla”. The alternative method speaks of the file “/var/lib/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkl”. Different directory and different extension!
Well spotted!

It always pays to double-check commands in case anything has been missed off. Seen this in instructions on other websites, one just missing that final / on the path ...
Dell Inspiron 1525 - LM17.3 CE 64-------------------Acer D255E 2GB - Manjaro KDE, LM17.3 KDE 32
Toshiba NB305 - Manjaro KDE------------------------K7S5A AMD 1.2GHz - LM17.3 Xfce 32 & WinXP-Pro
Acer Aspire E11 ES1-111M - LM18.2 KDE 64 ----Dell PII 350 64MB - Puppy 4.3 & Win98-SE

gm10
Level 12
Level 12
Posts: 4152
Joined: Thu Jun 21, 2018 5:11 pm

Re: How to enable hibernation with swap partion on Linux Mint 19

Post by gm10 » Thu Aug 09, 2018 2:22 pm

Just do what's written in the OP. No confusion, no problems. ;)

Post Reply

Return to “Tutorials”