What is Memtester?
Memtester is a memory testing program designed to stress test and test the system's random access memory for errors by writing test patterns to most memory addresses, reading back data and comparing errors. Memtester is distributed under the GPL-2.0 license.
In this article, we will install the memtester package on Ubuntu and then give examples of using memtester.
How to install memtester?
Update package list from Ubuntu repository:
foc@ubuntu22:~$ sudo apt update -y
The memtester version in the repository:
foc@ubuntu22:~$ sudo apt search memtester
Sorting... Done
Full Text Search... Done
memtester/jammy 4.5.1-1 amd64
Utility for testing the memory subsystem
For installation, simply type the following command:
foc@ubuntu22:~$ sudo apt install memtester -y
Post-installation version information and usage:
foc@ubuntu22:~$ memtester
memtester version 4.5.1 (64-bit)
Copyright (C) 2001-2020 Charles Cazabon.
Licensed under the GNU General Public License version 2 (only).
pagesize is 4096
pagesizemask is 0xfffffffffffff000
need memory argument, in MB
Usage: memtester [-p physaddrbase [-d device]] <mem>[B|K|M|G] [loops]
Parameters:
- -p : PHYSADDR tells memtester to test a specific region of memory starting at physical address PHYSADDR, by mmaping a device specified by the -d option.
- MEMORY the amount of memory to allocate and test, in megabytes by default. You can include a suffix of B, K, M, or G to indicate bytes, kilobytes, megabytes, or gigabytes respectively.
- ITERATIONS (optional) number of loops to iterate through. Default is infinite.
Method-1: Use Memtester via CLI interface
You must run Memtester with sudo root user or root user:
foc@ubuntu22:~$ sudo memtester 1024 3 [sudo] password for foc: memtester version 4.5.1 (64-bit) Copyright (C) 2001-2020 Charles Cazabon. Licensed under the GNU General Public License version 2 (only). pagesize is 4096 pagesizemask is 0xfffffffffffff000 want 1024MB (1073741824 bytes) got 1024MB (1073741824 bytes), trying mlock ...locked. Loop 1/3: Stuck Address : ok Random Value : ok Compare XOR : ok Compare SUB : ok Compare MUL : ok Compare DIV : ok Compare OR : ok Compare AND : ok Sequential Increment: ok Solid Bits : ok Block Sequential : ok Checkerboard : ok Bit Spread : ok Bit Flip : ok Walking Ones : ok Walking Zeroes : ok 8-bit Writes : ok 16-bit Writes : ok Loop 2/3: Stuck Address : ok Random Value : ok Compare XOR : ok Compare SUB : ok Compare MUL : ok Compare DIV : ok Compare OR : ok Compare AND : ok Sequential Increment: ok Solid Bits : ok Block Sequential : ok Checkerboard : ok Bit Spread : ok Bit Flip : ok Walking Ones : ok Walking Zeroes : ok 8-bit Writes : ok 16-bit Writes : ok Loop 3/3: Stuck Address : ok Random Value : ok Compare XOR : ok Compare SUB : ok Compare MUL : ok Compare DIV : ok Compare OR : ok Compare AND : ok Sequential Increment: ok Solid Bits : ok Block Sequential : ok Checkerboard : ok Bit Spread : ok Bit Flip : ok Walking Ones : ok Walking Zeroes : ok 8-bit Writes : ok 16-bit Writes : ok Done.
This should allocate 1024MB of memory, and repeat the test 3 times.
As your operating system, current running process might take some amount of RAM, Please check available free RAM and assign that too memtester:
foc@ubuntu22:~$ free -m
total used free shared buff/cache available
Mem: 3923 204 3143 1 576 3492
Swap: 2243 0 2243
It appears as free memory 3143, so it would be inconvenient to allocate more ram than this number for memtest.
Note: If you are using a 32 Bit System, you cannot test more than 4GB even if you have more RAM. Because 32-bit systems do not support more than 3.5 GB of RAM.
Method 2: Run Memtest using GRUB
RAM usage increases while the operating system is running. If you were using memtester before the system started, you could test faster with more ram. In this step we will run memtester with GRUB.
First install the memtest86+ package:
foc@ubuntu22:~$ sudo apt install memtest86+
Then restart Ubuntu, press the shift key to enter the grub menu:
If you did not capture the grub menu with the shift command, you can make grub appear for 5 seconds with the following commands:
foc@foc-ubuntu22:~$ sudo sed -i -e 's/timeout=0/timeout=5/g' /boot/grub/grub.cfg foc@foc-ubuntu22:~$ sudo reboot
Then the test screen is displayed:
Status information is displayed while the test is in progress:
When the test is finished, the number of times it has been tested and the test result are displayed:
When the test is finished, exit is made with the ESC key.
Summary
If your system is very busy and you still assigned higher than available amount of RAM, then the test might get your system into a deadlock, and leads to system to halt, be aware of this.
Run the memtester as root user, so that memtester process can malloc the memory, once its gets hold on that memory it will try to apply lock. If specified memory is not available, it will try to reduce required RAM automatically and try to lock it with mlock.
If you run it as a regular user, it can't auto reduce the required amount of RAM, so it can't lock it, it tries to get hold on that specified memory and starts exhausting all system resources. In this case, it may be a good choice to do memtest from the GRUB menu.
For more information about Memtester, you can get help from the manual page:
foc@ubuntu22:~$ man memtester NAME memtester - stress test to find memory subsystem faults. SYNOPSIS memtester [-p PHYSADDR [-d DEVICE]] <MEMORY> [ITERATIONS] DESCRIPTION memtester is an effective userspace tester for stress-testing the memory subsystem. It is very effective at finding inter‐ mittent and non-deterministic faults. Note that problems in other hardware areas (overheating CPU, out-of-specification power supply, etc.) can cause intermittent memory faults, so it is still up to you to determine where the fault lies through normal hardware diagnostic procedures; memtester just helps you determine whether a problem exists. ...
References
askubuntu.com - Run memtest in terminal [duplicate]