I can't make my Ubuntu 18.04 hibernate (I tried use both swap file and swap partion, nothing works)
As the title suggest.
I've already tried sudo pm-hibernate
, sudo systemctl hibernate
, sudo s2disk
all of them did nothing and just freeze on input in the terminal, except sudo systemctl hibernate
which seems to shutdown the system instantly but fail to resume after start the machine back up again.
I had 8 Gb RAM, 9 Gb Swap partition, when I first tried and I've already added resume
parameter in /etc/default/grub
. And failed after I tried to hibernate as I described above.
After that I tried use swap file instead of swap partition to hibernate by creating a 5 Gb swap file (I heard that I only need at least half the size of my RAM) and then add the parameter resume_offset
to the GRUB_CMDLINE_LINUX_DEFAULT
the same way as I did with resume
.
I also add the following to /etc/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
and also edit the following (changing from yes
to no
in the ResultActive
both section) in /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla
:
[Disable hibernate by default in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=no
[Disable hibernate by default 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=no
Note that when I use sudo pm-hibernate
I only have pm-utils
installed.
And when I used sudo s2disk
I uninstall pm-utils
before reinstall uswsusp
then run the command like this
sudo dpkg-reconfigure -pmedium uswsusp
before sudo s2disk
and then again nothings happened
what did I do wrong? I don't know what else I should try.
Solution 1:
Look at your /etc/initramfs-tools/conf.d/resume
file. It should contain the UUID of your swap partition, like so:
RESUME=UUID=071f8b0e-8e16-4f4d-90ff-a4ae9cc56e2b
# use your own correct UUID
To identify the correct UUID to use:
sudo blkid
# to display your UUIDs
Look for a line similar to this:
/dev/sda8: UUID="071f8b0e-8e16-4f4d-90ff-a4ae9cc56e2b" TYPE="swap" PARTUUID="d042d9f3-dfe7-4ba9-bbc8-efe6413e7fa4"
# your UUID will be different
Then perform:
sudo update-initramfs -c
# to create a fresh initramfs image file
reboot
# to reboot the computer
Now retest hibernate.