Thinkpad T560 Battery Usage Under Ubuntu 24

Information about batteries

List all power devices

$ upower -e
/org/freedesktop/UPower/devices/battery_BAT0
/org/freedesktop/UPower/devices/battery_BAT1
/org/freedesktop/UPower/devices/line_power_AC
/org/freedesktop/UPower/devices/DisplayDevice

Get information about one of the devices

$ upower -i /org/freedesktop/UPower/devices/battery_BAT1
native-path: BAT1
vendor: SANYO
model: 45N1775
serial: 219
power supply: yes
updated: Tue 31 Dec 2024 08:11:49 AM EST (25 seconds ago)
has history: yes
has statistics: yes
battery
present: yes
rechargeable: yes
state: discharging
warning-level: none
energy: 40.67 Wh
energy-empty: 0 Wh
energy-full: 60 Wh
energy-full-design: 60 Wh
energy-rate: 4.852 W
voltage: 11.286 V
charge-cycles: N/A
time to empty: 8.4 hours
percentage: 67%
capacity: 100%
technology: lithium-ion
icon-name: ‘battery-full-symbolic’
History (charge):
1735650649 67.000 discharging
History (rate):
1735650709 4.852 discharging
1735650679 5.101 discharging
1735650649 5.000 discharging

Charging Thresholds

Show the remaining battery percentage below which the battery will be charged.  The default is 0, which means the battery will always charge when on AC power.

$ cat /sys/class/power_supply/BAT1/charge_start_threshold
0

Change it to 5% so the battery won’t charge unless it has less than 5% of a full charge remaining :
$ sudo sh -c “echo 5 > /sys/class/power_supply/BAT1/charge_start_threshold”

Show the remaining battery percentage above which the battery will not be charged.  The default is 100, which means the battery will be charged until completely full.
$ cat /sys/class/power_supply/BAT1/charge_stop_threshold
100

Change it to 95%:
$ sudo sh -c “echo 95 > /sys/class/power_supply/BAT1/charge_stop_threshold”
Check what the battery is doing (returns discharging or charging):
$ cat /sys/class/power_supply/BAT1/status

References

How to Set Battery Charge Limit in Ubuntu 22.04 & 24.04

Uncategorized

Comments (0)

Permalink

Ubuntu 24.04 doesn’t wake up from suspend

Carmine, a Lenovo Thinkpad T560, stopped waking up from suspend after Ubuntu was upgraded from 22.04 to 24.04. After a suspend, the only recourse was to hold the power button down for five seconds until the laptop powered off, then restart it.
The fix is to update this line in /etc/default/grub:
GRUB_CMDLINE_LINUX="intel_iommu=off"
Then run
sudo update-grub
to generate the grub configuration.

Here is relevant information:
Bug 197029 – intel_iommu=on breaks resume from suspend on several Thinkpad models
Ubuntu 24.04 LTS does not wake up or repond after being idle for some time

Uncategorized

Comments (0)

Permalink

Upgrade Carmine from Ubuntu 22.04.5 to 24.04.1

Carmine is a Lenovo Thinkpad T560 laptop. It’s been running Ubuntu 22.04 for almost two years and was overdue for an upgrade to 24.04. The upgrade strategy for my machines is to keep two identically-sized partitions and copy the current partition to a backup partition before doing an upgrade. This makes sure I have a working system in case something goes wrong or a piece of software doesn’t work with the new version. This time, however, I didn’t do that because the partions were nearly full. Rather, I deleted the backup partion in LVM and added its space to the active one.

$ df -h
/dev/mapper/volgroup1-linux1 48G 43G 2.7G 94% /

$ sudo vgdisplay
--- Volume group ---
VG Name volgroup1
VG Size 112.46 GiB
VG UUID 6Jf0OZ-gKZU-vyqV-G06Y-tofU-IP3O-LMjwwX

$ sudo lvdisplay
--- Logical volume ---
LV Path /dev/volgroup1/swap
LV Name swap
VG Name volgroup1
LV UUID GR3Vhj-3DmU-VOUg-LO9u-Men4-GJHo-c7nYYQ
LV Size 16.00 GiB

--- Logical volume ---
LV Path /dev/volgroup1/linux1
LV Name linux1
LV UUID c3Ovej-FPO9-xte2-7W3B-3qMM-ZUnO-kzmBHy
VG Name volgroup1
LV Size 48.00 GiB

--- Logical volume ---
LV Path /dev/volgroup1/linux2
LV Name linux2
LV UUID cC2Z0d-r6Rh-Llkp-R7RP-02Fz-b5M1-xzdoGJ
VG Name volgroup1
LV Size 48.00 GiB

Logical Volume linux1 is used by the current OS. linux2 contains the backup of the prior Ubuntu version, 20.04.5. This can be verified by checking /boot/grub/grub.cfg. There isn’t enough space on these partitions for anything new, so I’m going to remove linux2 and add its space to linux1.
Use KDE Partition Manager (from package partitionmanager), which can operate on mounted partitions.
1) Delete linux2
2) Resize linux1 to use freed space
3) Apply changes
That’s it! Partition Manager automatically updates the filesystem to use the new space.
Next run the Ubuntu upgrade with Software Updater.
The installer said cheese is no longer supported, however it remained functional after the upgrade.
The installer also said it would remove GIMP and XSANE. I reinstalled these after the upgrade and they work fine.

Uncategorized

Comments (0)

Permalink

Resolving time issues with dual boot Windows and Linux

Unless you live in the GMT time zone, dual booting between Windows and Linux will cause your computer to display the wrong time each time you boot the other OS. This is because Linux (Ubuntu in this case) by default assumes the hardware clock is set to the UTC time zone and Windows assumes it’s set to the local time zone. One has to get changed, and because Windows is screwed up, it’s easier to tell Linux to use local time. The command to do this is:
timedatectl set-local-rtc 1 --adjust-system-clock
to confirm the change, run timedatectl

Reference: Gadget Gang

Uncategorized

Comments (0)

Permalink

Upgrade Carmine from Ubuntu 20.04 LTS to 22.04 LTS

/dev/volgroup1/ubuntu16.04 is really Ubuntu 20.04
/dev/volgroup1/ubuntu18.04 is the old Ubuntu 18.04 installation
Both logical volumes are the same size

Rename the old logical volume

First rename the old logical volume to reflect what will be stored there:
sudo lvrename volgroup1 ubuntu18.04 linux2

Back up the current OS

copy the contents of the current OS in ubuntu16.04 to linux2:
sudo dd if=/dev/volgroup1/ubuntu16.04 of=/dev/volgroup1/linux2 bs=1024k

Update the backup copy to be bootable

Mount the new volume:
sudo mkdir /media/linux2
sudo mount /dev/volgroup1/linux2 /media/linux2
Edit /media/linux2/etc/fstab and change / to point to /dev/mapper/volgroup1-linux2

Update Grub

Load Grub Customizer if you don’t already have it:
sudo apt install grub-customizer
Run Grub Customizer and check the entries for both logical volumes including the paths and LVIDs (which you can get from lvdisplay)
Rename the entries to Ubuntu primary (linux1) and Ubuntu alternate (linux2)
Don’t forget to save, which runs update-grub and install to MBR

Check both logical volumes are OK

Verify you can boot into primary and alternate

When running alternate, rename logical volume ubuntu16.04 to linux1, update its fstab and update Grub as above.

Now that there’s a backup copy of the current OS in Ubuntu alternate, it’s safe to boot into Ubuntu primary and begin the upgrade

Uncategorized

Comments (0)

Permalink

Upgrading from PHP 7.4 to 8.0

PHP 7.4 is no longer supported. My host offers 8.0, so I upgraded, but WordPress failed to run.

Starting State

WordPress version 6.1.1
PHP 7.4 FastCGI

Error Description

Upgrading to PHP 8.0 FastCGI caused WordPress to show:

There has been a critical error on this website. Please check your site admin email inbox for instructions.

None of the WordPress pages worked, including the recovery page that WordPress emailed to me, wp-login.php?action=enter_recovery_mode.

Diagnosis

To diagnose the problem, I turned on debug logs by adding these lines to wp-config.php:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );

This showed a fatal error in the wp-cache plugin. This was surprising because that plugin was disabled.

Solution

Moving the wp-cache directory from the plugins directory to another directory I created, plugins-old, fixed the problem.

Uncategorized

Comments (0)

Permalink

Open a File From the Command Line as if it were Double-Clicked in Nautilus

$ xdg-open {file-name}

Uncategorized

Comments (0)

Permalink

Ubuntu 20.04 NAS permission denied

On a new installation of Ubuntu 20.04, NAS mounts were readable, but not writable. When looking at the long directory listing, the files were owned by a UID and GID different than the user they were mounted for. The fix for this was to add forceuid and forcegid to the mount options in the autofs configuration file. After that, run
sudo service autofs restart
Verify the force options have been applied by accessing the mounted directory (to force automounting), then checking the output of mount and ls -l.

Uncategorized

Comments (0)

Permalink

Mapping Ctrl+Alt+Delete to Shut Down in Ubuntu 20

  1. Start Settings
  2. Select Keyboard Shortcuts
  3. In the System section, disable the shortcut for Log out
  4. At the bottom, select + to add a custom shortcut
  5. Name it Shut down
  6. Set the command to gnome-session-quit --power-off
  7. Enter Ctrl+Alt+Delete for the shortcut

Uncategorized

Comments (0)

Permalink

Backwards Natural Horizontal Scrolling

On a Thinkpad laptop with Ubuntu 20, I switched to Natural Scrolling, but was confused to find that, although vertical scrolling worked as expected, horizontal scrolling was unchanged, resulting in a very unnatural experience. It turns out that the culprit was a old input driver that was probably carried along as this laptop was upgraded over the years. The correct driver (xserver-xorg-input-libinput) was already installed, so the fix was to uninstall the old one:

sudo apt remove xserver-xorg-input-synaptics

then log out and back in again. Touchpad speed was at zero, so that had to be moved to 2/3 of maximum to restore the speed I had under the Synaptics driver.

Reference: https://askubuntu.com/questions/1029128/inverted-horizontal-scrolling-ubuntu-18-04#1199400

Uncategorized

Comments (0)

Permalink