Skip to content

Commit f7500b5

Browse files
authored
Moving NOP Linux install directives to documentation (#96)
1 parent 87bda28 commit f7500b5

File tree

1 file changed

+128
-1
lines changed

1 file changed

+128
-1
lines changed

content/en/docs/cluster/nop-linux.md

Lines changed: 128 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,131 @@ When benchmarking software it is important to have reproducible results between
1010

1111
We recommend tuning the Linux OS on all linux measurement machines that you have in your cluster to get the highest reproducability out of your measurement runs.
1212

13-
For a detailed description on how to produce your own NOP Linux instance visit [our blog article on NOP Linux](https://www.green-coding.io/blog/nop-linux/).
13+
The following script configures an Ubuntu 22.04+ system to have no active timers running, remove all unneeded services and disable also
14+
NTP.
15+
16+
The goal is to keep the system still very close to a production / user setup, but remove invariances from the system without
17+
decreasing idle power draw and skewing results.
18+
19+
Please further note that you must execute certain service still periodically. The [client.py](https://github.com/green-coding-solutions/green-metrics-tool/blob/main/cron/client.py) cluster service will periodically run [a cleanup script](https://github.com/green-coding-solutions/green-metrics-tool/blob/main/tools/cluster/cleanup_original.py)
20+
21+
```bash
22+
#!/bin/bash
23+
set -euox pipefail
24+
25+
# this is a patch. Firefox seems to have a trick to remove read-only filesystem. We need to unmount that first
26+
sudo umount /var/snap/firefox/common/host-hunspell || true
27+
28+
# remov all snaps first as they mount read only filesystem that only snap itself can find and unmount
29+
for i in {1..3}; do # we do this three times as packages depends on one another
30+
for snap_pkg in $(snap list | awk 'NR>1 {print $1}'); do sudo snap remove --purge "$snap_pkg"; done
31+
done
32+
33+
34+
# Remove all the packages we don't need
35+
sudo apt purge -y --purge snapd cloud-guest-utils cloud-init apport apport-symptoms cryptsetup cryptsetup-bin cryptsetup-initramfs curl gdisk lxd-installer mdadm open-iscsi snapd squashfs-tools ssh-import-id wget xauth unattended-upgrades update-notifier-common python3-update-manager unattended-upgrades needrestart command-not-found cron lxd-agent-loader modemmanager motd-news-config pastebinit packagekit
36+
sudo systemctl daemon-reload
37+
sudo apt autoremove -y --purge
38+
39+
# Get newest versions of everything
40+
sudo apt update
41+
42+
sudo apt install psmisc -y
43+
44+
# on some versions killall might be missing. Please insta
45+
sudo killall unattended-upgrade-shutdown
46+
47+
sudo apt upgrade -y
48+
49+
# These are packages that are installed through the update
50+
sudo apt remove -y --purge networkd-dispatcher multipath-tools
51+
52+
sudo apt autoremove -y --purge
53+
54+
# These are user running services
55+
systemctl --user disable --now snap.firmware-updater.firmware-notifier.timer
56+
systemctl --user disable --now launchpadlib-cache-clean.timer
57+
systemctl --user disable --now snap.snapd-desktop-integration.snapd-desktop-integration.service
58+
59+
60+
# Disable services that might do things
61+
sudo systemctl disable --now apt-daily-upgrade.timer
62+
sudo systemctl disable --now apt-daily.timer
63+
sudo systemctl disable --now dpkg-db-backup.timer
64+
sudo systemctl disable --now e2scrub_all.timer
65+
sudo systemctl disable --now fstrim.timer
66+
sudo systemctl disable --now motd-news.timer
67+
sudo systemctl disable --now e2scrub_reap.service
68+
sudo systemctl disable --now tinyproxy.service
69+
sudo systemctl disable --now anacron.timer
70+
71+
72+
# these following timers might be missing on newer ubuntus
73+
sudo systemctl disable --now systemd-tmpfiles-clean.timer
74+
sudo systemctl disable --now fwupd-refresh.timer
75+
sudo systemctl disable --now logrotate.timer
76+
sudo systemctl disable --now ua-timer.timer
77+
sudo systemctl disable --now man-db.timer
78+
79+
sudo systemctl disable --now sysstat-collect.timer
80+
sudo systemctl disable --now sysstat-summary.timer
81+
82+
sudo systemctl disable --now systemd-journal-flush.service
83+
sudo systemctl disable --now systemd-timesyncd.service
84+
85+
sudo systemctl disable --now systemd-fsckd.socket
86+
sudo systemctl disable --now systemd-initctl.socket
87+
88+
sudo systemctl disable --now cryptsetup.target
89+
90+
sudo systemctl disable --now power-profiles-daemon.service
91+
sudo systemctl disable --now thermald.service
92+
sudo systemctl disable --now anacron.service
93+
94+
95+
96+
# Packages to install for editing and later bluetooth. some of us prefer nano, some vim :)
97+
sudo apt install -y vim nano bluez
98+
99+
# Setup networking
100+
NET_NAME=$(sudo networkctl list "en*" --no-legend | cut -f 4 -d " ")
101+
cat <<EOT | sudo tee /etc/systemd/network/en.network
102+
[Match]
103+
Name=$NET_NAME
104+
105+
[Network]
106+
DHCP=ipv4
107+
EOT
108+
109+
# Disable NTP
110+
sudo timedatectl set-ntp false
111+
112+
# Disable the kernel watchdogs
113+
echo 0 | sudo tee /proc/sys/kernel/soft_watchdog
114+
echo 0 | sudo tee /proc/sys/kernel/nmi_watchdog
115+
echo 0 | sudo tee /proc/sys/kernel/watchdog
116+
echo 0 | sudo tee /proc/sys/kernel/watchdog_thresh
117+
118+
# Removes the large header when logging in
119+
sudo rm /etc/update-motd.d/*
120+
121+
# Remove all cron files. Cron shouldn't be running anyway but just to be safe
122+
rm -R /etc/cron*
123+
124+
sudo apt autoremove -y --purge
125+
126+
# Desktop systems have NetworkManager. Here we want to disable the periodic check to Host: connectivity-check.ubuntu.com.
127+
if [ -f "/etc/NetworkManager/NetworkManager.conf" ]; then
128+
echo "[connectivity]" >> /etc/NetworkManager/NetworkManager.conf
129+
echo "uri=" >> /etc/NetworkManager/NetworkManager.conf
130+
echo "interval=0" >> /etc/NetworkManager/NetworkManager.conf
131+
else
132+
echo "NetworkManager configuration file seems not to exist. Probably non desktop system"
133+
fi
134+
135+
# List all timers and services to validate we have nothing left
136+
sudo systemctl list timers
137+
systemctl --user list-timers
138+
139+
echo "All done. Please reboot system!"
140+
```

0 commit comments

Comments
 (0)