PINE64
Hibernation (suspend to disk) progress - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: Pinebook (https://forum.pine64.org/forumdisplay.php?fid=76)
+--- Forum: Linux on Pinebook (https://forum.pine64.org/forumdisplay.php?fid=79)
+--- Thread: Hibernation (suspend to disk) progress (/showthread.php?tid=8001)



Hibernation (suspend to disk) progress - NoraCodes - 09-25-2019

I have spent the last few days working on getting suspend to disk (hibernate) working, to improve battery life, since suspend to RAM does not improve it that much. I have it working now, with one major caveat. I am doing this on Manjaro ARM but the process should be similar on any OS.

First, it is necessary to create a swapfile using normal techniques. Allocate a swapfile (we'll call it /swapfile), set it as swap, and place an entry for it in /etc/fstab.

Create a 4GB file:
Code:
sudo fallocate -l 4G swapfile

Make it a swapfile, make it private to root, and turn it on:
Code:
sudo mkswap /swapfile
sudo chmod 0600 /swapfile
sudo swapon /swapfile

Then, add it to fstab, with the line "/swapfile swap swap defaults 0 0".

Now we need to add the resume hook to the initcpio. In /etc/mkinitcpio.conf, change the HOOKS line to include the hook resume:


Code:
HOOKS=(base udev autodetect modconf block resume filesystems keyboard fsck)

Now we need to edit the kernel's command line to include the resume target. First we need the UUID and the offset of the file.

Get the UUID with

Code:
sudo findmnt -no SOURCE,UUID -T /swapfile
And the offset by looking at the first row of sudo filefrag -e /swapfile, looking at the first column marked physical_offset. This tells the kernel where on the given block device to look.

These values need to be put into the kernel command line in /boot/boot.txt like so:


Code:
# Original line
setenv bootargs console=${console} console=tty0 root=PARTUUID=${uuid} rw rootwait
# New line
setenv bootargs console=${console} console=tty0 root=PARTUUID=${uuid} rw rootwait resume=UUID=29a4df6e-1531-4e1b-be79-82bd21f849ff resume_offset=2727936
Then you need to generate a new uboot script by running sudo /boot/mkscr followed by sudo mkinitcpio -P to regenerate the modified initcpio.

Now the machine will hibernate and resume! Try it with systemctl hibernate.

HOWEVER. In my case, when the system resumes, the screen image is as expected, but the screens brightness is at minimum and neither the keyboard or the trackpad work. I have to hard power off the machine and reboot.

If we can solve this problem, Pinebook can have working suspend-to-disk!


RE: Hibernation (suspend to disk) progress - tophneal - 09-25-2019

Awesome stuff! I've neglected Manjaro on my PB lately, just bc it doesn't suspend and eats up the battery. Have you shared this on the Manjaro forums as well? I'm sure Strit or one of the other devs would take interest in your write up.


RE: Hibernation (suspend to disk) progress - NoraCodes - 09-26-2019

(09-25-2019, 12:24 PM)tophneal Wrote: Awesome stuff! I've neglected Manjaro on my PB lately, just bc it doesn't suspend and eats up the battery. Have you shared this on the Manjaro forums as well? I'm sure Strit or one of the other devs would take interest in your write up.

Thanks! Just posted there, hopefully I'll get some useful responses. It seems like I'm just missing a configuration setting or something but I'm totally at a loss as to what it might be.


RE: Hibernation (suspend to disk) progress - tophneal - 09-26-2019

(09-26-2019, 10:50 AM)LeoLambda Wrote:
(09-25-2019, 12:24 PM)tophneal Wrote: Awesome stuff! I've neglected Manjaro on my PB lately, just bc it doesn't suspend and eats up the battery. Have you shared this on the Manjaro forums as well? I'm sure Strit or one of the other devs would take interest in your write up.

Thanks! Just posted there, hopefully I'll get some useful responses. It seems like I'm just missing a configuration setting or something but I'm totally at a loss as to what it might be.

Hopefully! I'd love to see your work included within one of the next updates