It would seem that answering this question ought to be easy; it is -- but every system has the answer in a different
place. Most put an answer of some sort into kernel messages reported by dmesg (AIX, for one, apparently does not).
But, why would you need to know how much memory is in a machine?
- Determine the need for expansion: An upgrade of a system from one operating system version to the next may require more memory. Knowing how much is in the machine will help you to determine if the system satisfies the new requirements.
- System load analysis: If your system is heavily used, you will want to know how much memory is in the machine in order to properly analyze whether the system is properly handling the system load. Is the amount of memory sufficient, or does additional memory need to be added?
- Memory deallocation tracking (in HP terminology): When memory goes bad, many midrange servers will remove the memory from use and thus the total physical memory reported will go down. Knowing what is in the machine will help you recognize when this happens.
- Inventory tracking: Suppose, for example, that the server is sent in for service with 32G of memory and comes back with 28G. Where did the memory go?
As you can see, knowing how much physical memory is in the system is important. So, how do you go about taking inventory of your system memory?
Most systems have a program for system inventory which reports a variety of things, including memory. Inventory programs vary widely and none are the same.
Rather than go into great detail about each environment and how to find total physical memory details for each one, we'll just put these out there for you to reference. Each environment has multiple commands that give available memory; each command is listed succinctly below.
Without further ado, here are a few answers to this burning question:
- dmesg | grep mem
- prtdiag | grep Memory
- prtconf -v | grep Memory
- bootinfo -r
- lsattr -E1 sys0 -a realmem
- getconf REAL_MEMORY
- dmesg | grep Physical
- /opt/ignite/bin/print_manifest | grep Memory
- machinfo | grep Memory
- dmesg | grep Memory
- grep -i memtotal /proc/meminfo
- show mem /page
- dmesg | grep memory
- grep memory /var/run/dmesg.boot
- sysctl -a | grep mem
ABOUT THE AUTHOR: David Douthitt (RHCE, LPIC1, SCSA, Linux+, CNA) is a UNIX Systems Administrator for a major healthcare software company. His blog is Unix Administratosphere, where he continues to write on UNIX, Linux and OpenVMS. He has also written two books on system administration. He still has his copy of Red Hat 2.0 and 4.4BSD.