Unix admin tutorial: How much memory is in this machine?

It's not always straightforward to get the answer to the burning question: How much memory is in this Unix machine? David Douthitt points readers to the answers for Solaris, AIX, HPUX, Linux, OpenVMS, and FreeBSD environments.

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:

Solaris

  1. dmesg | grep mem
  2. prtdiag | grep Memory
  3. prtconf -v | grep Memory

AIX

  1. bootinfo -r
  2. lsattr -E1 sys0 -a realmem
  3. getconf REAL_MEMORY

HPUX

  1. dmesg | grep Physical
  2. /opt/ignite/bin/print_manifest | grep Memory
  3. machinfo | grep Memory

Linux

  1. dmesg | grep Memory
  2. grep -i memtotal /proc/meminfo
  3. free

OpenVMS

  1. show mem /page

FreeBSD

  1. dmesg | grep memory
  2. grep memory /var/run/dmesg.boot
  3. 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.

Read more on Network monitoring and analysis