You can customize Linux sensor output on Ubuntu 24.04 by creating individual configuration files in the /etc/sensors.d/ directory to rename labels, ignore noisy readings, or adjust scaling factors. This approach avoids deprecated global configuration files and allows precise control over how lm-sensors displays hardware data without modifying system-wide defaults.
Understanding the Modern Configuration Structure
In previous versions of Ubuntu, users were often directed to edit a single global file calledsensors3.conf. However, this file is obsolete in Ubuntu 24.04 and later releases. The lm-sensors package now utilizes a modular configuration system located at /etc/sensors.d/. This directory allows you to create separate files for different sensors or groups of sensors, making management significantly easier and less prone to breaking other configurations.
When you run commands like sensors, the utility reads these configuration files in alphabetical order. If multiple files define settings for the same chip, the last one read typically takes precedence, although best practices suggest keeping configurations distinct to avoid conflicts. Understanding this structure is crucial before attempting any customizations, as it ensures your changes persist across updates and do not interfere with other hardware monitoring tools.
For more information on managing hardware components in Ubuntu, see Adding an Extra Hard Disk to an Ubuntu Machine. While that article focuses on storage, the principles of identifying and configuring hardware devices remain similar when dealing with thermal and voltage sensors.
Renaming Sensor Labels for Clarity
One of the most common reasons to customize sensor output is that default labels are often cryptic or generic. For example, a motherboard might label a temperature input as "temp1" instead of "CPU Package." You can change these labels by creating a new file in/etc/sensors.d/. Let us say you want to rename a label for a specific chip. You would create a file named /etc/sensors.d/custom-labels.conf.
Inside this file, you must identify the chip using its identifier. You can find this identifier by running sensors -u or simply sensors and looking for the chip name, such as coretemp-isa-0000. Once identified, you can add a section that maps the old label to a new, descriptive one.
chip "coretemp-isa-0000" {
label "temp1" "CPU Core 0 Temperature"
label "temp2" "CPU Core 1 Temperature"
}
After saving the file, run sensors again. You should see the new labels displayed immediately. This method works for various types of labels, including voltage inputs, fan speeds, and power measurements. It is important to note that you must use the exact chip identifier found in the raw output; otherwise, the configuration will be ignored silently.
Ignoring Noisy or Unreliable Sensors
Sometimes, certain sensors report erratic values due to hardware quirks or electrical noise. Instead of disabling the entire sensor, which might hide useful data, you can choose to ignore specific inputs in the output. This is particularly useful for fans that spin down completely or voltage rails that fluctuate slightly within acceptable limits. To ignore a specific reading, you use theignore directive within your configuration file in /etc/sensors.d/. For instance, if a fan speed sensor reports zero when the fan is off, causing clutter in your terminal output, you can suppress it.
chip "nct6798-isa-0290" {
ignore "fan3_input"
}
This command tells lm-sensors to skip displaying fan3_input entirely. Note that this does not disable the sensor from the kernel; it only hides it from the user-space display. This is a safe way to clean up your output without affecting system monitoring daemons that might rely on the raw data. Always verify the chip name and input name carefully before applying this directive to ensure you are not hiding critical health metrics.
Adjusting Scaling Factors
Another powerful customization option involves adjusting the scaling factor of sensor readings. Some sensors report values in millivolts or milliamps, while others might require multiplication to display human-readable units. By default,lm-sensors applies standard scaling, but you can override this if necessary.
If you notice that a voltage reading seems off by a factor of ten, you can apply a multiplier in your configuration file. This is done using the factor directive.
chip "acpitz-virtual-0" {
factor "temp1_input" 1.0
}
In this example, we explicitly set the factor to 1.0, ensuring no scaling occurs. If the value was being divided incorrectly, you could set it to 10 or 0.1 depending on the discrepancy. This feature is less commonly needed than renaming or ignoring, but it provides granular control over how data is presented. Use diagnostic tools to compare the raw values from the kernel against the displayed values to determine if scaling adjustments are required.
For users interested in deeper system configuration, exploring BIOS Won't Allow Boot Priority Change for Ubuntu Hard Drive may provide insights into how low-level hardware interactions affect software visibility, though this is tangential to sensor configuration.
Verifying Your Configuration
After creating or modifying files in/etc/sensors.d/, it is essential to verify that they are being read correctly. You can do this by checking the system logs or simply running the sensors command and comparing the output to your expectations. If your changes do not appear, ensure that the file permissions allow the root user to read them, which is the default state. Also, check for syntax errors in your configuration files, as even minor typos can cause the parser to skip sections.
Restarting the lm-sensors service is generally not required, as the sensors command loads configurations dynamically. However, if you have installed additional monitoring services like fancontrol or smartmontools, restarting those services might be necessary to pick up new configurations. Always test changes incrementally, adding one modification at a time to isolate potential issues.
Frequently Asked Questions
Where are lm-sensors configuration files stored in Ubuntu 24.04?
Configuration files are stored in the/etc/sensors.d/ directory. This modular approach replaces the older sensors3.conf file, allowing for easier management of individual sensor settings without editing a single global file.
How do I find the correct chip identifier for my sensor?
Run thesensors command in the terminal. Look for the line that starts with the chip name, such as coretemp-isa-0000 or nct6798-isa-0290. This identifier is case-sensitive and must match exactly in your configuration file.
Can I customize sensor outputs for third-party hardware monitors?
Yes, as long as the hardware is supported bylm-sensors and exposes data through the sysfs interface. You can create custom configuration files in /etc/sensors.d/ to rename or ignore inputs from any compatible sensor chip detected by the system.
What happens if I make a syntax error in my configuration file?
lm-sensors will typically ignore the erroneous section or file and continue with the rest of the configuration. Check the terminal output for warnings, or review the file for missing brackets or incorrect directives. Syntax errors do not usually break the entire system, but they will prevent your customizations from taking effect.
Is it safe to ignore sensor readings?
Ignoring a sensor reading only hides it from thesensors command output; it does not disable the sensor in the kernel. This is safe for cleaning up display clutter, but ensure you are not hiding critical alerts like CPU overheating or fan failures that you need to monitor visually.