Hibernation not working for Thinkpad X230 on Manjaro i3 edition

I’m running the Manjaro i3 edition on my X230, and have tlp and powertop installed. It’s running on kernel v5.10.60-1 (but the problem isn’t new, it’s been like this since I started using it more than a year ago.)

When the battery gets below a certain threshold (a few percent or so) the laptop appears to hibernate. After connecting it to power and charging it up for a bit, I open the lid but the power button doesn’t have the pulsing/glowing ring around it.

When I then press the power button, it just boots up as if it had shutdown previously, and I have to login to a fresh system.

I don’t have this problem on my T460, which will hibernate when the power is low, and then wake from hibernate after the recharging for a bit, or if connected to power.

The problem is replicated when I try to hibernate the X230 manually (i.e. rather than wait for low power), but I don’t think this happens with the T460 (can’t check at the moment as it’s running something, but this is what I recall from the last manual suspension ~ a year ago).

I don’t have the exact same setup for both machines, but I thought I did enough to ensure some similarity. Is there something I can change to enable wake from hibernate, or is this something the X230 can’t do but the T460 can? Enable some BIOS setting, or tlp option?

Additionally, the whole Manjaro partition on the X230 is encrypted as well - not sure if this would make a difference. On the T460, just /home is encrypted, the root filesystem is not.

As always when it comes to hibernation, I’ll ask about swap: What is your swap size and how is it set up?

(inxi -Fazy)

1 Like

Thanks for replying! Yes, after posting I remembered that I had some problems installing Manjaro on the X230 and did not have a swap partition, instead making a swapfile. My T460 has a separate swap partition - presumably one reason why hibernate works on that machine.

Here is the swap setup on the X230:

Swap:
  Kernel: swappiness: 60 (default) cache-pressure: 100 (default) 
  ID-1: swap-1 type: file size: 7.6 GiB used: 0 KiB (0.0%) priority: -2 
  file: /swapfile 

The 7.6GiB is more or less the same as the 8GiB of RAM I have.

How do I configure the swap file to be used when hibernating? Are these instructions valid in this case?

Yes, I used the Arch-Wiki to setup hibernation. Depending on how much RAM is already swapped and how many applications must be put into the swap file, 7.6GB might not be enough.

However, if you already set up a swap file, you could just increase its size. Remember to get the offset correctly and set the correct kernel parameters.
(Also see the Arch wiki for that.)

This one not only tells you how to do it but what to do exactly. More specifically:

RAM   No hibernation    With Hibernation  Maximum
8GB              3GB                11GB     16GB

First column is actual RAM, other columns are swap calculations

:crossed_fingers:

1 Like

To clarify: The pulsating ring on the power switch appears on the X230 while it is in sleep mode (standby). The crescent moon symbol on the lid should also flash continuously. The whole thing should also be accessible via the [FN + F4] keys. The [FN] key or lid switch can used to wake up again from sleep mode. With Hibernation, on the other hand, the power light only flashes when it is shut down and then goes out. Wake up again only with the power button. So what is desired, Sleep or Hibernate?

To clarify: The pulsating ring on the power switch appears on the X230 while it is in sleep mode (standby).

Ah yes - I wrote this originally in another post where I was confused about the difference between suspend/sleep and hibernate.

To clarify, I believe suspend/sleep means “save the system state in RAM/volatile memory and go into a low power mode until woken up”, and hibernate means “save the system state to disk/non-volatile memory and go into low power mode until woken up”.

So what is desired, Sleep or Hibernate?

I want hibernation to function correctly, because my problem occurs when the battery falls below a certain threshold and I am not near my charger. It seems to me that if I wanted to avoid data loss, allowing the system to hibernate before the battery runs out is the best thing to do.

The whole thing should also be accessible via the [FN + F4] keys. The [FN] key or lid switch can used to wake up again from sleep mode.

I didn’t realize this capability with the [Fn] keys - usually the laptop goes into suspend/sleep after the lid has been closed for a while, or I’ve left it alone for more than x minutes. To wake, I either open the lid or press the power button.

I would advise against switching to hibernate when the battery level is low or setting the battery switch-off threshold accordingly high. Shutting down the system briefly requires significantly more energy than sleep mode. The danger, especially with old batteries, is that the last of the juice runs out when the battery is shut down and the data can’t be written to the disk. This is why the default setting for a low battery on the X230 is “sleep”. In sleep mode, all vital functions are shut down so that the X230 gets by with less than 2 watts. Time enough to look for the power adapter and a socket.

Thanks, but can I ask: Do you have hibernate enabled on your system?
How did you do this, and how do you wake from hibernate? It seems even opening the lid after hibernating leads to the system rebooting.

Read the linked arch wiki entry about swap and hibernation.

You need to change a few things: size of the swap file/partition (possibly), add the resume kernel parameter with the correct offset, and probably the resumt hook for the initramfs.

Otherwise, you have to give more system information and a log.

1 Like

I had specified on all our lenovos during setup to create a swap. With XFCE it was always created automatically until 16GB RAM and then build 16GB swap. However, I did not see any notable advantage in using with SSD. I almost got the impression that a swap in a system with sufficient RAM and SSD makes things slower rather than accelerating. In the meantime, the swap has been removed everywhere and everyone is so satisfied. Hibernate doesn’t work anymore, of course, but sorry, nobody misses it here.
Addendum: I don’t know any other way at Lenovo than restarting after Hibernate using the power button, after all the system is shut down completely with data storage . All of your open programs should be back. But: This should also be the case with 8GB RAM after waking up from “sleep” and does not require a swap.

Update and one more question:
I’ve increased the size of my swapfile to 11GB, and now am trying to modify the kernel parameters.

I’m trying to follow the Hijacking cmdline procedure described in the Wiki (seemed to be the clearest way).

I’ve copied the contents of /proc/cmdline to /root/cmdline, and added the resume parameter setting at the end, so that /root/cmdline looks like:

BOOT_IMAGE=/boot/vmlinuz-5.10-x86_64 root=UUID=9489fa42-8bec-47e5-bc9a-5cbf0b1fddb3 rw cryptdevice=UUID=4b36070c-ec60-4e98-9117-3eea3dc6bb8b:cryptroot quiet udev.log_priority=3 resume=UUID=4b93b0b0-19b4-4564-84a3-6b04426c1031

Is this right? Following the wiki I would then do

# mount -n --bind -o ro /root/cmdline /proc/cmdline

and hopefully everything should work after rebooting.

Why don’t you just edit the /etc/default/grub file? Also, you probably need the offset of the swapfile.

I have two lines in /etc/default/grub that seem relevant:

GRUB_CMDLINE_LINUX_DEFAULT="quiet udev.log_priority=3"

and

GRUB_CMDLINE_LINX="cryptdevice=UUID=4b36070c-ec60-4e98-9117-3eea3dc6bb8b:cryptroot"

I presume I would put the resume parameter in the first line, based on what I see on my other machine?

To find the offset, I did # filefrag -v /swapfile and got a table that looks like this, and in my case the number is 34816. I presume then that I also enter resume_offset=34816 into the GRUB_CMDLINE_LINUX_DEFAULT line?

I don’t use grub, so I don’t know to where it should be placed but my kernel options look like this (only the interesting parts):

root=UUID=<my uuid for root> resume=/dev/mapper/volgroup0-rootvol resume_offset=99213311

The UUID for root is the root partition, the resume parameters points to the same device, and obviously the resume_offset depends on the filefrag command.

However, for the encrypted root partition, I do have a /etc/crypttab.initramfs and an /etc/crypttab for the encrypted /home.

Hmm… what do you put in /etc/initram.fs? I don’t have a file like this or /etc/crypttab.initramfs on my other machine, though I do have /etc/crypttab for the encrypted home partition there.

Looking up initram.fs and hibernate leads me to the first solution on this Ubuntu help forum question, but I’m not sure if this is entirely relevant to Manjaro/Arch based systems.

Otherwise, I’ve edited /etc/default/grub and ran grub-mkconfig, so after rebooting /proc/cmdline has updated to show the resume and resume_offset parameters. But hibernating then ends up leading to the same problem, i.e. no resumption from the previous state of the system, just a hard reboot when the machine is powered up/laptop lid is opened.

I followed the ArchiWiki.

My /etc/crypttab.initramfs contains the setup for my root partition. The /etc/crypttab contains only the setup for the encrypted /home partition.

Finally got this working.

Had to do a few more things after updating /etc/default/grub with the resume and resume_offset parameters:

  • make sure that the UUID for the swapfile is exactly that provided by # findmnt -no UUID -T /swapfile , rather than # swaplabel /swapfile (I changed to the latter when experimenting, did not change back till later). Also make sure to do grub-mkconfig -o /boot/grub/grub.cfg and/or # update-grub to enforce the changes after a reboot. You can check if anything has happened with cat /proc/cmdline.

  • change /etc/mkinitcpio.conf to add the resume hook via
    HOOKS=(base udev autodetect keymap modconf block encrypt resume filesystems keyboard fsck) . (I think it’s important that resume comes before filesystems and after encrypt in my case.)
    Afterwards, need to do # mkinitcpio -p linux510, where linux510 refers to the kernel I’m currently using.

After a reboot, I opened some windows and then issued a hibernate command, and the x230 looked to be writing to disk and powering down. (This was happening before, except when I got the wrong UUID for \swapfile, when I was told there wasn’t enough swap to hibernate. So clearly the issue was with setting/enabling the resume module.)

After powering on, it went through the booting procedure, but instead of a fresh login screen I was brought back to the previous system state with the old application windows showing. So hibernating works now!

Thanks to everyone for their help!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.