Score:1

How could I enable hibernation on a Dell Inspiron 5548 running ubuntu focal?

cn flag

I'm running Ubuntu Focal and I have 15gigs of Ram and 20G of swap space.

Partition: ID-1: / size: 437.52 GiB used: 47.14 GiB (10.8%) fs: ext4 dev: /dev/sda5 
       ID-2: swap-1 size: 19.53 GiB used: 0 KiB (0.0%) fs: swap dev: /dev/sda6 

I've tried adding acpi=noirq to my grub boot options but it didn't work and it ended up disabling my keyboard.

When I type sudo pm-hibernate and turn the computer back on it starts up normally.

Is there something else I could try?

Score:1
cn flag

To enable Hibernation in 20.04 using swapfile:

Confirm swapfile size matches RAM size

  • Check the swap that is in use:

    sudo swapon -s
    
  • If swap partition(s) are found:

    sudo swapoff -a
    sudo nano -Bw /etc/fstab
    
  • Add # before the UUID of the swap partition(s):

    # UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX   none   swap    sw     0       0
    
  • Add a line for the swapfile, if one does not exist:

    /swapfile   none    swap     sw      0       0
    
  • Create the swapfile:

    sudo fallocate -l XG /swapfile*
    

    where X is swapfile's 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-grub
    
  • Test hibernation:

    sudo systemctl hibernate
    

A hibernate button can be added using GNOME extensions.

Note that 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 swap file 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.

cn flag
I was using a swap partition. The piece of the puzzle I was missing was "resume=UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" in the Kernel options in the grub config.
C.S.Cameron avatar
cn flag
@Frank Barcenas: Thank you for letting us know. I should probably change the instructions to allow for either swap partition or swapfile.
evilSnobu avatar
tr flag
This guy hibernates. Scratched my head for weeks trying to make hibernation work on my Thinkpad, landed here and got it working in 4 minutes. This is the way.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.