- Note: Please read these instructions start to finish beforehand.
- BIOS update / BIOS settings to be changed
- Being sure your hardware states are reported and supported in kernel
- Choosing a proper way to mange sleep functions
- Choosing how to set up your partitioning or swap file
- If you are using a swap partition, you will not be able to use LVM or disk encryption on your root boot disk.
- If you are using a swap file, you can use LVM or disk encryption on your root boot disk.
1 is the easier way to be sure hibernation modes work properly. However, it is not hard to make things work with a swap file, LVM and encryption. It simply requires a few additional steps.
This will command will show the states currently available.
sudo cat /sys/power/state
freeze mem disk
If mem is shown, your mem state will likely be s2idle (hardware).
sudo cat /sys/power/mem_sleep
[s2idle]
If you have disk state available, check your disk states.
sudo cat /sys/power/disk
[platform] shutdown reboot suspend test_resume
Platform will freeze state to disk and allow hardware (BIOS) to take over state. Shutdown will freeze state to disk and shutdown. Reboot will freeze state to disk and reboot. Suspend will freeze state to disk and idle. Test_resume will test disk state is functioning and resume.
Most likely, you will not have disk or freeze state available. If you have chosen to use LVM, Disk Encryption, or have BIOS settings which conflict, the kernel can not set or adjust states of the hardware.
Be sure you are using the most current version of your BIOS, and update it if neccessary.
Check BIOS UEFI and disable Secure Boot and any BIOS lock features. Reboot and check if you see disk states available.
Check BIOS settings to be sure power management features are enabled. Reboot and check if your see disk states available.
Check your fstab:
sudo cat /etc/fstab
If it has a swap entry, check if the swap is enabled. If not, skip ahead to: Configure a blank swap file.
sudo swapon -s
If swap is enabled, disable it.
sudo swapoff -a
Configure a blank swap file. This will reside on your LVM or encrypted root partition. If you have 8GB or 16GB RAM, the standard practice is to double your RAM to get your swap size.
sudo fallocate -l 16G /swapfile
Adjust the permissions of the swapfile.
sudo chown 0 /swapfile
sudo chmod 0600 /swapfile
Allocate the swap file.
sudo mkswap /swapfile
Enable the swap file
sudo swapon /swapfile
Check your new swap is available. It should report /swapfile as the current swap enabled and Type file.
sudo swapon -s
Now that swap is running, add it to your /etc/fstab. If you already have a swap partition or swapfile in your fstab, comment it out and add the new mount point for swap to the end of the file.
/swapfile none swap sw 0 0
To resume, grub bootloader needs to be made aware of the swapfile so it can check as soon as the volume is mounted.
Get the UID of the root partition. Copy this value down.
sudo findmnt / -o UUID
UUID
12345789-1234-1234-1234-123456789098
Obtain the block 0 offset for the location where the swapfile starts on disk.
sudo filefrag -v /swapfile | grep " 0:" | awk '{print $5}'
1234567:
Edit /etc/default/grub to add the swapfile to grub bootloader.
GRUB_CMDLINE_LINUX_DEFAULT="quiet resume=UUID=12345789-1234-1234-1234-123456789098 resume_offset=1234567"
Update grub.
sudo update-grub
Wait for grub to rebuild, then reboot your machine.
Check mem suspend state works. Your machine should go into suspend.
sudo echo "mem" > /sys/power/state
Check disk suspend state works. Your machine should go into full hibernate disk suspend. (This will take a few seconds.)
sudo echo "disk" > /sys/power/state
Configure power management software to your liking. Lid closing. Powerbutton interactions. Sleep on idle etc. There are many options for this.
- acpid
- systemd
- pm-utils
- libsmbios (Dell)
- TLP
- powertop
- xfce4-power-manager
- gnome-power-manager
- powerkit
Be sure that you only have 1 power management daemon running. A common problem is conflicting power management daemons or userspace utilities. Pick one and stick with it. Be sure that the others are removed or completely disabled.