I'm sorry if this is poorly worded, but I've done a memory test on one of my computers, and certain memory addresses have errors. This is the first time I've searched. If you need more information, then I can provide it.
I'm sorry if this is poorly worded, but I've done a memory test on one of my computers, and certain memory addresses have errors. This is the first time I've searched. If you need more information, then I can provide it.
If you look in
/etc/default/grub
, you'll find aGRUB_BADRAM=
parameter where you can identify what bad memory locations there are.After setting the addresses, run
sudo update-grub
to apply.Note: That
GRUB_BADRAM
doesn't work with Kernel Lockdown (which would be enabled if you have Secure Boot). You can check if you have Secure Boot enabled by runningmokutil --sb-state
.Taken from https://help.ubuntu.com/community/BadRAM#BADRAM_setting_in_Grub2 ...
BADRAM setting in Grub2
The GRUB2 config file in Natty has a line for configuring kernel bad ram exclusions. So, I will assume that is the preferred way of mapping out a section of memory that is showing errors. The line I set was
The suggested way on every web site I could find was to set this was to run memtest86 and let it show you the BadRAM settings. memtest86 gave me a page of stuff I would have had to enter. I could see that all the addresses were in one 16K block, so I just wanted to map that 16K block out of action. Here is how I generated the correct entry.
The first parameter is easy. That is the base address of the bad memory. In my case, I could see that all the bad addresses were greater than 0x7DDF0000 and less than 0x7DDF4000. So, I took the beginning of the 16K block as my starting address.
The second parameter is a mask. You put 1s where the address range you want shares the same values and 0s where it will vary. This means you need to pick your address range such that only the low order bits vary. Looking at my address, the first part of the mask is easy. You want to start with 0xffff. For the next nibble, I will explain with bit maps. I want to range from 0000 to 0011. So, the mask for badram would be 1100 or a hex c. The last 3 nibbles need to be all 0s in the mask, since we want the entire range mapped out. So, we get a total result of 0xffffc000.
After setting this line in /etc/default/grub, I ran sudo update-grub and rebooted and my bad memory was no longer being used. No kernel patches are needed to map out bad memory using this method.
You can check whether the ranges provided are correct by running
dmesg
and looking forBIOS-provided physical RAM map
orextended physical RAM map
:You can also check
/proc/iomem
as root to see the unusable ranges.Of course, the best action plan would be to replace the defective RAM.
I found the easiest and most robust way for me is to add a kernel parameter
memtest=4
to my GRUB config. This adds a couple of seconds to boot-up where the kernel checks your ram and then marks them as bad for you.sudo nano /etc/default/grub
update this line:
sudo update-grub
reboot
Optionally, check that it is working by running
dmesg
and see logs like this:Source.
To follow on to @heynnema's answer, I wrote a small python script to compute what the mask should be. I wasn't sure of what the proper way to find what the position of the leftmost significant 0 was with bin operations, so I hacked it with a string-based function. But it did work for finding what the mask should be programatically:
This results in
heynnema's answer doesn't work if you have kernel lockdown enabled (which is enabled by default if you are using Secure Boot).
AmanicA's answer doesn't really scale: it will run the test on each boot, slowing down your boot times.
You can use the kernel cmdline parameter
memmap
to reserve certain regions of physical memory so they are not used.See kernel parameters for details.
For example, memtest86+ and the linux memtest found that address 0x22a89a128 was faulty on my machine.
So I added the following line to my kernel cmdline to disable 8KiB of ram around the faulty ram page:
memmap=16K$0x22a898000
Which reserves (this is what the
$
is for) 16 KiB of memory starting at physical address0x22a898000
.I did this by editing
/etc/default/grub
and addingmemmap=16K\\\$0x22a898000
at the end of theGRUB_CMDLINE_LINUX_DEFAULT
variable in that file, and then runningsudo update-grub
.The
\\\
is because grub does some weird character escaping.You can verify that this works by looking for the reserved regions in either dmesg or by opening
/proc/iomem
as root: