Introduction
The lmem command is part of the util-linux package and is responsible for showing detailed information on the physical memory of the system, including the address ranges, the size of each block and its status (online / offline). Unlike tools such as free or top, lmem focuses on the low-level vision that the kernel exposes through sysfs, allowing the administrator to identify memory fragments that may be disabled by hardware or boot settings. This level of detail is particularly useful in high-availability servers, in hot-pluggable memory systems and virtualization environments where resource allocation needs to be validated. In the following article we will explore its operation, syntax and the most common cases of use.
What is lmem
lsmem reads the information present in the / sys / devices / system / memory / directory, where each memory block is represented as a subdirectory called memoryXXX. Each of these directories contains files such as state, removable and size that indicate whether the block is active, whether it can be hot removed and how many kilobytes it occupies. When running lmem without arguments, the tool adds these data and presents them in a legible table that shows the start and end of each segment, its size and current status. This output allows you to quickly detect unused memory gaps or blocks marked as offline that could be reput in line by hot-add operations.
Basic syntax
The basic syntax of lsmem is very simple: lsmem [options]. If no options are specified, the command assumes the default behavior of listing all available memory ranges. Some of the most used options include -a or -all to also show the blocks that are marked as removable, -b or -bytes to express the sizes in bytes instead of the default unit (kilobytes), and -J or -json to generate a JSON output that facilitates its processing by scripts. Other options like -h or -help and -V or -version are standard for getting help and program version.
Most useful options
Among the most useful options are -p or -human, which adapts the presentation to legible units (KB, MB, GB) according to the size of each block, and -S or -summarize, which summarizes the total amount of online and offline memory instead of listing each segment individually. There is also the -o or -output option that allows you to select specific columns such as start, end, size, state and removable, which is very practical when you need to feed other programs with precise data. Combining several options, such as lsmem -b -or start, size, state, provides a raw and detailed vision ideal for hardware audits.
Practical examples
Example 1: See memory in bytes and with custom columns. Running lsmem -b -or start, size, state is obtained a list where each line shows the start address, the exact size in bytes and if the block is online or offline. This is useful for scripts that must validate that all memory ranges are active after a boot. Example 2: Summarize online and offline total memory. With lmem -S you will print something like: total online memory: 32GB, total offline memory: 0GB, which allows quick verification of available capacity without manually adding values. Another case of use is to combine lsmem with grep to filter removable blocks: lsmem -a | grep removable: 1 helps to identify which memory sections can be removed in hot, critical information on platforms that support hot-plug RAM.
Interpretation of the exit
The output of lmem is organized in columns that, by default, include the range of starting addresses (Start), the end range (End), the size (Size) and the state (State). The State field can show online, indicating that the block is available for the kernel, or offline, pointing out that it is disabled, either due to lack of hardware, by BIOS configuration or by a previous hot-remove action. When the -a option is used, the Removable column, with values 1 or 0, also appears, indicating whether the block can be added or removed while the system is in place. To correctly interpret these data helps to plan memory updates, diagnose RAM detection failures and validate the functionality of dynamic memory mechanisms in cloud and container environments.
Limitations and alternatives
Although lsmem provides a precise view of physical memory, it has certain limitations: it does not show information about the use of memory by process, or about caches, buffers or swap; for these aspects tools such as free, vmstat or / proc / meminfo should be used. In addition, in systems where the kernel does not expose memory blocks through sysfs (for example, some very old embossed architectures), lmem can return an empty output or error. In such cases, alternatives such as dmidecode -t memory or lshw -class memory can provide data on installed RAM modules, although at a less granular level than that provided by lsmem. Finally, in containers, the vision of lmem is limited to the memory space assigned to the container, so it is recommended to complement it with cgroup metrics for actual use.
Conclusion
In short, lmem is an essential tool for any system manager who needs to know in depth the layout and status of physical memory on a Linux server. Its ability to show individual blocks, its online / offline status and its remobility makes it a powerful ally for planning, hardware diagnosis and validation of hot-plug features. Although it does not replace traditional memory-use monitoring commands, its low-level information completes the picture and allows more informed decisions about infrastructure. It is recommended that lmem be included in the routine management toolkit and be familiar with your options to maximize the potential of system memory.


