Hibernation, Ubuntu & Battery Life


Intro 👋

I’ve been playing quite a bit with my new (old) laptop, a Dell Latitude 7490. Great laptop for sure. Feel like a ThinkPad, great 1080p screen, decent battery life, i7, 16gb ram, but I digress. I would often pick up and put down what I was working on throughout the day, but not having to reopen everything each time I decide to boot back up. After much digging I discovered that while my laptop supported S3 sleep, hibernation was no where to be found. I also had been struggling with getting a decently long amount of usage out of the refurbished battery it came with.

Hibernation 🛏️

I’m not 100% sure if this impacts anyone running other distribution’s, but at least for me running Ubuntu MATE 22.04 LTS, the hibernation option is missing. This might also be related to having a custom data partition using BTRFS (which is AMAZING BTW).

I did some digging around Google and realized that there were TWO things that I needed to do to fix my problem.

How to

Step 1:

Edit the following file and add the below and reboot.

/var/lib/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla

[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

This would enable the menu option, but when I tried it, I would get a blank desktop. To fix this, you need to do a small edit to the GRUB boot loader.

Step 2:

Look up the UUID of your swap partition

cat /etc/fstab | grep swap
# swap was on /dev/sda2 during installation
UUID=92cd717b-83f8-4aab-beb9-3cd7a84f9224 none            swap    sw              0       0

Step 3:

  • Edit your /etc/default/grub file

  • ADD the follow to your resume=UUID=XXXXXXXXXXXXXXXXX replacing the value here with the value you found from above

Example

GRUB_DEFAULT="0"
GRUB_TIMEOUT_STYLE="hidden"
GRUB_TIMEOUT="5"
GRUB_DISTRIBUTOR="`lsb_release -i -s 2> /dev/null || echo Debian`"
GRUB_CMDLINE_LINUX_DEFAULT="resume=UUID=92cd717b-83f8-4aab-beb9-3cd7a84f9224"
GRUB_CMDLINE_LINUX=""

Step 4:

Run sudo update-grub and REBOOT!

Step 5:

Profit!

Hibernate WIN

Sleep states 💻

In addition to the benefits of enabling hibernation, I would also recommend you check out both TLP (

TLP has some great auto tune options to help you get he best battery life you can out of your laptop. PowerTOP replicates quite a few of the tweaks in TLP, but also gives you some handy stats as well. I would say to try to not use them both at the same time, as the have slightly different ideas on what settings to tweak.

If your having issues, also be sure to check to see what sleep states your laptop supports via sudo dmesg | grep 'S3\|suspend' and cat /sys/power/mem_sleep

You can also get a quick look into how your battery health is looking via upower -i /org/freedesktop/UPower/devices/battery_BAT0 or if you really want to see all the nuts and bolts upower --dump

Some useful background info on different power states:

Running a calibrate with PowerTOP should give you a good estimate of how long your battery SHOULD last.

powertop --calibrate

If you find that your laptop is not sleeping properly, I would dig through your BIOS settings to make sure that sleep is enabled. Also updating your BIOS can helps as well, but that’s outside the scope of this article :wink:!

- As always, if anyone has any corrections or comments, feel free to message here or drop me a email.

☮️


Prev
Your tools don't matter
Your tools don't matter
Next
ADHD, Productivity and Time Management
ADHD, Productivity and Time Management

Comments




Kudos:

@ Feed 📰 @ Mast 🐘