Optimize Battery Health on Dell Linux Laptops and Fedora 38
Update, 24/12/2023: Dell has recently updated and released their Dell Command & Configure
toolkit for RHEL9, which makes it installable natively again on recent RHEL-based distros such as Fedora.
Link: https://www.dell.com/support/kbdoc/en-sg/000178000/dell-command-configure
Why tune battery charging?
To any laptop user who is often on the go, battery life is essential but unfortunately, tends to decrease siginificantly as a laptop grows older. However, did you know that keeping your laptop battery charged at 100% all the time can actually hurt its health over time?
There is a lot of well written articles over this topic, so I won’t go in details; but here are two suggestions:
- My laptop just turned 4 years old. Its battery is still 97.7% healthy. This is how I did it.
- iFixit: How to Care for Your Laptopโs Battery (So It Lasts Longer)
Now, to the matter at hand. Most mainstream laptop manufacturers make use of a variety of software that enables users to directly or indirectly manage battery charge levels and algorithms from the OS while using Windows. MacOS also has a similar functionality called battery health management. This range of options is however often missing on Linux.
If you are using a Dell XPS, not to worry though! command-configure
, mainly a server-oriented utility, lets us control laptop UEFI settings straight from the OS. This comes in handy, especially when we want to adjust battery charge levels.
The snag is command-configure
isnโt quite current. The newest version supports RHEL8 and earlier versions but attempting to install the package on Fedora 38 only leads to broken dependencies - and a broken system.
Here’s where Distrobox steps in to save the day!
In practice
What is Distrobox?
Distrobox is a utility that lets us run different Linux distributions as containers on our host system. It aims to provide an integrated and seamless experience with the host system while keeping the sandboxed environment of the distribution.
Using Distrobox, we can operate a RHEL8 container that serves the sole purpose of running command-configure
and altering UEFI settings from the OS โ specifically, battery charge levels.
Requirements
For this process, you’ll need:
- Distrobox
command-configure
rpm packagesrvadmin-hapi
rpm package (it’s a dependency)
You can download both Dell rpm packages from the Dell Support website here.
Steps to Optimize Your Battery Health
Here’s how you can use Distrobox and command-configure
to ensure your battery’s longevity.
1. Create a Distrobox with host root
When Distrobox (and Podman) launches without the --root
argument, it results in a rootless container, which is good practice but doesnโt meet the requirements for Dell command-configure
to work. Instead, we use the --root
argument as shown below:
> $ distrobox create --image rhel8 --name rhel8-root --root
This command will pull the image if it’s not already available and create a root container named ‘rhel8-root’. The output will display the next command to enter the container.
2. Enter the Container
To get into your newly created container use this command:
> $ distrobox enter --root rhel8-root
On the first launch, the container will run through a set of updates before displaying a command prompt.
3. Install command-configure
in the Container
Once you’re inside the container, go ahead and install command-configure
using the following commands:
> $ sudo dnf install .srvadmin-hapi-9.5.0-4063.16816.el8.x86_64.rpm
> $ sudo dnf install ./command-configure-4.7.0-433.el8.x86_64.rpm
4. Adjust the Battery Charge
With the command-configure
utility installed, you’re now free to adjust the battery charging settings. We’re primarily interested in the PrimaryBattChargeCfg
argument, which configures the charging behavior of the battery, with several options available:
- Standard: Charges the battery over a longer period of time.
- Express: Charges the battery using Dell’s fast charging technology.
- PrimAcUse: Charges battery while plugged-in.
- Adaptive: Charges the battery based on periodic evaluation of battery usage to balance capacity.
- Custom: Starts and stops battery charging based on user input.
If your UEFI is password-protected (and it should be), you’ll also need to include the --ValSetupPwd
argument.
To extend the lifespan of your battery, you may choose to set a custom interval of 50-60% while docked and not on the go. To do this, simply input the command:
> $ sudo /opt/dell/dcc/cctk --PrimaryBattChargeCfg=Custom:50-60 --ValSetupPwd='mypassword'
With these steps, you should be able to effectively manage and optimize the health of your Dell laptopโs battery while using Linux. Itโs an extra step, yes, but it’s a small price to pay for increased battery lifespan.
Happy computing!