Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Getting hibernation to work?

  1. #1
    Join Date
    Oct 2013
    Beans
    83

    Getting hibernation to work?

    Esp. with new laptops that won't enter a deep sleep state and expect Windows hybrid sleep or drain the battery extensively on 'sleep', it would be really handy to be able to get hibernation to work.

    So I'm wondering if people have had success getting hibernation to work? If so, how was your system set up? I'm guessing that partition encryption, secure boot, swap size, kernel lockdown features, and possibly lvm are all obstacles. Did someone find some ways to get around these problems? Is swap at 1-1.5 times RAM actually sufficient (hibernation has to store RAM + swap)? Is it possible to have secureboot activated and still hibernate?

  2. #2
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Getting hibernation to work?

    I don't use hibernation due to well known security issues with it. I use standby daily, but if the system is being moved out of a building, it is shutdown completely for security reasons.

    Standby works with LUKs encryption and LVM. I'm 100% positive. That's how I use it. I don't have sufficient swap to hibernate. I use swap partitions (actually it is an LV), not swapfiles.

    Also, I don't use secureboot. When I'm traveling to less-trustworthy parts of the world, I boot from a flash drive that is always on my body. I ignore the /boot/ on the system. Look up evil-maid attack for why.

  3. #3
    Join Date
    Oct 2013
    Beans
    83

    Re: Getting hibernation to work?

    Thanks TheFu! Yup, using a flash drive in insecure parts of the world makes a lot of sense--thanks for the idea. Standby works fine for me as well, at least on my desktop. But, as I mentioned, I have a laptop that won't go into deep sleep, so it burns almost as much battery suspended as it does while I'm using it. Windows handles this with hybrid suspend--it suspends to idle, not deep sleep, for 10 minutes and then goes into hibernate. And, even on my desktop, it would be nice to be able to hibernate so I can always get back to exactly where I was, even if I'm out of town for a while, and without using power that might itself be unreliable.

  4. #4
    Join Date
    Sep 2022
    Beans
    Hidden!
    Distro
    Lubuntu 20.04 Focal Fossa

    Re: Getting hibernation to work?

    Getting Hibernate to work takes quite some effort.
    My laptops hibernate fine, but only with a swap partition >10% larger than RAM size. I've never been able to get it to work with a swapfile.

  5. #5
    Join Date
    Oct 2013
    Beans
    83

    Re: Getting hibernation to work?

    Thanks ne29914, good to hear it's possible! Also the info on swap size is helpful. What took effort?

  6. #6
    Join Date
    Sep 2022
    Beans
    Hidden!
    Distro
    Lubuntu 20.04 Focal Fossa

    Re: Getting hibernation to work?

    Quote Originally Posted by Peter_Brandon View Post
    What took effort?
    Well, first you need to create a swap partition. Let's say /dev/sda6 for this example.
    Run:
    Code:
    sudo mkswap /dev/sda6
    sudo swapon /dev/sda6
    blkid
    (you may get an error on the first command if /dev/sda6 is already a swap partition. It's unimportant).
    Note the UUID of /dev/sda6. in this case (as an example): 123456-7890-abcd-ef12-34567890abcd
    Check that this file:
    Code:
    /etc/fstab
    contains:
    Code:
    UUID=123456-7890-abcd-ef12-34567890abcd none swap defaults 0 2
    If not, reboot and check again.

    Modify/create:
    Code:
    /etc/initramfs-tools/conf.d/resume
    to contain:
    Code:
    RESUME=UUID=123456-7890-abcd-ef12-34567890abcd
    Modify:
    Code:
    /etc/default/grub
    To contain:
    Code:
    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=123456-7890-abcd-ef12-34567890abcd"
    GRUB_RECORDFAIL_TIMEOUT=$GRUB_TIMEOUT
    Modify/create:
    Code:
    /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
    To contain:
    Code:
    [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
    Run:
    Code:
    sudo update-grub
    sudo update-initramfs -u
    Reboot.

    It should now work, lid switch, timeout, battery-level trigger etc. you'll have to set yourself.

  7. #7
    Join Date
    Oct 2013
    Beans
    83

    Re: Getting hibernation to work?

    That's immensely helpful ne29914! Will have to give it a try. One question though: do you have encrypted partitions? I was under the impression that if you encrypt /home, you also end up encrypting swap and that swap uses a randomly generated encryption key each time you boot. So if you hibernate, that would likely mean that the system can't read the swap file when you restart. Or?

  8. #8
    Join Date
    Sep 2022
    Beans
    Hidden!
    Distro
    Lubuntu 20.04 Focal Fossa

    Re: Getting hibernation to work?

    I can't say, I don't use encryption. But as swap is on a separate partition, I don't see how /home could influence it. But I could be wrong.

  9. #9
    Join Date
    Oct 2013
    Beans
    83

    Re: Getting hibernation to work?

    Thanks for the info! My mistake--I meant if you encrypt root (typically with home in it), the default for swap is to be encrypted as well. If someone thinks root / home aren't safe, the swap isn't either.

  10. #10
    Join Date
    Sep 2022
    Beans
    Hidden!
    Distro
    Lubuntu 20.04 Focal Fossa

    Re: Getting hibernation to work?

    I never set up a machine like that. I always have separate partitions for /, /home and swap.
    In that case, encrypting root makes no sense, the OS is not secret.
    If you're operating with just /, this whole discussion is pointless.

    EDIT: this is what I mean:
    Code:
    macro@macro6910p:~$ lsblk
    NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
    sda      8:0    0 465,8G  0 disk 
    ├─sda1   8:1    0  29,3G  0 part /
    ├─sda2   8:2    0   5,9G  0 part [SWAP]
    └─sda3   8:3    0 430,6G  0 part /home
    sr0     11:0    1  1024M  0 rom
    Last edited by ne29914; September 12th, 2022 at 07:47 PM.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •