Hibernate your laptop (Fedora 25)

You can hibernate your laptop for faster boot next time. Hibernate is suspending to disk , so you'll need swap partition. I dont use suspend to RAM because it sucks battery. Follow these steps to make hibernate work using Fedora 25/24:

Create swap partition or logical volume (LV)

Common size for hibernating:
RAM 8 GB  create 12 GB swap
RAM 4 GB  create 8 GB swap
RAM 2 GB  create 4 GB swap

Format swap partition

Check new created swap using lsblk -p

For example:
mkswap /dev/mapper/VG-Swap

Add swap to fstab

/dev/mapper/VG-Swap            swap            swap    defaults  0  0

Activate and check

swapon -a

swapon --show     #or swapon -s

Recreate initramfs

dracut --force

Edit grub cmdline

dracut --print-cmdline

will print recommended GRUB_CMDLINE_LINUX

Add resume= and rd.lvm.lv= lines to /etc/default/grub (GRUB_CMDLINE_LINUX=)

For example:

GRUB_CMDLINE_LINUX="rd.lvm.lv=VG/Swap rd.lvm.lv=VG/Fedora24-root resume=/dev/mapper/VG-Swap root=/dev/mapper/VG-Fedora24--root rootfstype=ext4 rootflags=rw,noatime,nodiratime,lazytime,seclabel,data=ordered"

Regenerate grub.cfg

grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

Install gnome extension and change gnome Power Settings

Install Hibernate Status Button by p91paul

Open Settings - Power, When Power button is pressed: Hibernate

Edit logind

vim /etc/systemd/logind.conf


HandleLidSwitch=hibernate (I use HandleLidSwitch=poweroff to avoid rapid suspend resume when battery low)

Edit image_size to hibernate faster:

vim /etc/rc.d/rc.local
# in bytes, my RAM is 8GB
echo 8000000000 > /sys/power/image_size

chmod +x /etc/rc.d/rc.local

Reboot once, check if resume= is correct and swap is enabled

cat /proc/cmdline

swapon --show         #or swapon -s

Try to hibernate and resume

When hibernating wait until led is not flashing (on my Thinkpad)
When resuming, your previous running application will be restored

To run command before hibernate:

touch /usr/lib/systemd/system-sleep/sleep.sh
chmod +x /usr/lib/systemd/system-sleep/sleep.sh
vim /usr/lib/systemd/system-sleep/sleep.sh

if [ "$1X" = "preX" ];  then
    if [ "$2X" = "hibernateX" ];  then
        systemctl stop httpd postgresql mariadb
        killall -r wineserver
        killall -r .exe
        killall firefox
        killall chrome
        killall steam
        #killall soffice.bin
        killall java
        #killall dropbox
        killall evolution
        sleep 2
        killall -HUP steam
        sleep 1   


Popular posts from this blog

Tips Jika Mobil Anda Habis Bensin LOL!

Setting open office u label tom & jerry