Step 8 of 9 · lab · 20 min
A build runs out of memory
The nightly search index build fails for lack of memory, and it cannot be given more RAM. Give the machine a swap file that survives a reboot and set how readily the system uses it.
Situation
Every night the lab-build.timer timer starts the search index build of the docs site — the lab-build
service. The build is given 192 MiB of RAM: the site and the database need the rest. There are more pages now,
and the index has not been updated for several nights in a row. The build can be started in the daytime too:
sudo systemctl start lab-build.
The build cannot be given more RAM. The decision is to give the machine swap: whatever does not fit into 192 MiB goes to the disk — the build runs slower, but it finishes.
Task
- The swap is a file of exactly 512 MiB, and it is on. Process memory ends up in swap, so only root may read and write the file (mode 600).
- After a reboot the swap comes on by itself, and the swap lines in
/etc/fstabcause no errors at boot. - The system is reluctant to send memory to swap:
vm.swappiness= 10 now and after a reboot, and the setting is written as a file in/etc/sysctl.d. - The
sudo systemctl start lab-buildbuild passes — the check will start it itself. Do not change the build unit or its memory limit.
The machine has no internet access; the programs you need are already installed.
Lab · on your own
No commands are given in this lab: type them in the terminal yourself. Goals are checked on the machine after every command.
Goals
0 of 4-
A swap file of exactly 512 MiB is on, owned by root with mode 600 — not done yet
-
The swap file is listed in /etc/fstab, and there are no swap lines for files that do not exist — not done yet
-
vm.swappiness = 10 now and after a reboot, from a file in /etc/sysctl.d — not done yet
-
The nightly lab-build build passes within the same 192 MiB memory limit — not done yet
The machine is starting
Hints
0 of 3Lab goals
0 of 4-
A swap file of exactly 512 MiB is on, owned by root with mode 600 — not done yet
-
The swap file is listed in /etc/fstab, and there are no swap lines for files that do not exist — not done yet
-
vm.swappiness = 10 now and after a reboot, from a file in /etc/sysctl.d — not done yet
-
The nightly lab-build build passes within the same 192 MiB memory limit — not done yet
Goals are checked on the machine after every command.