This might be of some use for insight and troubleshooting:
It's also important to note that hibernation in Ubuntu is disabled because there are issues with it on some computers, so it might not work for everyone
@stephenbbb you can shutdown a system with sudo poweroff but I guess you don't want to do that. You want your system to hibernate and later wake up.
My suggestion is 1) send a message to syslog that you're going to sleep (logger "Zzzz ... going to sleep now ..."), 2) open syslog (tail -f /var/log/syslog) and look at the messages.
this is the direction I want to go. please, provide more detail. do I send the message and then try to hibernate? or you just want to check if logging works? is there a brief reference to working with the logs?
You could use WOL (wake-on-LAN). You need to enable this in the system's BIOS (in the network settings), then you send a magic packet to wake up the system. It works in a LAN env. To wake up your system from across the Globe is far more complicated. This article may help. https://www.cyberciti.biz/tips/linux-send-wake-on-lan-wol-magic-packets.html
I can get the log from trying pm-hibernate.
are there people who can debug that? it is quite long.
sudo poweroff works and shuts down, but hibernate goes into black screen without ever shutting down.
I am ready to post the log if there are volunteers.
Muchachos,
I have some bad news to report here. The code for hibernation is not being developed/debugged any more. there was a pm-utils developer group, but the last posts in the newsgroup are from 2017. I found threads with same complaint like mine that did not get resolved. Looks like the Linux kernel can hibernate on some hardware, but not on many. So, I am unlucky with that laptop.
#!/bin/bash
if [[ $UID != 0 ]]; then
echo "Only tested on Ubuntu MATE 21.10"
echo "Please run this script with sudo or root privileges to enable hibernate"
echo "sudo $0 $*"
exit 1
else
echo "Enable hibernate on system, calculate swap file size"
#Change this value to size the swapfile X times your ram
SWAP_FILE_FACTOR=1.3
#Compute ideal size of swap ( Mem size * 1.5 )
SWAP_FILE_SIZE=$(echo "$(cat /proc/meminfo | grep MemTotal | grep -oh '[0-9]*') * $SWAP_FILE_FACTOR" | bc -l | awk '{print int($1)}')
echo "SWAP_FILE_SIZE will be $SWAP_FILE_SIZE bytes"
echo "Creating new swapfile, please wait, this may take a few minutes."
swapoff /swapfile
dd if=/dev/zero of=/swapfile bs="$SWAP_FILE_SIZE" count=1024 conv=notrunc
mkswap /swapfile
swapon /swapfile
# Get UUID & swap_offset
ROOT_UUID=$(findmnt -no SOURCE,UUID -T /swapfile |cut -d\ -f 2)
echo ROOT_UUID = "$ROOT_UUID"
SWAP_FILE_OFFSET=$(filefrag -v /swapfile | awk '{print $4}' | head -4 | tail -1 | cut -d'.' -f1)
echo SWAP_FILE_OFFSET = "$SWAP_FILE_OFFSET"
echo "Modify initramfs"
echo "RESUME=UUID=$ROOT_UUID resume_offset=$SWAP_FILE_OFFSET" | tee /etc/initramfs-tools/conf.d/resume
echo "Update initramfs"
update-initramfs -k all -u
echo "Update Grub config"
#TODO Test if grub was already containing the string
#if [[ grep -q "resume" ]]
GRUB_STRING="resume=UUID=$ROOT_UUID resume_offset=$SWAP_FILE_OFFSET"
sed -i '/^GRUB_CMDLINE_LINUX_DEFAULT=/ s|"\(.*\)"|"\1 '"${GRUB_STRING}"'"|' /etc/default/grub
update-grub
echo "Update MATE policy kit"
tee /etc/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla <<EOF
[Enable hibernate in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes
[Enable hibernate in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.handle-hibernate-key;org.freedesktop.login1;org.freedesktop.login1.hibernate-multiple-sessions;org.freedesktop.login1.hibernate-ignore-inhibit
ResultActive=yes
EOF
echo "Setting hibernate delay after suspend at 1h in /etc/systemd/sleep.conf "
echo "HibernateDelaySec=3600" | tee -a /etc/systemd/sleep.conf
echo "setting sleep-then-hibernate on lid close in /etc/systemd/logind.conf "
echo "HandleSuspendKey=suspend-then-hibernate" | tee -a /etc/systemd/logind.conf
echo "HandleLidSwitch=suspend-then-hibernate" | tee -a /etc/systemd/logind.conf
echo "Hibernate now active, configuration complete"
fi