Aller au contenu principal
Image d'illustration pour l'article "Enable Hibernate on Ubuntu: A Step-by-Step Guide" par Kevin Otty, développeur web et mobile
Ubuntu System Administration Power Management

Enable Hibernate on Ubuntu: A Step-by-Step Guide

Learn how to enable and configure hibernation on Ubuntu with this comprehensive guide. Follow step-by-step instructions to set up hibernation properly.

K
Lecture : 2 min Ubuntu, System Administration, Power Management

Enable Hibernate on Ubuntu: A Step-by-Step Guide

1. Check Secure Boot Status

Before proceeding, ensure Secure Boot is disabled. Run:

mokutil --sb-state

If the output shows SecureBoot enabled, disable it in your BIOS settings.


2. Verify Hibernation Support

Open a terminal and check if your system supports hibernation:

cat /sys/power/state

Expected output:

freeze mem disk

If disk is present, your kernel supports hibernation. Test it with:

sudo systemctl hibernate

Your system should power off and restore upon boot.


3. Ensure Adequate Swap Space

Your swap should be at least the size of your RAM. Check RAM and swap size:

free -h

Verify swap partition or file:

swapon --show

If no swap exists, create one.


4. Check Disk Space

Install and run gparted:

sudo apt install gparted
sudo gparted

Select /dev/sda and examine partitions for available space.


5. Resize Partition (If Needed)

If you need space for swap, shrink a partition like /dev/sda7:

df -h /

Use gparted to resize it. Backup your data before proceeding.


6. Create a Swap Partition

In gparted, create a new partition:

  • Set size (e.g., 32 GB).
  • Choose linux-swap as the type.
  • Apply changes.
  • Note the new partition's device name (e.g., /dev/sda8).

7. Configure Swap

Format and activate the swap partition:

sudo mkswap /dev/sda8
sudo swapon /dev/sda8

Get the UUID of the swap partition:

sudo blkid /dev/sda8

Edit /etc/fstab:

sudo nano /etc/fstab

Replace the /swapfile entry with:

UUID=your_swap_uuid none swap sw 0 0

Then remove the old swap file:

sudo swapoff /swapfile
sudo rm /swapfile

8. Configure GRUB for Hibernate

Edit GRUB:

sudo nano /etc/default/grub

Modify this line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=YOUR-SWAP-UUID"

Update GRUB:

sudo update-grub

Also, update initramfs:

echo "RESUME=UUID=YOUR-SWAP-UUID" | sudo tee /etc/initramfs-tools/conf.d/resume
sudo update-initramfs -u

9. Enable Hibernate in PolicyKit

Create necessary directories:

sudo mkdir -p /etc/polkit-1/localauthority/10-vendor.d

Edit the PolicyKit configuration:

sudo nano /etc/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla

Add the following:

[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;org.freedesktop.login1.handle-hibernate-key;org.freedesktop.login1;org.freedesktop.login1.hibernate-multiple-sessions;org.freedesktop.login1.hibernate-ignore-inhibit
ResultActive=yes

Also, create another rules file:

sudo nano /etc/polkit-1/rules.d/10-enable-hibernate.rules

Add:

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;
    }
});

10. Test Hibernate

Reboot and verify hibernation:

sudo systemctl hibernate

If everything works, your system should restore after powering back on.


This guide will be great for your blog! Let me know if you need further refinements. 🚀

Tags de l'article

#Ubuntu #System Administration #Power Management
K

KEVIN OTTY

Développeur Web & Mobile

Développeur Web & Mobile titulaire d'une licence en systèmes informatiques et logiciels. Passionné par l'innovation technologique, il cherche à mettre ses compétences techniques au service de projets concrets pour contribuer à la croissance des entreprises.

Articles similaires

Découvrez d'autres articles qui pourraient vous intéresser

Image d'illustration pour l'article "Trying Hackintosh on my HP ProBook 640 G5"
Hackintosh
7 mai 2025

Trying Hackintosh on my HP ProBook 640 G5

A step-by-step guide to installing macOS on an HP ProBook 640 G5 with Intel Core i5-8365U and UHD 620 graphics, including BIOS configuration, EFI setup, and troubleshooting tips.

#macOS #HP ProBook +2 autres
Lire l'article
Image d'illustration pour l'article "Top 7 des Meilleurs Sites Gratuits de Face Swap en 2025"
AI
26 avril 2025

Top 7 des Meilleurs Sites Gratuits de Face Swap en 2025

Découvrez les meilleurs outils gratuits pour échanger des visages sur photos et vidéos. Comparaison détaillée des 7 plateformes les plus performantes pour créer du contenu amusant et viral.

#Face Swap #Outils +1 autres
Lire l'article

Restez informé

Recevez une notification lors de la publication de nouveaux articles

Nous respectons votre vie privée. Désabonnement possible à tout moment.