📜 ⬆️ ⬇️

We test memory with Memtest86 + and VirtualBox

By the nature of his activity, one has to deal with hardware, with a large number of computers of different configurations, and, in particular, to test them. Naturally, I want this process to be as automated as possible. For these purposes, I use diskless Linux booting through PXE, where the corresponding scripts with different tests are prepared for autorun, the demons monitor the system status, and monitoring on the server shows the results and swears if something is wrong. In general, everyone can be happy, but I never liked the process of checking the RAM. Memtester, native to Linux, subjectively, works for too long before it finds something, and it does not always find it. Build a kernel or play around with archives is a good way to check the system for stability, but memory is not always to blame for glitches. And the most effective way, ultimately, is the good old Memtest86. But with it, it is necessary to monitor each computer separately, the whole process of automation is lost, and when there are too many computers, time also begins to tighten. Unfortunately, deprived of all sorts of cunning kvm'ami.

Reflecting on this, I turned my eyes on virtualization. Why not try? At least just for lulz. Memory is in fact used the same.


')
For these purposes in VirtualBox we create a virtual machine of the simplest configuration: without a network, without hard drives, only a CD-ROM where the image is connected with MemTest. Create using the GUI or in the console:
VBoxManage createvm --name memtest --ostype Linux --register 


We connect to our machine boot image with Memtest. I used the beta version of the fifth version, you can download from the official forum .
 VBoxManage storagectl memtest --name "IDE Controller" --add ide VBoxManage storageattach memtest --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium /home/user/mt500b1.iso 


Just before launching, we clean the Linux cache from the memory:
 sudo sync sudo echo 3 > /proc/sys/vm/drop_caches 


We decide how much free memory we will give for checking, and how much we will leave for the needs of the operating system:
 a=`free -m | grep "cache:" | awk {'print $4'}` b=$(($a*20/100)) free=$(($a - $b)) 

If you leave too little memory, Linux starts to behave unstably, especially a diskless system where there is no swap.

The fifth version of the memtest supports multi-core, let's use it and give it to the test for how much it is not a pity:
 cpus=$((`lscpu | grep "Core(s) per socket:" | awk {'print $4'}`*`lscpu | grep "Thread(s) per core:" | awk {'print $4'}`-1)) if [ $cpus -lt 1 ]; then cpus=1 fi 


We make the appropriate changes to the car:
 VBoxManage modifyvm memtest --memory $free --cpus $cpus --ioapic on 


And run in the background in console mode:
 VBoxManage startvm memtest --type headless 


You can turn off the virtual machine with the command:
 VBoxManage controlvm memtest poweroff 


We monitor the test status using the VirtualBox debugger:
 VBoxManage debugvm memtest info vgatext 


Example of output to the terminal:
Hidden text
 -------------------------------------------------------------------------------- Memtest86+ 5.00b1 | Intel(R) Pentium(R) CPU G620 @ 2.60GHz CLK: 2600 MHz (X64 Mode) | Pass 10% ### L1 Cache: 64K 39386 MB/s | Test 4% # L2 Cache: 6144K 50971 MB/s | Test #6 [Moving inversions, random pattern] L3 Cache: None | Testing: 0K - 32M 32M of 1853M Memory : 1853M 14939 MB/s | Pattern: e2e5e6e8 R | Time: 0:00:16 ------------------------------------------------------------------------------ Core#: 0 | RAM: 0 MHz (DDR3- 0) - BCLK: 650 State: - | Timings: CAS 0-0-0-0 @ 64-bit Mode Cores: 1 Active / 1 Total (Run: All) | Pass: 0 Errors: 0 ------------------------------------------------------------------------------ SS (ESC)exit (c)configuration (SP)scroll_lock (CR)scroll_unlock -------------------------------------------------------------------------------- 


Now it’s enough to parse the output to the terminal in any convenient way to find out the time, number of passes, errors found, and other interesting information. And accordingly, to write under this case control scripts, for which everything was intended.

For example, if I have an error, a “snapshot” of the screen is written to the log, and the corresponding warning is sent to the server:
 if [[ `VBoxManage debugvm memtest info vgatext | grep Errors: | awk {'print $13'}` > 0 ]];then "$path"/sendmess flog "`VBoxManage debugvm memtest info vgatext`" "$path"/sendmess nonstoperr "[error] Memtest" sleep 15 fi 


I launched this case to be tested on several computers with not the highest quality memory, and the result did not take long to wait:
Hidden text
 -------------------------------------------------------------------------------- Memtest86+ 5.00b1 | Intel(R) Core(TM) i3-2130 CPU @ 3.40GHz CLK: 3383 MHz (X64 Mode) | Pass 7% ## L1 Cache: 64K 51253 MB/s | Test 77% ############################## L2 Cache: 6144K 51253 MB/s | Test #5 [Moving inversions, 8 bit pattern] L3 Cache: None | Testing: 2048M - 3042M 994M of 3042M Memory : 3042M MB/s | Pattern: 80808080 | Time: 0:00:38 ------------------------------------------------------------------------------ Core#: 012 | RAM: 0 MHz (DDR3- 0) - BCLK: 845 State: --- | Timings: CAS 0-0-0-0 @ 64-bit Mode Cores: 3 Active / 3 Total (Run: All) | Pass: 0 Errors: 2 ------------------------------------------------------------------------------ Tst Pass Failing Address Good Bad Err-Bits Count CPU --- ---- ----------------------- -------- -------- -------- ----- ---- 3 0 0004396be2c - 1081.6MB 02020202 02020206 00000004 1 1 3 0 0004396bd3c - 1081.6MB 02020202 0202020a 00000008 2 1 (ESC)exit (c)configuration (SP)scroll_lock (CR)scroll_unlock -------------------------------------------------------------------------------- 


To confirm, I restart Memtest in normal mode:
really there is an error


The way works surprisingly. Therefore, I use it for myself along with the others. Thus it turned out to reveal a lot of memory bars with errors.

Pros:

Of course there are also disadvantages:


I hope someone finds the article useful. Well, or at least smile.

Source: https://habr.com/ru/post/173591/


All Articles