Hibernation allows your Linux computer to save the current session to disk and completely power off, consuming zero energy. When the system is powered back on, it resumes your previous session, including open apps, documents, and settings.
This guide explains how to enable hibernation using a swap file (common in modern Ubuntu installations) rather than a dedicated swap partition.
Hibernation, or "suspend to disk," saves the contents of your RAM to disk and turns the system off. This differs from "suspend to RAM" (sleep), which keeps memory powered but uses more energy.
Before enabling hibernation, determine how much RAM your system has, as the swap file must be at least equal in size.
bash
CopyEdit
free -h
Make note of the "Mem" total. This is your RAM size.
If your system doesn’t already have a swap file large enough to match your RAM, create or resize it:
bash
CopyEdit
sudo swapoff -a
sudo rm /swapfile # optional: delete existing file
sudo fallocate -l 8G /swapfile # adjust size to match your RAM
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
Replace 8G with the actual size of your RAM.
Add the new swap file entry to the system’s filesystem table so it persists after reboot:
bash
CopyEdit
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
Two values are needed: the UUID of the partition containing the swap file and the swap file’s offset on disk.
bash
CopyEdit
findmnt -no UUID -T /swapfile
Copy the UUID string.
bash
CopyEdit
sudo filefrag -v /swapfile | grep -m1 "^ " | awk '{print $4}' | sed 's/\..*//'
Copy the numeric offset shown.
Edit the GRUB configuration file to include the resume information:
bash
CopyEdit
sudo nano /etc/default/grub
Find the line starting with:
text
CopyEdit
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
Update it as follows:
text
CopyEdit
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=your-uuid resume_offset=your-offset"
Replace your-uuid and your-offset with the values from step 4.
Save and close the file. Then apply the changes:
bash
CopyEdit
sudo update-grub
sudo update-initramfs -u
Close any unsaved work and run:
bash
CopyEdit
sudo systemctl hibernate
Your system should shut down completely. Upon restart, your previous session should be restored exactly as it was.
To add the hibernate option to graphical menus in environments like GNOME, create a policy rule.
bash
CopyEdit
sudo nano /etc/polkit-1/rules.d/10-enable-hibernate.rules
Paste the following:
javascript
CopyEdit
polkit.addRule(function(action, subject) {
if (action.id == "org.freedesktop.login1.hibernate" ||
action.id == "org.freedesktop.login1.hibernate-multiple-sessions" ||
action.id == "org.freedesktop.upower.hibernate" ||
action.id == "org.freedesktop.login1.handle-hibernate-key" ||
action.id == "org.freedesktop.login1.hibernate-ignore-inhibit")
{
return polkit.Result.YES;
}
});
Save and reboot the system:
bash
CopyEdit
sudo reboot
After rebooting, "Hibernate" should now appear in the system’s shutdown or power menu.
Issue
Solution
Hibernate does not restore session:
Recheck UUID and offset values in GRUB configuration
Hibernate option missing in GUI:
Verify the PolicyKit rule was saved correctly
Swap file too small:
Recreate it using fallocate with the correct size
Secure Boot is enabled:
Temporarily disable Secure Boot in BIOS if needed
Dual-boot with Windows:
Disable Windows Fast Startup to avoid boot conflicts
Run this command to verify:
bash
CopyEdit
cat /sys/power/state
If the output includes disk, your system supports hibernation.
Once set up, hibernation provides:
With the steps above, you now have full hibernation support configured on your Debian or Ubuntu-based system.
If you’re still having trouble, consider reaching out to Support.Com for a personalized solution to all technical support issues.