7

I have a machine with 4gb of RAM, but Linux is only detecting two in top and free. The BIOS reports 4.

Running i386 Debian Lenny.

Knox
  • 2,453
  • 2
  • 26
  • 33
sludge
  • 332
  • 5
  • 10

3 Answers3

11

You need to enable the bigmem kernel.

dpkg --get-selections | grep bigmem
apt-get install linux-image-2.6-xxx-bigmem

You can also check to see if it worked with:

sudo grep -i memory /var/log/dmesg
[ 0.004000] Memory: 899224k/917504k available (1693k kernel code, 17724k reserved, 746k data, 320k init, 0k highmem)

highmem should be larger than 0k

Joseph Kern
  • 9,809
  • 3
  • 31
  • 55
1

You could install a 64-bit version of Debian. This assumes you have a 64 bit processor, which isn't clear from the question. Using the PAE extensions on a 32-bit kernel incurs a performance hit, and without those, you won't be able to see the full 4GB of memory.

Mark
  • 2,846
  • 19
  • 13
  • You can "see" thoe 4GB w/o PAE, it's just that *one* single process can't. But you can have the memory used by a number of processes. – niXar Jun 14 '09 at 09:53
1

(I would have added this as a comment on Mark's answer, but it grew too long to fit)

As Mark points out you won't see the full 4Gb with any 32-bit kernel. Depending on your chipset and other factors you will see between 3.25Gb and 3.75Gb without the performance hit of PAE.

But you don't have to have a full 64 bit system - just a 64-bit kernel. I run a server with 6Gb RAM this way: the kernel sees the whole 6Gb (not 3.5Gb a 32-bit kernel could use on the machine) but has a 32-bit everything else (I haven't found time to do a full re-install to 64-bit yet).

aptitude install linux-image-2.6-amd64

is all you need to do (at least on etch, which this box still is, I doubt the package name has changed in Lenny).

While no individual process will see more then 3Gb RAM (because of the way the virtual memory space is mapped for each process) your processes in total can use the whole lot. In my case the machine runs several VMs which together consume ~5Gb (the host OS using the rest for a few other little things and IO cache/buffers). So if the bigmem kernel can only make use of 3.25Gb of your 4 this might be worth a try to make the extra 0.75 available.

One further caveat: if the machine's chipset is limited to 4Gb then you may still find some of you RAM "missing" even with a 64-bit kernel (or full 64-bit OS install). But I think you'll be unlucky to find a chipset that supports 64-bit processors without supporting >4Gb RAM.

David Spillett
  • 22,534
  • 42
  • 66
  • That's incorrect; you will see the full 4GB. It's just that a single app won't be able to make use of it at once. – niXar Jun 14 '09 at 09:52
  • I'm not sure it is. By my understanding: with a chipset that won't go beyond 4Gb (note: this is maximum supported by the chipset, which may well be more then the max supported by any given board using that chipset) there is nowhere for the kernel to map the memory that clashes with PCI/AGP windows and similar to even if in 64-bit mode, other than to use PAE like a 32-bit kernel would have too. On a 32-bit kernel - the total available will be less than 4Gb, not just the per-process limit being <4Gb. – David Spillett Jun 14 '09 at 17:12
  • Anecdotal evidence: I have a 32 bit kernel now and only see a little over 3Gb of RAM (I have 4GB in the machine and a bigmem enabled kernel). The 64 bit kernel with 32 bit userland sounds like it might be the way to go to see the full amount. Time to go tinkering... – Mark Jun 15 '09 at 14:03
  • That is where I started from. The machine had 4Gb but the kernel could only use ~3.25. It has been running this way (64 bit kernel, 32-bit userland) for nearly six months now and I've not experienced any problems. – David Spillett Jun 15 '09 at 15:55