Thinkpad T410 random shutdown issue

Yusef Aslam - 05 Apr 2024

Tags: thinkpad,battery,linux

Randomly, the laptop just shuts off while I’m doing something, this happens when the battery is still charged a decent amount, but doesn’t happen all the time.

Some guy on the internet that has a Thinkpad and had the same issue was saying certain dodgy aftermarket batteries can do this. Also the laptop doesn’t shutdown, it hibernates, I lose data regardless as it doesn’t support hibernation.

Some post on the internet lead me to the Upower logs (/var/lib/upower), Upower logs the battery charge in that location. I looked at one of the logfiles and I confirmed the suspicions, at random points in the logfile, the battery charge goes from 30% straight to 0%, then back to 30% again for example, this means that Upower notices that, waits a bit, then executes the CriticalBatteryAction in its config file.

Truncated logfile, the unknown parts are what are causing the issue I think:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1712041737	0.000	unknown
1712041737	79.000	discharging
1712043368	0.000	unknown
1712043368	79.000	discharging
1712043398	78.000	discharging
1712043488	77.000	discharging
1712043669	76.000	discharging
1712043909	75.000	discharging
1712045097	6.000	discharging
1712045097	0.000	unknown
1712045097	6.000	discharging
1712045098	75.000	discharging
1712045197	74.000	discharging
1712059391	0.000	unknown
1712059391	36.000	discharging
1712059512	35.000	discharging
1712059662	34.000	discharging
1712060512	44.000	discharging
1712060672	43.000	discharging
1712343388	63.000	charging
1712343438	0.000	unknown
1712343438	63.000	charging

I looked at the Upower config file to see if you can set the CriticalBatteryAction to nothing, but for some reason, it is not possible.

Why?!

I found a PR in the Upower repo on GitLab that has that option, and some discussion about adding it, but for some strange reason they are not merging it. ArchLinux does have a patched Upower in the AUR, so I might have to switch.

Dafuq.

Update:

I completely disabled Upower by renaming its systemd service in /usr/lib/systemd/system/upower.service to /usr/lib/systemd/system/upower.service.disabled, the reason why you have to rename the file and not just disable the service is because in Fedora the service just starts again regardless.

Without Upower, nothing happens when I close the lid of the laptop, so I switched to logind to handle that, I configured logind like so in its configuration file at /etc/systemd/logind.conf:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it under the
#  terms of the GNU Lesser General Public License as published by the Free
#  Software Foundation; either version 2.1 of the License, or (at your option)
#  any later version.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in
# the logind.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# Use 'systemd-analyze cat-config systemd/logind.conf' to display the full config.
#
# See logind.conf(5) for details.

[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#UserStopDelaySec=10
#HandlePowerKey=poweroff
#HandlePowerKeyLongPress=ignore
#HandleRebootKey=reboot
#HandleRebootKeyLongPress=poweroff
#HandleSuspendKey=suspend
#HandleSuspendKeyLongPress=hibernate
#HandleHibernateKey=hibernate
#HandleHibernateKeyLongPress=ignore
HandleLidSwitch=suspend
HandleLidSwitchExternalPower=suspend
HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#RebootKeyIgnoreInhibited=no
#HoldoffTimeoutSec=30s
IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RuntimeDirectoryInodesMax=
#RemoveIPC=yes
#InhibitorsMax=8192
#SessionsMax=8192
#StopIdleSessionSec=infinity

One thing that logind does not do though is lock the screen before suspending, will need to find a way to bring that back.

Also without Upower, power management daemons such as powerkit are unable to read the battery life, so I have to just resort to reading the file from the kernel directly in /sys/class/power_supply/BAT0/capacity.

Regenerated at : November 24, 2024 - 08:40:55 GMT