Reserve Bad RAM to Improve System Reliability
When dealing with unstable systems, one often overlooked culprit is faulty RAM. Faulty memory can cause random crashes, corrupted files, and a myriad of hard-to -trace issues. While replacing bad RAM is the ideal solution, sometimes it’s not immediately possible. In such cases, you can identify the defective memory regions and prevent the operating system from using them by marking them as reserved or persistent memory. This guide explains how to achieve this using Memtest86+ and the Linux kernel’s memmap= parameter.
Test RAM with Memtest86+
- Run memtest86+.
- Press F1, F4, F4, switch to “BadRAM patterns” mode.
- Press F10, F10, memtest86+ will scan your RAM for errors.
Reserve Bad RAM Using the Linux Kernel memmap=
Parameter
Now that you have the defective memory addresses, you can use the memmap=
parameter to reserve them, ensuring the Linux kernel avoids these areas.
The memmap=
parameter tells the kernel to mark specific memory regions as
reserved or to reclassify them. The syntax is:
# Reserved memory
memmap=size[KMG]$start_address[KMG]
# Persistent memory (Try this if the reserved memory can't boot)
memmap=size[KMG]!start_address[KMG]
- size: The size of the memory region to reserve.
- start_address: The starting physical address of the memory range.
- Both size and start_address can be specified in kilobytes (K), megabytes (M), or gigabytes (G).
If memtest86+ gives the BadRAM patterns as:
0x00000003b7b7a068,0xfffffffffffffff8,
0x00000007b7440438,0xfffffffffffffff8
Convert these ranges to a size and start address with 2M alignment and add the
memmap=
paramters to GRUB:
Edit the GRUB configureation file (/etc/default/grub):
GRUB_CMDLINE_LINUX="... memmap=2M$0x3b7a00000 memmap=2M$0x7b7400000"
Update grub configuration file and reboot the system.
Verify the Reserved Memory
After rebooting, verify that the kernel has reserved the specified memory ranges.
sudo cat /proc/iomem
...
3b7a00000-3b7bfffff : Persistent Memory (legacy)
3b7a00000-3b7bfffff : namespace0.0
3b7c00000-7b73fffff : System RAM
7b7400000-7b75fffff : Persistent Memory (legacy)
7b7400000-7b75fffff : namespace1.0
...
By using Memtest86+ to identify faulty RAM regions and the Linux kernel’s memmap=
parameter to reserve or repurpose them, you can significantly improve system stability
without replacing the RAM immediately. While this is a workaround rather than a permanent
fix, it can buy you time and prevent further crashes caused by bad memory.
For mission-critical systems, always aim to replace faulty hardware as soon as possible. But in a pinch, these techniques can keep your system running smoothly!