Skip to content
Check other posts

Disabling broken areas of RAM in Linux

Published: at 11:51 PM

mlembug:

Firefox started crashing very frequently on my laptop from 2016 and finally discovered why: RAM is broken

a camera photo of a laptop display showing a failing memtest86+

too bad, this is one of those “portable” laptops and has the RAM soldered in so I can’t replace it

thankfully Linux comes in to the rescue - using memtest86+ I got info on which memory areas are broken and used this information to tell Linux to not use that memory (the “badram” kernel parameter).

I also added the “memtest” kernel parameter so when the computer is turned on it will do a test on its own and mark the RAM areas which are broken and avoid using these. This is to detect potential increase of damaged areas.

Hopefully this will prolong the lifetime of this laptop by at least a year or so.

update from the future: passing the “memtest” kernel parameter is definitely not enough - the tests are not through enough but also memory that’s nearby seems to work or not work on random basis so it’s safer to manually mark a wider range around it.

using the “badram” kernel parameter didn’t work either as this turned out to be an old kernel patch that was never included.

/etc/default/grub has this line which is supposed to work as is, where you can list the ranges to blacklist by simply copying them from Memtest86+

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD …)
# GRUB_BADRAM="0x00000000a90b0000,0xffffffffffff0000"

but it didn’t work for me for some reason, as the machine refused to boot.

I did however, find a solution through the “memmap” kernel parameter, and my current solution looks like this: edit the /etc/default/grub file and add the memmap as follows

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash memtest memmap=0x10000\\\$0xa90b0000"

and then run update-grub2 as root.

the number of backslashes that seems to work with this file was experimentally found to be three.

this marks 64KB near the address 0xA90B0000 as “reserved” which means Linux kernel will never use it for anything.