Bad Memory HowTo

So.. Memtest tells you have bad ram! Here are your easy options:

  1. Buy new ram
  2. Turn off everything after the bad memory (mem=###M option)
  3. Turn off just the memory around the bad memory (memmap=#M$###M option)
*May require moving RAM around in the computer for best results.

Testing The Memory Tool 1: Memtest There is the classic Memtest which is on every Ubuntu LiveCD and most other Free operating system CDs. It tests memory and gives you back fun technical numbers and also what sectors are bad in the easier form of 797M or 84M. It's the easier number we want. So try to write down the range (if applicable) of bad results.

Tool 2: Memtester Memtester (click here to install) is like memtest only it runs from a command line once Ubuntu has loaded. It can't test your whole ram so you should make sure that it would be testing the area that memtest has detected being bad. You absolutely need to run it with sudo/root.

WARNING: Don' try to test your whole RAM, just say 100M over where the error is. Doing really close to your actual total ram will make your computer unresponsive (unless you are following this with nothing but a shell, then you might be fine).

Ex. Let's say you have 150M taken up by your OS, the badram is at 797M (from memtest) and you have 1024M total memory.

This command would work:

sudo memtester 750M

Option 1 - Buy New Ram

Simple. Easy. Safest. Might be cheap if your computer supports new ram. Wastes hardware that we could likely get to work. Some people say that once RAM starts to go, it will just keep getting worse, I personally don't believe them. I will not be liable for you losing data by using bad RAM. Use YOUR own judgment.

Option 2 - Turn off everything after the bad memory (mem=###M option) This is simple take the lowest number from memtest, subtract let's say 3 from it for a bit of safety. Then add it to your kernel command line for bootup. Ex. So for bad memory at 797M we would add to the default kernel options:

mem=795M

Option 3 - Turn off just the memory around the bad memory (memmap=#M$###M option) WARNING: This is much less tested than Option 2. There may be bugs lurking about. This isn't much more difficult. Instead of just stopping at 795M, we are going to stop at 795M but then only ignore the next 10M. If there are multiple places try to make a range that includes them both.

Ex. So for bad memory at 804M and 806M we could use:

memmap=10M$800M

But for this option I will fell better if you use memtester afterwards to make sure you actually got the right memory spot. (And maybe do it before too, too make sure you actually were testing the right spots in the test)

HowTo Kernel Default Options Edit the file /boot/grub/menu.lst with sudo/root (ex. sudo nano /boot/grub/menu.lst)\

Navigate to here

## ## Start Default Options ## ## default kernel options ## default kernel options for automagic boot options ## If you want special options for specific kernels use kopt_x_y_z ## where x.y.z is kernel version. Minor versions can be omitted. ## e.g. kopt=root=/dev/hda1 ro ## kopt_2_6_8=root=/dev/hdc1 ro ## kopt_2_6_8_2_686=root=/dev/hdc2 ro # kopt=root=UUID=f0906667-bcde-4b64-86bc-5a47320d5517 ro

Edit the line (DO NOT GET RID OF THE #):

# kopt=root=UUID=f0906667-bcde-4b64-86bc-5a47320d5517 ro (add mem stuff here)

Then run:

sudo update-grub

Then reboot.

Thanks for following my HowTo. Many happy PCs and memory modules saved from landfills.

Comments

  • LeDopore says:
    >Hey gQuig, Thanks for the help! You have a well-written tutorial that's a beacon of hope for people with sick computers. I have a quick question. When I try to work around my bad RAM, it looks like top still sees just as much RAM as before. Does that mean that my kernel isn't avoiding the bad ram? My menu.lst file had the following line in it: # kopt=root=UUID=a9f39ac2-c67f-418e-93ce-967bdda5e3a4 ro memmap=100M$1800M and I did remember to sudo update-grub. Thanks for your help! LeDopore
  • gQuigs says:
    >@LeDopore: tell me more about your setup. Anything odd? It should definitely report a different amount. Try looking at: cat /proc/meminfo When you are booting up, stop at grub, by pressing escape and try to edit the lines to see what is actually being used. Remove it and double check that it didn't change the amount of ram.
  • LeDopore says:
    >Thanks, gQuigs. I hadn't known about editing the boot options with grub. I added the memmap=100M$1800M to grub right at boot and my memory available dropped by 100 megs, so I guess the trouble was that my grub wasn't listening to my /boot/grub/menu.lst file. I'll look into this; thanks a million for the help! Cheers, LeDopore
  • LeDopore says:
    >Here's the permanent fix: I have Ubuntu 9.04 running, but I've upgraded a few times so there might be some funny cobwebs in my installation. In any case, I found that adding memmap=100M$1800M under # defoptions (see below) propagates the memory reduction when you run update-grub, even though adding it earlier didn't. ## additional options to use with the default boot option, but not with the ## alternatives ## e.g. defoptions=vga=791 resume=/dev/hda5 # defoptions=quiet splash memmap=100M$1800M Thanks again for the help! LeDopore
  • Bogdan C. says:
    >You can map multiple intervals of your ram. Lets say that you want to "ban" 20 MB from 550 to 570 and 35 MB from 800 to 835 You can write at the end of the line mentioned in the post above "memmap=…" multiple times. Like this: # kopt=root=UUID=a9f39ac2-c67f-418e-93ce-967bdda5e3a4 ro memmap=20M$550M memmap=35M$800M
  • prh says:
    >thanks for this really helpful blog – just a question: when, after adding this (multiple) memmap, I start from grub the windows2000 installation I also have on my hard disk, is then the bad memory also blocked for windows? prh
  • Bogdan C. says:
    >Hm… i don't know if this has any effect on Windows. But you can test this easily: just block, for example, 50 MB of ram. IF Windows shows you (yourAmountOfRam-50) MB then you are one lucky guy 😛
  • Deftronic says:
    >hello i'm trying to apply this tutorial but i got ubuntu 9.10 karmic (first installation) so that i don't got this menu.lst file i can find a /boot/grub/grub.cfg but there's no kopt=root … in the while content any help ? the grub.cfg file content => # # DO NOT EDIT THIS FILE # # It is automatically generated by /usr/sbin/grub-mkconfig using templates # from /etc/grub.d and settings from /etc/default/grub # ### BEGIN /etc/grub.d/00_header ### if [ -s /boot/grub/grubenv ]; then have_grubenv=true load_env fi set default="0" if [ ${prev_saved_entry} ]; then saved_entry=${prev_saved_entry} save_env saved_entry prev_saved_entry= save_env prev_saved_entry fi insmod ext2 set root=(hd0,6) search –no-floppy –fs-uuid –set 0fac7a3d-ec9c-4cd2-899e-a78a899c973b if loadfont /usr/share/grub/unicode.pf2 ; then set gfxmode=640×480 insmod gfxterm insmod vbe if terminal_output gfxterm ; then true ; else # For backward compatibility with versions of terminal.mod that don't # understand terminal_output terminal gfxterm fi fi if [ ${recordfail} = 1 ]; then set timeout=-1 else set timeout=10 fi ### END /etc/grub.d/00_header ### ### BEGIN /etc/grub.d/05_debian_theme ### set menu_color_normal=white/black set menu_color_highlight=black/white ### END /etc/grub.d/05_debian_theme ### ### BEGIN /etc/grub.d/10_linux ### menuentry "Ubuntu, Linux 2.6.31-16-generic" { recordfail=1 if [ -n ${have_grubenv} ]; then save_env recordfail; fi set quiet=1 insmod ext2 set root=(hd0,1) search –no-floppy –fs-uuid –set f017e4b3-7a62-48d7-a2fe-d3842503a7e3 linux /vmlinuz-2.6.31-16-generic root=UUID=0fac7a3d-ec9c-4cd2-899e-a78a899c973b ro quiet splash initrd /initrd.img-2.6.31-16-generic } menuentry "Ubuntu, Linux 2.6.31-16-generic (recovery mode)" { recordfail=1 if [ -n ${have_grubenv} ]; then save_env recordfail; fi insmod ext2 set root=(hd0,1) search –no-floppy –fs-uuid –set f017e4b3-7a62-48d7-a2fe-d3842503a7e3 linux /vmlinuz-2.6.31-16-generic root=UUID=0fac7a3d-ec9c-4cd2-899e-a78a899c973b ro single initrd /initrd.img-2.6.31-16-generic } menuentry "Ubuntu, Linux 2.6.31-14-generic" { recordfail=1 if [ -n ${have_grubenv} ]; then save_env recordfail; fi set quiet=1 insmod ext2 set root=(hd0,1) search –no-floppy –fs-uuid –set f017e4b3-7a62-48d7-a2fe-d3842503a7e3 linux /vmlinuz-2.6.31-14-generic root=UUID=0fac7a3d-ec9c-4cd2-899e-a78a899c973b ro quiet splash initrd /initrd.img-2.6.31-14-generic } menuentry "Ubuntu, Linux 2.6.31-14-generic (recovery mode)" { recordfail=1 if [ -n ${have_grubenv} ]; then save_env recordfail; fi insmod ext2 set root=(hd0,1) search –no-floppy –fs-uuid –set f017e4b3-7a62-48d7-a2fe-d3842503a7e3 linux /vmlinuz-2.6.31-14-generic root=UUID=0fac7a3d-ec9c-4cd2-899e-a78a899c973b ro single initrd /initrd.img-2.6.31-14-generic } ### END /etc/grub.d/10_linux ### ### BEGIN /etc/grub.d/20_memtest86+ ### menuentry "Memory test (memtest86+)" { linux16 /memtest86+.bin } menuentry "Memory test (memtest86+, serial console 115200)" { linux16 /memtest86+.bin console=ttyS0,115200n8 } ### END /etc/grub.d/20_memtest86+ ### ### BEGIN /etc/grub.d/30_os-prober ### if [ ${timeout} != -1 ]; then if keystatus; then if keystatus –shift; then set timeout=-1 else set timeout=0 fi else if sleep –interruptible 3 ; then set timeout=0 fi fi fi ### END /etc/grub.d/30_os-prober ### ### BEGIN /etc/grub.d/40_custom ### # This file provides an easy way to add custom menu entries. Simply type the # menu entries you want to add after this comment. Be careful not to change # the 'exec tail' line above. ### END /etc/grub.d/40_custom ###
  • jordanwb says:
    >Thanks. I got a 1 Gigabyte stick with one bad address and I don't want to throw it out. I'll try this.
  • Bogdan C. says:
    >Deftronic … i had this problem too. Now (in Ubuntu 9.10) the boot loader is upgraded and the menu.lst file doesn't exist. Stop searching it. The solution is… different now. You have to edit the /etc/default/grub file (or grub.cfg; i don't know exactly… i don't have my computer with linux near me). Of course… you have to have admin rights, so edit this file with sudo. Now… you will se something like this: # If you change this file, run 'update-grub' afterwards to update # /boot/grub/grub.cfg. GRUB_DEFAULT=0 GRUB_HIDDEN_TIMEOUT=0 GRUB_HIDDEN_TIMEOUT_QUIET=false GRUB_TIMEOUT="10" GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="quiet splash memmap=54M\\\$970M" GRUB_CMDLINE_LINUX="" save the file and run sudo update-grub Those backslashes are important so don't forget them. And 3 of those are now necessary, as you can see in the code posted above. Of course, you can map, as before, more than one part of your memory. In this case the above line will look something like this: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash memmap=14M\\\$170M memmap=54M\\\$340M memmap=34M\\\$670M" Anyway… hope this helped you a little 🙂
    Gimmy says:
    hi all, Thank you for all the info. I am experiencing problems with my RAM, so I decided to use Memtest86+ to locate the errors and Memtester to double check them. I tried then to use Memtester as you suggest here, but I am not sure about the description you gave. I downloaded the last version and from the web I understood that: sudo memtester 750M is just going to lock (malloc) a block of 750MB in size and test it without consideration of WHERE this block is. If the aim is to test a specific area, it is necessary to give memtester a physical address and then the amount of MB from there onwards. e.g.: for testing 100MB after a certain address 0xfffblabla sudo memtester -p 0xffffblabla 100M Does anybody know how I can get the physical address of the defecting memory? Thanks!
    1. Bryan says:
      Yup, you understand why memtester isn’t as useful as far as I’ve found. I do believe memtester will allocate contiguous memory though, so if you know where it is from memtest86+ you should be able to get it to allocate to cover the bad spot.
      1. Gimmy says:
        Yes, but I am not sure how to read the memtest86+ output… The list of errors is not very clear to me. I tried to isolate some areas using grub. I’m waiting to see as it goes. fingers crossed.
  • Myron Shank, M.D., Ph.D. says:
    I had similar problems, but found the available instructions incomplete and confusing, so I wrote these instructions to assume as little background as possible. 1. Run Memtest86+ in “badram” output (preferably from a bootable external medium). When it starts, type “c” (“configuration”), then “4” (“Error Report Mode”), then “3” (“Bad RAM Patterns”), then “0” (“Continue”). 2. Copy the output that follows any lines beginning with “badram=”. 3. Open a terminal (command line). 4. Change to the directory where the “grub” file is located. For example, “cd /etc/default”. 5. With “root” privileges, use a text editor to open the “grub” file (If you are not signed in as “root,” use “sudo.” You will be asked for the “root” password. In Linux and other Unix derivatives, “root” is equivalent to Windows’ “Administrator.”). For example, type “sudo nano grub” (This temporarily changes the user to “root” and opens the file “grub” with the “nano” text editor.) 6. Find the section describing memtest. Uncomment the last line (Delete the special character at the beginning of the line, such as “#,” “>,” or “!”). This makes it active (for example, “#GRUB_BADRAM=” becomes “GRUB_BADRAM=”). Replace the example addresses (following “GRUB_BADRAM=”), with the “badram=” output that you copied from Memtest86+ (for example, “0x98f548a0,0xfffffffc”). Save (or “write out”) your changes. 7. In the terminal (command line), update the “grub.cfg” file, by typing “sudo update-grub”. 8. Reboot.
    1. James R says:
      Myron, I found your comment to be quite instructive, thank you.