Cannot resume from "hibernate"

6 risposte [Ultimo contenuto]
Avron

I am a translator!

Offline
Iscritto: 08/18/2020

I reinstalled Trisquel using the main installer in text mode and selected "use whole disk with LVM and encryption option" and the installer proceeded without further options. It is on an x200 with latest stable Libreboot from this month.

It made

  • a boot partition
  • a space for encyption containing a logical volume group with
    • root in a logical volume (no separate home)
    • swap in a logical volume (less than 1GB)

Although I was happy it worked, I was disappointed not to have the separate logical volume for home and that the swap is mch smaller than the memory (4GB) I won't be able to use hibernate.

Therefore, running on a live USB, I

  • resized the root logical volume to 80 GB ('lvresize -r' nicely shrinks the ext4 fs)
  • extended the swap volume to 4G and ran mkswap (I don't know another way)
  • created a logical volume with an ext4 fs for home
  • added it to /etc/fstab
  • removed /home from the root fs
  • rebooted

It seemed to work fine but in the update after I added backports, I noticed that cryptsetup complained before update-initramfs that it couldn't find the fs with a certain UUID in order to resume. I suppose it is the swap. I searched and found that I need to put the UUID of the swap in /etc/initramfs-tools/conf.d/resume so I did that (got it from blkid) and ran 'sudo update-initramfs -u'.

However, after I hibernate, the computer starts as if I had not hibernated. How to correct that?

Besides, I wonder why the installer allocated far less space for swap than the computer memory.

eric23
Offline
Iscritto: 06/30/2017

I thought one could not do hibernate with swap, but it maybe possible with some problems using the below page. Searching through the forums I did not see a solution but saw indication that it is possible.

The risks sounds like you could lose your unsaved information should it not work correctly. So be sure to test it out without important unsaved documents. Also, save your documents before hibernating even if you think it works.

I don't know if this makes your swap partition more or less secure having a passphrase on swap. I think that the Ubuntu version wants an encrypted swap partition and not in the logical volume.

This page claims that it was able to get it working on another distribution based on Ubuntu 20.04. So maybe it will work for you?

https://help.ubuntu.com/community/EnableHibernateWithEncryptedSwap

Avron

I am a translator!

Offline
Iscritto: 08/18/2020

I have another computer (x201i) with 2016 stable Libreboot and a single encrypted volume including everything (only possible because Grub2 is in the bootrom), I installed it with the Trisquel 9 net installer. On that computer, I allocated the swap size to the memory size and I can hibernate and resume fine, and everything is encrypted.

I also have a t400 with osboot (it came so, I plan to replace it with Libreboot 2022 stable). Initially, I tried doing the same with the Trisquel 10 installer but after installation, grub2 fails to decrypt the disk, perhaps becausee the Trisquel 10 installer uses LUKS2 with Key Derivation Function not supported by Grub2 (Argon2).

Then I did an encrypted install with Trisquel 10 installer in graphic mode (but I can't remember the options I selected), for some reason the Trisquel installer allocated 4GB to swap while I have 8GB memory. I noticed that sometimes the hibernate option is there, sometimes it is not, and then, if I quit a number of apps, it comes back, and resume always worked. Since swap is in the encrypted space, it is encrypted.

This is why I find the link you posted rather strange: it proposes a complicated method to do what is normally possible by default. If I had the correct swap size, I would not have had to do any tinkering by which I broke what should normally be working.

prospero
Offline
Iscritto: 05/20/2022

> after I hibernate, the computer starts as if I had not hibernated.

Same behavior here with an up-to-date version of Trisquel 9 with 8 GiB RAM and 10 GiB Swap.

I just realized that I have not been using the hibernate option for years. Sleep mode and power-off suit my needs better.

Avron

I am a translator!

Offline
Iscritto: 08/18/2020

I checked on my t400, here is the layout as shown by lsblk:

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 223,6G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 513M 0 part /boot/efi
├─sda3 8:3 0 732M 0 part /boot
└─sda4 8:4 0 222,4G 0 part
└─sda4_crypt 253:0 0 222,3G 0 crypt
├─vgtrisquel-root 253:1 0 38,6G 0 lvm /
├─vgtrisquel-swap_1 253:2 0 1,9G 0 lvm [SWAP]
└─vgtrisquel-home 253:3 0 181,8G 0 lvm /home

As far as I can remember, this was done by Trisquel 10 graphic installer. The resume from hibernate works but when I have abrowser plus some other memory consumming application running, "hibernate" does not show up. After I quit a number of applications, it shows up again.

Interestingly, there is no /etc/initram-tools/conf.d/resume so what I found on internet about this might be irrelevant or outdated information. However, that file was created by the text mode installation option using encryption and lvm.

I don't like sleep because you can go out of battery and there is no serious protection at wake-up. I really wonder why the installer does not allocate a larger swap space, hibernate is most useful when many things are running, having to quit programmes to use it makes it somehow useless.

prospero
Offline
Iscritto: 05/20/2022

> I don't like sleep because you can go out of battery and there is no serious protection at wake-up

That makes sense. My usage case of sleep mode does not require serious protection at wake up, and I cannot go out of battery because I am not usually using one. So I have no reason to use hibernate, which in my memory is more often buggy than not, and always very slow.

In the situation you mention, which is indeed when hibernate looks like the first choice, I realized that my own memory could not make much of the mess I would find when resuming from hibernate after such a long break, in which case saving everything and powering off was best.

Anyway, I agree that such an unexpected behavior is annoying for those who need it and should be looked into. I believe you should open an issue on https://gitlab.trisquel.org, for which you need a password, or send a message to the dev mailing list and tell them about the situation.

Avron

I am a translator!

Offline
Iscritto: 08/18/2020

Problem is now solved on my x200.

I changed /etc/initramfs-tools/conf.d/resume to:
RESUME=/dev/mapper/vgx-swap_1

and ran 'sudo update-initramfs -u'.

Previously, RESUME was set to a UUID, I had the idea to change it to a path with /dev/mapper when reading https://wiki.debian.org/Hibernation#Changing_or_moving_the_swap_partition that said UUID could not be used with lvm.

Attention: my x200 was installed with Trisquel 9 net installer and upgraded to Trisquel 10. On my t400 installed with Trisquel 10 graphic installer, there is no /etc/initramfs-tools/conf.d/resume but resume from hibernate works, so the mechanism may be different.