Linux does not see all memory

The other day I upgraded the memory in a customer’s Linux system from 2 to 8 Gb. Afterwards though, only 4 Gb was “visible”. The “free” and “top” commands confirmed that only half the expected memory was there. The system was running 32 bit Red Hat 4.7 in a vmware virtual machine.

4 Gb is the normal limit of memory addressable in a 32 bit system, because 32 bits can support at most 2^32 addresses: 2^32 bits = 4 x 2^30 = 4 Gb. (1 Gb = 2^30 bytes).

In order for a Red Hat 32 bit system to address more than 4 Gb, it must be running an “SMP”, or multi-processor, kernel. The above system wasn’t, as shown by uname -a:

saturn# uname -a
Linux saturn 2.6.9-78.EL #1 Wed Jul 9 15:27:01 EDT 2008 i686 i686 i386 GNU/Linux

That’s a uniprocessor kernel. Another of the customer’s systems, though identical to saturn, does see its full complement of 8 Gb. It runs an SMP kernel, as indicated below:

pluto# uname -a
Linux pluto 2.6.9-78.ELsmp #1 SMP Wed Jul 9 15:39:47 EDT 2008 i686 i686 i386 GNU/Linux

The installed memory can be determined with the “free” and “top” commands.

Fortunately, it is quite easy to change from one type of kernel to the other. Using a process like this, I installed an SMP kernel into saturn:

Insert the Red Hat CD, or present the ISO if the system is virtual. Then:

# cd /media/cdrom/RedHat/RPMS

In this directory there will be tons of RPM files containing various programs and applications. To see those pertaining to the kernel, use

# ls -l kernel*
-rw-r--r-- 34 root root 12868252 Jul 9 2008 kernel-2.6.9-78.EL.i686.rpm
-rw-r--r-- 34 root root 4097812 Jul 9 2008 kernel-devel-2.6.9-78.EL.i686.rpm
-rw-r--r-- 34 root root 12294960 Jul 9 2008 kernel-hugemem-2.6.9-78.EL.i686.rpm
-rw-r--r-- 33 root root 4122953 Jul 9 2008 kernel-hugemem-devel-2.6.9-78.EL.i686.rpm
-rw-r--r-- 34 root root 12416034 Jul 9 2008 kernel-smp-2.6.9-78.EL.i686.rpm
-rw-r--r-- 34 root root 4114334 Jul 9 2008 kernel-smp-devel-2.6.9-78.EL.i686.rpm
-rw-r--r-- 121 root root 1075676 Jun 3 2008 kernel-utils-2.4-14.1.117.i386.rpm
-rw-r--r-- 33 root root 3793324 Jul 9 2008 kernel-xenU-2.6.9-78.EL.i686.rpm
-rw-r--r-- 33 root root 3907861 Jul 9 2008 kernel-xenU-devel-2.6.9-78.EL.i686.rpm

Confirm the currently installed kernel as follows.

# rpm -q -a | grep kernel
kernel-utils-2.4-14.1.117
kernel-hugemem-devel-2.6.9-78.EL
kernel-devel-2.6.9-78.EL
kernel-smp-devel-2.6.9-78.EL
kernel-2.6.9-78.EL

The SMP kernel is not installed on the system (although the SMP devel package is). Install the SMP kernel as follows:

# rpm -Uvh kernel-smp-2.6.9-78.EL.i686.rpm
Preparing... ########################################### [100%]
1:kernel-smp ########################################### [100%]
#
# rpm -q -a | grep kernel
kernel-utils-2.4-14.1.117
kernel-hugemem-devel-2.6.9-78.EL
kernel-devel-2.6.9-78.EL
kernel-smp-devel-2.6.9-78.EL
kernel-smp-2.6.9-78.EL
kernel-2.6.9-78.EL

Edit grub.conf to enable the new kernel to boot, adding the following lines
# vi /etc/grub/grub.conf

default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux AS (2.6.9-78.ELsmp)
root (hd0,0)
kernel /vmlinuz-2.6.9-78.ELsmp ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.9-78.ELsmp.img

title Red Hat Enterprise Linux AS (2.6.9-78.EL)
root (hd0,0)
kernel /vmlinuz-2.6.9-78.EL ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.9-78.EL.img

The “default=0” will cause the system to boot the new SMP kernel by default.

A final reboot loaded the SMP kernel, making available the full 8 Gb of memory. The problem, at first seeming very mysterious, succumbed to a pretty painless fix.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.