Linux x86_64 reports 3.2G of memory instead of 4G

I have an ASRock G31M-GS motherboard with 4GB memory installed, but when I query the memory size under CentOS 5.4 (x86_64)

[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.18-164.el5 #1 SMP Thu Sep 3 03:28:30 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux

this is what I get:

[root@localhost ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          3261        565       2696          0         25        288
-/+ buffers/cache:        250       3010
Swap:         2047          0       2047

[root@localhost ~]# grep -i memory /var/log/dmesg
Memory for crash kernel (0x0 to 0x0) notwithin permissible range
Memory: 3336256k/3398336k available (2547k kernel code, 61628k reserved, 1289k data, 208k init)
Freeing initrd memory: 3280k freed
Total HugeTLB memory allocated, 0
Non-volatile memory driver v1.2
agpgart: Detected 7164K stolen memory.
Freeing unused kernel memory: 208k freed

[root@localhost ~]# cat  /proc/meminfo
MemTotal:      3339748 kB
MemFree:       2760432 kB
Buffers:         26692 kB
Cached:         295436 kB
SwapCached:          0 kB
Active:         102232 kB
Inactive:       284276 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:      3339748 kB
LowFree:       2760432 kB
SwapTotal:     2097144 kB
SwapFree:      2097144 kB
Dirty:               0 kB
Writeback:           0 kB
AnonPages:       64336 kB
Mapped:          20720 kB
Slab:            31628 kB
PageTables:       7724 kB
NFS_Unstable:        0 kB
Bounce:              0 kB
CommitLimit:   3767016 kB
Committed_AS:   257916 kB
VmallocTotal: 34359738367 kB
VmallocUsed:      4000 kB
VmallocChunk: 34359733883 kB
HugePages_Total:     0
HugePages_Free:      0
HugePages_Rsvd:      0
Hugepagesize:     2048 kB

but dmidecode reports 4G (DIMM0, DIMM1, 2G each):

[root@localhost ~]# dmidecode
# dmidecode 2.9
SMBIOS 2.4 present.
22 structures occupying 1127 bytes.
Table at 0x000FC200.

Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
        Vendor: American Megatrends Inc.
        Version: P1.60
        Release Date: 07/08/2009
        Address: 0xF0000
        Runtime Size: 64 kB
        ROM Size: 512 kB
        Characteristics:
                PCI is supported
                BIOS is upgradeable
                BIOS shadowing is allowed
                Boot from CD is supported
                Selectable boot is supported
                BIOS ROM is socketed
                EDD is supported
                5.25"/1.2 MB floppy services are supported (int 13h)
                3.5"/720 KB floppy services are supported (int 13h)
                3.5"/2.88 MB floppy services are supported (int 13h)
                Print screen service is supported (int 5h)
                8042 keyboard services are supported (int 9h)
                Serial services are supported (int 14h)
                Printer services are supported (int 17h)
                CGA/mono video services are supported (int 10h)
                ACPI is supported
                USB legacy is supported
                LS-120 boot is supported
                ATAPI Zip drive boot is supported
                BIOS boot specification is supported
                Function key-initiated network boot is supported
                Targeted content distribution is supported
        BIOS Revision: 8.14

Handle 0x0001, DMI type 1, 27 bytes
System Information
        Manufacturer: To Be Filled By O.E.M.
        Product Name: To Be Filled By O.E.M.
        Version: To Be Filled By O.E.M.
        Serial Number: To Be Filled By O.E.M.
        UUID: 00020003-0004-0005-0006-000700080009
        Wake-up Type: Power Switch
        SKU Number: To Be Filled By O.E.M.
        Family: To Be Filled By O.E.M.

Handle 0x0002, DMI type 2, 15 bytes
Base Board Information
        Manufacturer: ASRock
        Product Name: G31M-GS
        Version:
        Serial Number:
        Asset Tag:
        Features:
                Board is a hosting board
                Board is replaceable
        Location In Chassis:
        Chassis Handle: 0x0003
        Type: Motherboard
        Contained Object Handles: 0

Handle 0x0003, DMI type 3, 21 bytes
Chassis Information
        Manufacturer: To Be Filled By O.E.M.
        Type: Desktop
        Lock: Not Present
        Version: To Be Filled By O.E.M.
        Serial Number: To Be Filled By O.E.M.
        Asset Tag: To Be Filled By O.E.M.
        Boot-up State: Safe
        Power Supply State: Safe
        Thermal State: Safe
        Security Status: None
        OEM Information: 0x00000000
        Height: Unspecified
        Number Of Power Cords: 1
        Contained Elements: 0

Handle 0x0004, DMI type 4, 35 bytes
Processor Information
        Socket Designation: CPUSocket
        Type: Central Processor
        Family: Pentium 4
        Manufacturer: Intel
        ID: 7A 06 01 00 FF FB EB BF
        Signature: Type 0, Family 6, Model 23, Stepping 10
        Flags:
                FPU (Floating-point unit on-chip)
                VME (Virtual mode extension)
                DE (Debugging extension)
                PSE (Page size extension)
                TSC (Time stamp counter)
                MSR (Model specific registers)
                PAE (Physical address extension)
                MCE (Machine check exception)
                CX8 (CMPXCHG8 instruction supported)
                APIC (On-chip APIC hardware supported)
                SEP (Fast system call)
                MTRR (Memory type range registers)
                PGE (Page global enable)
                MCA (Machine check architecture)
                CMOV (Conditional move instruction supported)
                PAT (Page attribute table)
                PSE-36 (36-bit page size extension)
                CLFSH (CLFLUSH instruction supported)
                DS (Debug store)
                ACPI (ACPI supported)
                MMX (MMX technology supported)
                FXSR (Fast floating-point save and restore)
                SSE (Streaming SIMD extensions)
                SSE2 (Streaming SIMD extensions 2)
                SS (Self-snoop)
                HTT (Hyper-threading technology)
                TM (Thermal monitor supported)
                PBE (Pending break enabled)
        Version: Pentium(R) Dual-Core  CPU      E5400  @ 2.70GHz
        Voltage: 1.3 V
        External Clock: 200 MHz
        Max Speed: 2700 MHz
        Current Speed: 2700 MHz
        Status: Populated, Enabled
        Upgrade: Other
        L1 Cache Handle: 0x0005
        L2 Cache Handle: 0x0006
        L3 Cache Handle: Not Provided
        Serial Number: To Be Filled By O.E.M.
        Asset Tag: To Be Filled By O.E.M.
        Part Number: To Be Filled By O.E.M.

Handle 0x0005, DMI type 7, 19 bytes
Cache Information
        Socket Designation: L1-Cache
        Configuration: Enabled, Not Socketed, Level 1
        Operational Mode: Write Back
        Location: Internal
        Installed Size: 64 KB
        Maximum Size: 64 KB
        Supported SRAM Types:
                Other
        Installed SRAM Type: Other
        Speed: Unknown
        Error Correction Type: Parity
        System Type: Data
        Associativity: 8-way Set-associative

Handle 0x0006, DMI type 7, 19 bytes
Cache Information
        Socket Designation: L2-Cache
        Configuration: Enabled, Not Socketed, Level 2
        Operational Mode: Write Back
        Location: Internal
        Installed Size: 2048 KB
        Maximum Size: 2048 KB
        Supported SRAM Types:
                Other
        Installed SRAM Type: Other
        Speed: Unknown
        Error Correction Type: Single-bit ECC
        System Type: Unified
        Associativity: 8-way Set-associative

Handle 0x0007, DMI type 5, 20 bytes
Memory Controller Information
        Error Detecting Method: 64-bit ECC
        Error Correcting Capabilities:
                None
        Supported Interleave: One-way Interleave
        Current Interleave: One-way Interleave
        Maximum Memory Module Size: 4096 MB
        Maximum Total Memory Size: 8192 MB
        Supported Speeds:
                Other
        Supported Memory Types:
                DIMM
                SDRAM
        Memory Module Voltage: 3.3 V
        Associated Memory Slots: 2
                0x0008
                0x0009
        Enabled Error Correcting Capabilities:
                None

Handle 0x0008, DMI type 6, 12 bytes
Memory Module Information
        Socket Designation: DIMM0
        Bank Connections: 0 1
        Current Speed: Unknown
        Type: DIMM SDRAM
        Installed Size: 2048 MB (Double-bank Connection)
        Enabled Size: 2048 MB (Double-bank Connection)
        Error Status: OK

Handle 0x0009, DMI type 6, 12 bytes
Memory Module Information
        Socket Designation: DIMM1
        Bank Connections: 4 5
        Current Speed: Unknown
        Type: DIMM SDRAM
        Installed Size: 2048 MB (Double-bank Connection)
        Enabled Size: 2048 MB (Double-bank Connection)
        Error Status: OK

Handle 0x000A, DMI type 9, 13 bytes
System Slot Information
        Designation: PCI1
        Type: 32-bit PCI
        Current Usage: Available
        Length: Short
        ID: 1
        Characteristics:
                3.3 V is provided
                Opening is shared
                PME signal is supported

Handle 0x000B, DMI type 9, 13 bytes
System Slot Information
        Designation: PCI2
        Type: 32-bit PCI
        Current Usage: Available
        Length: Short
        ID: 2
        Characteristics:
                3.3 V is provided
                Opening is shared
                PME signal is supported

Handle 0x000C, DMI type 126, 13 bytes
Inactive

Handle 0x000D, DMI type 9, 13 bytes
System Slot Information
        Designation: PCIE2
        Type: x1 PCI Express
        Current Usage: Available
        Length: Short
        ID: 18
        Characteristics:
                3.3 V is provided
                Opening is shared
                PME signal is supported

Handle 0x000E, DMI type 16, 15 bytes
Physical Memory Array
        Location: System Board Or Motherboard
        Use: System Memory
        Error Correction Type: None
        Maximum Capacity: 4 GB
        Error Information Handle: Not Provided
        Number Of Devices: 2

Handle 0x000F, DMI type 19, 15 bytes
Memory Array Mapped Address
        Starting Address: 0x00000000000
        Ending Address: 0x000FFFFFFFF
        Range Size: 4 GB
        Physical Array Handle: 0x000E
        Partition Width: 0

Handle 0x0010, DMI type 17, 27 bytes
Memory Device
        Array Handle: 0x000E
        Error Information Handle: Not Provided
        Total Width: 64 bits
        Data Width: 64 bits
        Size: 2048 MB
        Form Factor: DIMM
        Set: None
        Locator: DIMM0
        Bank Locator: BANK0
        Type: SDRAM
        Type Detail: Synchronous
        Speed: Unknown
        Manufacturer: Manufacturer0
        Serial Number: SerNum0
        Asset Tag: AssetTagNum0
        Part Number: PartNum0

Handle 0x0011, DMI type 20, 19 bytes
Memory Device Mapped Address
        Starting Address: 0x00000000000
        Ending Address: 0x0007FFFFFFF
        Range Size: 2 GB
        Physical Device Handle: 0x0010
        Memory Array Mapped Address Handle: 0x000F
        Partition Row Position: 1
        Interleaved Data Depth: 1

Handle 0x0012, DMI type 17, 27 bytes
Memory Device
        Array Handle: 0x000E
        Error Information Handle: Not Provided
        Total Width: 64 bits
        Data Width: 64 bits
        Size: 2048 MB
        Form Factor: DIMM
        Set: None
        Locator: DIMM1
        Bank Locator: BANK1
        Type: SDRAM
        Type Detail: Synchronous
        Speed: Unknown
        Manufacturer: Manufacturer1
        Serial Number: SerNum1
        Asset Tag: AssetTagNum1
        Part Number: PartNum1

Handle 0x0013, DMI type 20, 19 bytes
Memory Device Mapped Address
        Starting Address: 0x00080000000
        Ending Address: 0x000FFFFFFFF
        Range Size: 2 GB
        Physical Device Handle: 0x0012
        Memory Array Mapped Address Handle: 0x000F
        Partition Row Position: 1
        Interleaved Data Depth: 1

Handle 0x0014, DMI type 32, 20 bytes
System Boot Information
        Status: No errors detected

Handle 0x0015, DMI type 127, 4 bytes
End Of Table

Same thing (give or take a few MBs) happens with gentoo 2008.x x86_64 livecd.

What's happening here? Wasn't a 64bit OS a cure for this kind of problems?


Solution 1:

I don't know this motherboard personally but here's a suggestion: Go in the BIOS. There should be a Memory Remap Feature option (probably in the Advanced menu) which is disabled by default. Enable it and try again.

Also make sure you are using the latest BIOS version. (And don't forget to install the CentOS patches, because you're not running the latest kernel. :) )