When you are attempting to deploy a massive, memory-intensive database architecture (like Redis or PostgreSQL) on a bare-metal Linux server, you cannot rely on generic hardware assumptions. If you allocate 64GB of RAM to the database, but the physical motherboard only has 32GB installed, the Linux Out-Of-Memory (OOM) killer will violently terminate the database the millisecond it boots. To force the kernel to execute a deep architectural scan of the physical silicon and dump the exact memory topology to your screen, you must use the lsmem command.
Executing the Silicon Audit
The lsmem (List Memory) command is a highly aggressive hardware diagnostic engine. It completely bypasses the operating system’s software abstraction layers, interrogates the physical memory controllers on the motherboard, and calculates the exact mathematical amount of RAM available.
To execute the scan, simply type:
lsmem
The exact millisecond you press Enter, the terminal outputs a highly structured, deeply technical block of data.
Decoding the Memory Architecture
The raw output is not designed for casual users; it is built for systems engineers. You must know how to decode the specific variables:
- Memory block size: The exact mathematical chunk size the kernel uses to address the physical RAM (often 128MB).
- Total online memory: The absolute, mathematically precise amount of RAM currently active and usable by the operating system (e.g., 32G). This is the most critical number for configuring database limits.
- Total offline memory: RAM that is physically installed on the motherboard but is mathematically disabled or inaccessible (usually 0B on healthy servers).
Extracting Raw Byte Data
By default, the lsmem engine attempts to be helpful by outputting human-readable formats (like 32G). However, if you are writing a highly complex bash script that needs to mathematically calculate percentages (e.g., allocating exactly 75% of total RAM to a specific application), the letter ‘G’ will instantly crash your script.
To force the engine to strip away the human-readable formatting and output raw, unadulterated integer byte counts, you must inject the -b (bytes) flag.
lsmem -b
The engine instantly restructures the report, transforming “32G” into the exact mathematical byte count (e.g., 34359738368). You can immediately pipe this pristine integer directly into your automated deployment scripts.