Problem
A process named dropbear consumes a high percentage of CPU continuously (20%+ of one core, accumulating hundreds of CPU-minutes over a couple of days of uptime), even though no dropbear SSH server is running:
root 350 12.2 0.0 3072 1728 ? S Okt30 375:36 /bin/sh /scripts/init-premount/dropbearMeanwhile systemctl status dropbear shows the actual service failed at boot and nothing is listening for dropbear.
Diagnosis
The process is not the dropbear SSH daemon. It is a leftover shell from the initramfs — the dropbear-initramfs package (used for remote LUKS passphrase entry during early boot) installs /scripts/init-premount/dropbear, a path that does not even exist on the booted root filesystem:
ls: cannot access '/scripts/init-premount/dropbear': No such file or directoryYou can confirm it is an initramfs survivor by inspecting /proc/<pid>:
$ readlink /proc/350/exe
/usr/bin/sh (deleted)
$ ls -l /proc/350/fd
0 -> /dev/null
1 -> /dev/console (deleted)
2 -> /dev/console (deleted)
$ cat /proc/350/stack
do_wait
kernel_wait4
__do_sys_wait4The deleted executable and the dangling /dev/console file descriptors prove its entire filesystem — the initramfs — was destroyed during switch_root.
Root cause
/scripts/init-premount/dropbear ends with:
run_dropbear &
echo $! >/run/dropbear.pidrun_dropbear runs configure_networking (DHCP via ipconfig) and then execs /sbin/dropbear in the foreground. The init-bottom/dropbear script is supposed to kill this background subshell before switch_root — but its wait_for_dropbear() only kills it after it has exec’ed the dropbear binary:
while [ $timer -gt 0 ] && exe="$(readlink -f "/proc/$pid/exe" 2>/dev/null)"; do
if [ "$exe" = "$EXE" ]; then
echo "$pid"
return 0
fi
sleep 1
timer=$(( timer - 1 ))
done
return 1If configure_networking never finishes — for example on a Wi-Fi-only laptop (initramfs cannot do Wi-Fi) or any boot where DHCP never succeeds — the subshell never execs dropbear, the 60-second timeout expires, the kill is skipped, and the subshell survives switch_root. Since every external command (sleep, ipconfig, …) it tries to run no longer exists, each loop iteration fails instantly — a busy loop that burns CPU forever.
Solution
1. Kill the leftover process
sudo kill -TERM 350 # substitute your PIDSIGTERM is sufficient — the shell has no signal handlers. Use kill -9 if it somehow persists.
2. Prevent it from coming back on the next boot
Add an initramfs init-bottom script that kills whatever the dropbear pidfile still points at after dropbear’s own cleanup ran. This runs after the packaged cleanup (scripts run in ORDER sequence, and a zzz_ prefix sorts last), so it only fires when the normal path already failed — remote LUKS unlock keeps working normally:
#!/bin/sh
PREREQ=""
prereqs() {
echo "$PREREQ"
}
case "$1" in
prereqs)
prereqs
exit 0
;;
esac
# dropbear-initramfs's own init-bottom script only kills the run_dropbear()
# subshell once it has exec'ed /sbin/dropbear. If configure_networking()
# never finishes (no usable NIC at boot, e.g. Wi-Fi-only machines), the
# subshell survives switch_root and spins at high CPU on a deleted
# filesystem. Kill whatever the pidfile still points at, plus its children.
PID=$(cat /run/dropbear.pid 2>/dev/null) || exit 0
[ -n "$PID" ] || exit 0
sed -nr "s/^([0-9]+) \(.*\) \S $PID .*/\1/p" /proc/[0-9]*/stat 2>/dev/null |
while read -r child; do kill -9 "$child" 2>/dev/null; done
kill -9 "$PID" 2>/dev/null
rm -f /run/dropbear.pid
exit 0Make it executable and rebuild all initramfs images:
sudo chmod 755 /etc/initramfs-tools/scripts/init-bottom/zzz_dropbear_survivor
sudo update-initramfs -u -k allVerify it is included, listed after dropbear in the init-bottom sequence:
$ lsinitramfs /boot/initrd.img-$(uname -r) | grep init-bottom
scripts/init-bottom
scripts/init-bottom/ORDER
scripts/init-bottom/dropbear
scripts/init-bottom/plymouth
scripts/init-bottom/udev
scripts/init-bottom/zzz_dropbear_survivor3. Optional: disable the redundant dropbear.service
On systems where OpenSSH (or its ssh.socket activation unit) already owns port 22, dropbear.service can never start and fails at every boot with Failed listening on '22': Address already in use. Disable it:
sudo systemctl disable dropbear.serviceThis only affects the post-boot SSH daemon — it does not affect dropbear-initramfs remote unlocking, which lives entirely inside the initramfs.
Note on remote LUKS unlock
Remote unlocking only works if the machine has a wired NIC with DHCP (or a static ip= kernel parameter) at boot — the stock initramfs cannot configure Wi-Fi. If the subshell was spinning, remote unlock could not have worked on that boot anyway. To make it reliable on ethernet boots, add ip=dhcp (or a full ip=<client-ip>::<gw>:<netmask>::<iface>:dhcp line) to your kernel cmdline and rebuild the initramfs as shown above.
For a complete setup of remote LUKS passphrase entry with dropbear-initramfs, see Ansible playbook to setup Initramfs Dropbear for LUKS decryption over SSH.