[GUIDE] How to hibernate to a swap file in Linux Mint 19.x

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
orca
Level 1
Level 1
Posts: 5
Joined: Thu Jan 24, 2019 1:36 pm

Re: [GUIDE] How to hibernate to a swap file in Linux Mint 19.x

Post by orca »

I followed the above instructions and sometimes hibernate doesn't work really well. Most of the times I use hibernate I have to try 2-3 times to work because it tries to lock/wait for some processes. I lost the "Sleep" button. How I can reverse the changes and just use the sleep option?
gm10

Re: [GUIDE] How to hibernate to a swap file in Linux Mint 19.x

Post by gm10 »

orca wrote: Tue Feb 04, 2020 12:00 pm lost the "Sleep" button. How I can reverse the changes and just use the sleep option?
That's curious, but if all you did was follow the guide then this will undo that:

Code: Select all

sudo rm -v /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
West_Training_8668
Level 2
Level 2
Posts: 71
Joined: Tue Mar 29, 2016 8:41 am

Re: [GUIDE] How to hibernate to a swap file in Linux Mint 19.x

Post by West_Training_8668 »

It worked! Thanks a lot. My previous laptop battery completely stopped working because I was always using suspend. Hopefully the next one will last me more than a year with hibernation because this one only lasted 231 days.

Operating System: Linux Mint 19.3
Kernel: Linux 5.0.0-32-generic
Architecture: x86-64
mauromol
Level 1
Level 1
Posts: 48
Joined: Wed Jul 13, 2011 6:46 am
Location: Pino Torinese (TO) - Italy

Re: [GUIDE] How to hibernate to a swap file in Linux Mint 19.x

Post by mauromol »

Really annoying that a desktop-oriented O.S. like Mint has made it so difficult to enable the hibernation feature! :?
This feature was in Mint 17 and 18, yesterday I installed 19 on my wife's netbook and it is missing.
Suspend to RAM isn't the same, it still consumes battery and for an old laptop it can make a difference. Especially because Linux "suspend to RAM" is not a hybrid suspension, which can restore the state from disk if the battery meanwhile has died.

I know that hibernation has always been problematic in Linux, but from my experience it is getting better with time. I think this is a step behind for Mint: if the problem is that it sometimes doesn't work reliably, a "disclaimer" would be a better choice to make the user informed and let him/her try (and hopefully use) all the same.
User avatar
lonely_llama
Level 3
Level 3
Posts: 128
Joined: Mon Jul 22, 2019 12:08 am

Re: [GUIDE] How to hibernate to a swap file in Linux Mint 19.x

Post by lonely_llama »

After updating to kernel 4.15.0.91, and increasing my RAM from 4 to 12 GB, hibernation has stopped working. I use a BTRFS partition and had no problems until now.

I recreated the swap file exactly as instructed in this post (as I originally successfully had), with a size of 12 GB but after every reboot it fails to mount with the error that the swapfile has holes.
I have already tried creating the swapfile with fallocate as opposed to dd but it makes no difference. Is this a problem with the kernel, given that it does show that hibernation is supported?
slvstr3
Level 1
Level 1
Posts: 23
Joined: Sat Feb 15, 2020 7:20 am

Re: [GUIDE] How to hibernate to a swap file in Linux Mint 19.x

Post by slvstr3 »

Most complete and clear guide for hibernation. Worked flawlessly (for my Mint 19.3). Thank you so much!
BrunoMiranda
Level 4
Level 4
Posts: 359
Joined: Thu Jun 24, 2010 2:22 pm

Re: [GUIDE] How to hibernate to a swap file in Linux Mint 19.x

Post by BrunoMiranda »

How do I disable this and revert hibernation back to using s2disk?

I made it work, thanks for the tutorial, but now I've realized I'd prefer to go back to hibernate to a partition.
Reason is, when I backup I don't have to store that huge file, and since I have 2 OSs in the computer I can use the swap partition on both of them (with the limitation of only being able to hibernate one OS at the time).

I've reverted most of the changes but it's still not 100% functional. The system can hibernate using s2disk on the terminal but when I choose the Hibernate button on the GUI the screen goes black for a second and then the system is back instead of initiating hibernation.

So...
- The swap partition is activated on /etc/fstab
- /etc/default/grub has been modified to use a partition instead of a file
- /etc/uswsusp.conf has been updated
- sudo update-grub has been ran
- sudo update-initramfs -u has been ran
- The system hibernates and resumes using s2disk on the terminal

So how can I reassign the Hibernate button to go back to s2ram? (my favorite Linux command) :roll:
Any hints? Thanks!
Bye for now,
Bruno


(Always backup before you screw up :)
iRiKi
Level 1
Level 1
Posts: 14
Joined: Wed Jul 03, 2019 6:33 am

Re: [GUIDE] How to hibernate to a swap file in Linux Mint 19.x

Post by iRiKi »

Pjotr wrote: Mon Jun 17, 2019 5:59 pm
gm10 wrote: Sat Jun 15, 2019 11:50 am
FamCompKid wrote: Sat Jun 15, 2019 8:21 am What's the philosophy behind this?
Mostly Ubuntu not wanting to support it on all possible hardware combinations and deciding that suspend to RAM is good enough.
Which it is. :mrgreen:
No, it is NOT.
pebcak
Level 4
Level 4
Posts: 222
Joined: Mon Dec 16, 2019 4:59 am

Re: [GUIDE] How to hibernate to a swap file in Linux Mint 19.x

Post by pebcak »

gm10 wrote: Sun Dec 23, 2018 7:38 am Linux Mint 19 does not support hibernation out of the box - this guide shows you how to enable it when using the default swap file.
Hi gm10,

I just wanted to ask if these instructions are applicable to LMDE4 as well. I would appreciate if you let me know.
User avatar
lonely_llama
Level 3
Level 3
Posts: 128
Joined: Mon Jul 22, 2019 12:08 am

Re: [GUIDE] How to hibernate to a swap file in Linux Mint 19.x

Post by lonely_llama »

pebcak wrote: Mon Jun 08, 2020 8:31 am I just wanted to ask if these instructions are applicable to LMDE4 as well
It doesn't matter what desktop environment you use since this has nothing to do with that.
asinoro
Level 6
Level 6
Posts: 1285
Joined: Mon Feb 12, 2018 11:43 am

Re: [GUIDE] How to hibernate to a swap file in Linux Mint 19.x

Post by asinoro »

Of course, hibernation is not advisable on SSD drives since it reduces the life span of the drives with the extra writings.
Moonstone Man
Level 16
Level 16
Posts: 6054
Joined: Mon Aug 27, 2012 10:17 pm

Re: [GUIDE] How to hibernate to a swap file in Linux Mint 19.x

Post by Moonstone Man »

asinoro wrote: Tue Jun 23, 2020 5:33 am Of course, hibernation is not advisable on SSD drives since it reduces the life span of the drives with the extra writings.
Of course, that's an old, outdated idea that no longer applies.
asinoro
Level 6
Level 6
Posts: 1285
Joined: Mon Feb 12, 2018 11:43 am

Re: [GUIDE] How to hibernate to a swap file in Linux Mint 19.x

Post by asinoro »

Kadaitcha Man wrote: Tue Jun 23, 2020 5:38 am
asinoro wrote: Tue Jun 23, 2020 5:33 am Of course, hibernation is not advisable on SSD drives since it reduces the life span of the drives with the extra writings.
Of course, that's an old, outdated idea that no longer applies.
If you say so!
Do NOT enable hibernation
15. Hibernation (suspend-to-disk) causes a huge amount of write actions, which is bad for an SSD. In Linux Mint and Ubuntu, it's disabled by default. Don't enable it! (item 10).
https://easylinuxtipsproject.blogspot.c ... .html#ID15
Moonstone Man
Level 16
Level 16
Posts: 6054
Joined: Mon Aug 27, 2012 10:17 pm

Re: [GUIDE] How to hibernate to a swap file in Linux Mint 19.x

Post by Moonstone Man »

asinoro wrote: Tue Jun 23, 2020 5:43 am
Kadaitcha Man wrote: Tue Jun 23, 2020 5:38 am
asinoro wrote: Tue Jun 23, 2020 5:33 am Of course, hibernation is not advisable on SSD drives since it reduces the life span of the drives with the extra writings.
Of course, that's an old, outdated idea that no longer applies.
If you say so!
I do say so.
Do NOT enable hibernation
15. Hibernation (suspend-to-disk) causes a huge amount of write actions, which is bad for an SSD. In Linux Mint and Ubuntu, it's disabled by default. Don't enable it! (item 10).
https://easylinuxtipsproject.blogspot.c ... .html#ID15
That's just some dude's opinion, and just because some dude said it on the internet it doesn't make it true.
asinoro
Level 6
Level 6
Posts: 1285
Joined: Mon Feb 12, 2018 11:43 am

Re: [GUIDE] How to hibernate to a swap file in Linux Mint 19.x

Post by asinoro »

Kadaitcha Man wrote: Tue Jun 23, 2020 6:17 am
asinoro wrote: Tue Jun 23, 2020 5:43 am
Kadaitcha Man wrote: Tue Jun 23, 2020 5:38 am

Of course, that's an old, outdated idea that no longer applies.
If you say so!
I do say so.
Do NOT enable hibernation
15. Hibernation (suspend-to-disk) causes a huge amount of write actions, which is bad for an SSD. In Linux Mint and Ubuntu, it's disabled by default. Don't enable it! (item 10).
https://easylinuxtipsproject.blogspot.c ... .html#ID15
That's just some dude's opinion, and just because some dude said it on the internet it doesn't make it true.
Let's see what a company advice and not just some dude!
https://www.diskpart.com/ssd-management ... -0528.html
pebcak
Level 4
Level 4
Posts: 222
Joined: Mon Dec 16, 2019 4:59 am

Re: [GUIDE] How to hibernate to a swap file in Linux Mint 19.x

Post by pebcak »

lonely_llama wrote: Tue Jun 23, 2020 5:24 am
pebcak wrote: Mon Jun 08, 2020 8:31 am I just wanted to ask if these instructions are applicable to LMDE4 as well
It doesn't matter what desktop environment you use since this has nothing to do with that.
LMDE4 is not a desktop environment but Linux Mint based on Debian and not like the "mainstream" one based on Ubuntu. My question could then be rephrased to if this method works on Debian.
User avatar
lonely_llama
Level 3
Level 3
Posts: 128
Joined: Mon Jul 22, 2019 12:08 am

Re: [GUIDE] How to hibernate to a swap file in Linux Mint 19.x

Post by lonely_llama »

pebcak wrote: Tue Jun 23, 2020 8:11 am LMDE4 is not a desktop environment but Linux Mint based on Debian and not like the "mainstream" one based on Ubuntu. My question could then be rephrased to if this method works on Debian.
Ah, got it - I had somehow confused that with the MATE edition :)
mauromol
Level 1
Level 1
Posts: 48
Joined: Wed Jul 13, 2011 6:46 am
Location: Pino Torinese (TO) - Italy

Re: [GUIDE] How to hibernate to a swap file in Linux Mint 19.x

Post by mauromol »

Kadaitcha Man wrote: Tue Jun 23, 2020 5:38 am Of course, that's an old, outdated idea that no longer applies.
I perfectly agree with you. Have been hibernating on a SSD for years on my desktop PC at work with neither problems nor any noticeable shortening of disk lifespan at all. These preconceptions coming from the first SSDs of dozen years ago are hard to eradicate.
niko

Re: [GUIDE] How to hibernate to a swap file in Linux Mint 19.x

Post by niko »

am a newbie but thanks so much for this guide

I am using linux to make an HP Stream 11 useful and have tried various distribiutions, I found Mint to be terrific but with a laptop being able to either hibernate or suspend is very useful. So after a week of trying to do that with Mint I gave up, and tried Linuxlite.... then I found your instructions and applied them in LL and they work so might head back to Mint

the main use for the stream 11 is to learn to use linux, as a test bed,

Anyway much kudos to you for your instructions!
slvstr3
Level 1
Level 1
Posts: 23
Joined: Sat Feb 15, 2020 7:20 am

Re: [GUIDE] How to hibernate to a swap file in Linux Mint 19.x

Post by slvstr3 »

slvstr3 wrote: Thu Apr 02, 2020 6:47 am Most complete and clear guide for hibernation. Worked flawlessly (for my Mint 19.3). Thank you so much!
After updating from 19.3 to 20.0, I needed to rerun "5. Adding Hibernate to the shutdown dialog" and it was fully functional again.
Locked

Return to “Tutorials”