1# This module adds Memtest86+ to the GRUB boot menu.
2{
3 config,
4 lib,
5 pkgs,
6 ...
7}:
8
9with lib;
10
11let
12 memtest86 = pkgs.memtest86plus;
13 cfg = config.boot.loader.grub.memtest86;
14in
15
16{
17 options = {
18
19 boot.loader.grub.memtest86 = {
20
21 enable = mkOption {
22 default = false;
23 type = types.bool;
24 description = ''
25 Make Memtest86+, a memory testing program, available from the GRUB
26 boot menu.
27 '';
28 };
29
30 params = mkOption {
31 default = [ ];
32 example = [ "console=ttyS0,115200" ];
33 type = types.listOf types.str;
34 description = ''
35 Parameters added to the Memtest86+ command line. As of memtest86+ 5.01
36 the following list of (apparently undocumented) parameters are
37 accepted:
38
39 - `console=...`, set up a serial console.
40 Examples:
41 `console=ttyS0`,
42 `console=ttyS0,9600` or
43 `console=ttyS0,115200n8`.
44
45 - `btrace`, enable boot trace.
46
47 - `maxcpus=N`, limit number of CPUs.
48
49 - `onepass`, run one pass and exit if there
50 are no errors.
51
52 - `tstlist=...`, list of tests to run.
53 Example: `0,1,2`.
54
55 - `cpumask=...`, set a CPU mask, to select CPUs
56 to use for testing.
57
58 This list of command line options was obtained by reading the
59 Memtest86+ source code.
60 '';
61 };
62
63 };
64 };
65
66 config = mkIf cfg.enable {
67 boot.loader.grub.extraEntries = ''
68 menuentry "Memtest86+" {
69 linux @bootRoot@/memtest.bin ${toString cfg.params}
70 }
71 '';
72 boot.loader.grub.extraFiles."memtest.bin" = "${memtest86}/memtest.bin";
73 };
74}