I am setting up a lot of 64-bit RedHat VMs (VMware vSphere) for our development department in my company. Most of them start with 4096MB of RAM, but Linux only seems to recognize 3832MB. Can anyone tell me why that is?
There are several reasons a piece of RAM would not be used by Linux:
- If Linux detects it as belonging to a hardware peripheral. Most computers need RAM for the display, and thus reserve some RAM for the graphics card. It's also possible for the graphics card to contain its own RAM; as graphics cards have relatively high memory requirements, they tend not to get bundled with RAM of their own (but there are exceptions).
At least VMware and VirtualBox count video memory as part of the memory allocated to a virtual machine. The size of the video memory is a setting in the VM configuration.
- The range of memory addresses that Linux will use can be restricted with
memmap=…parameters on the kernel command line.
- Sometimes the kernel may be unable to use some of the memory. As RAM interfaces are pretty standard, this hardly ever happens except when you run a non-LPAE 32-bit kernel and have 4GB or more of RAM.
- With ECC memory, some ranges where an error has been detected may be marked as unusable.
In practice, most of the time, the memory that Linux can use is the available RAM minus video memory (and possibly memory used by other hardware peripherals). Linux itself divides memory into two parts: the memory used by the kernel, and the memory that's available to processes. Most tools such as
free report as the total figure the memory that's available to processes.
free shows a total of 3832MB and you have 4096MB of RAM on that (physical or virtual) machine, it means that
4096MB - 3832MB = video memory (+ other hardware memory) + kernel memory
264MB for hardware plus kernel sounds plausible. You have 3832MB available for applications because the rest is used by hardware and by the kernel.