I searched this online but all articles found are outdated. What should I do to enable hibernation in GNOME?
1 Answers
To enable Hibernation in 20.04:
Increase swapfile size to match RAM size up to 8GB.
Check the swap that is in use:
sudo swapon -sIf swap partition(s) found:
sudo swapoff -asudo nano -Bw /etc/fstabAdd "# " before the UUID of the swap partition(s):
# UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX none swap sw 0 0Add a line for the swapfile, if one does not exist:
swapfile none swap sw 0 0Create the swap file:
sudo fallocate -l XG /swapfile*
Where X is the swapfile size in GB
sudo mkswap /swapfile
sudo chmod 0600 /swapfile
sudo swapon /swapfile
Reboot:
sudo reboot
Add resume location and offset to grub.cfg:
- Edit /etc/default/grub:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX resume_offset=XXXXX"
Use UUID from root.
Use offset from
sudo filefrag -v /swapfile |grep " 0:"| awk '{print $4}'Update GRUB
sudo update-grubTest hibernation
sudo systemctl hibernate
A hibernate button can be added using gnome extensions. https://extensions.gnome.org/extension/755/hibernate-status-button/
*There is a slight possibility of getting holes in a swapfile when creating it with fallocate. /var/log/syslog can be searched for the phrase swapon: swapfile has holes to ensure there will be no data loss.
A swapfile can alternatively be created using dd: sudo dd if=/dev/zero of=/swapfile bs=1G count=8 An error when using dd may overwrite your HDD
- 18,890
- 10
- 64
- 105
-
Can I resize the swap partition instead of using a swap file? – NinePlusTenEqualsTwentyOne Oct 20 '20 at 07:39
-
for grub cfg, can I use my ESP as I am booting with UEFI? – NinePlusTenEqualsTwentyOne Oct 20 '20 at 07:40
-
can I delete the swap partition? – NinePlusTenEqualsTwentyOne Oct 20 '20 at 07:41
-
@NinePlusTenEqualsTwentyOne Yes, you can resize your swap partition instead of using a swap file, or delete it or use both a swapfile and swap partition. 20.04 makes it's own swapfile, (you may already be using both). Add UUID and offset to your grub.cfg it will find it's way to a UEFI boot. – C.S.Cameron Oct 20 '20 at 09:14
-
how do you resize a LVM partition? – NinePlusTenEqualsTwentyOne Oct 21 '20 at 04:53
-
With LVM I have only managed to resize my swapfile. People have told me that it is easy to resize a LVM partition, but they have never explained how, at least not so I could understand. – C.S.Cameron Oct 21 '20 at 05:06
-
`chown` is wrong. it must be chmod. – pouria Jan 03 '21 at 07:45
-
@pooria: I tested the above quite a few times and could have sworn chown worked for me, but I must have been typing chmod.as that seems to be the normal method, Thanks above has been edited. – C.S.Cameron Jan 03 '21 at 10:11
-
That answer enables hibernation from the OS. What about the Gnome menu? – Hiran Chaudhuri Feb 07 '22 at 08:12
-
@Hiran Chaudhuri, You can add a hibernation button using **Gnome-Extensions** – C.S.Cameron Feb 07 '22 at 16:46
-
From my POV this should be part of the answer, as it was part of the question as well. But I will search how to install gnome extensions (and actually the right one) via command line somehow. – Hiran Chaudhuri Feb 07 '22 at 19:50
-
@Hiran Chaudhuri; Thank you, I have added a link to Gnome-Hibernate Status Button. https://extensions.gnome.org/extension/755/hibernate-status-button/ – C.S.Cameron Feb 10 '22 at 00:36