The systemd-shutdown process is blocking your system from shutting down because a critical service or unit is refusing to stop gracefully.
Here are the common culprits and how to fix them:
1. A Stalled Network Manager
Sometimes NetworkManager gets stuck trying to bring down interfaces or reconfigure routes, holding up the entire shutdown sequence.
-
Diagnosis: Look for messages like
A start job is running for NetworkManager...orNetworkManager-wait-online.servicein yourjournalctl -xboutput during shutdown. You can also check the status of NetworkManager directly:systemctl status NetworkManager.serviceIf it’s
activatingordeactivatingfor an extended period, this is likely your issue. -
Fix: You can force-restart NetworkManager if it’s truly stuck, though this isn’t ideal for production systems. For a quick fix during a hang:
systemctl restart NetworkManager.serviceIf this doesn’t work, you might need to specifically address why it’s stalling. Often, it’s related to DNS resolution or DHCP lease renewal failures. Check
journalctl -u NetworkManagerfor specific errors. A more robust fix involves configuring NetworkManager to not be a blocker during shutdown. Edit/etc/NetworkManager/conf.d/10-unmanaged-devices.conf(or create it) and ensure it looks like this:[keyfile] unmanaged-devices=interface-name:eth0;interface-name:wlan0Replace
eth0andwlan0with your actual interface names. This tells NetworkManager to ignore these devices, preventing it from getting stuck on them.Another common cause is
NetworkManager-wait-online.service. You can disable this service if your system doesn’t strictly need to wait for network connectivity before proceeding with shutdown:systemctl disable NetworkManager-wait-online.serviceThis allows shutdown to continue even if the network isn’t fully up or down.
2. A Frozen systemd-udevd
The device manager udev can sometimes hang if it encounters a problematic device or driver during its shutdown phase, preventing other services from stopping.
-
Diagnosis: In
journalctl -xb, you’ll seesystemd-udevd.servicetaking a long time to stop. You might seeA start job is running for udev Kernel Device Manager.... -
Fix: There’s no direct "restart
udev" command that fixes a hang. The problem is usually with a specific device or driver. Checkjournalctl -u systemd-udevdfor errors related to specific devices (e.g., USB devices, storage controllers). If you identify a problematic device, you might need to:- Unplug it: If it’s an external device (like a USB drive) that’s causing the hang, unplugging it before shutdown can resolve the issue.
- Blacklist the driver: If it’s an internal component, you might need to blacklist its kernel module. For example, to blacklist the
usb-storagemodule, create a file/etc/modprobe.d/blacklist-usb-storage.confwith the content:
Then, rebuild your initramfs (e.g.,blacklist usb-storageupdate-initramfs -uon Debian/Ubuntu,dracut -fon Fedora/CentOS) and reboot.
3. A Non-Responsive Application Service
Many applications run as systemd services. If an application’s stop command hangs indefinitely, it will block shutdown.
-
Diagnosis: Use
journalctl -xbto identify which service unit is taking an unusually long time to stop. Look for lines likeA stop job is running for <service-name>.service. -
Fix:
- Graceful Restart: First, try restarting the service manually to see if it hangs then:
If it hangs here, investigate the application logs (e.g.,systemctl restart <service-name>.service/var/log/myapp.logorjournalctl -u <service-name>) for errors during shutdown. The application might be failing to save data, close connections, or release resources. - Adjust
TimeoutStopSec: In the service’s unit file (e.g.,/etc/systemd/system/<service-name>.serviceor/usr/lib/systemd/system/<service-name>.service), you can increase the timesystemdwaits for the service to stop. The default is often 90 seconds. Edit the unit file and add or modify:
This gives the service 300 seconds (5 minutes) to stop. After editing, reload[Service] TimeoutStopSec=300systemdand restart the service:systemctl daemon-reload systemctl restart <service-name>.service - Forceful Stop (Last Resort): If the service consistently hangs and you cannot fix its internal shutdown logic, you can configure
systemdto kill it forcefully after a timeout. In the[Service]section of the unit file:[Service] KillMode=mixed TimeoutStopSec=30KillMode=mixed(orprocess) ensures thatsystemdsendsSIGTERMto the main process and thenSIGKILLif it doesn’t exit withinTimeoutStopSec.KillMode=processis safer as it only kills the main process,KillMode=control-groupkills everything in the cgroup. Usemixedorprocesswith caution as it can lead to data corruption if the application is in the middle of writing.
- Graceful Restart: First, try restarting the service manually to see if it hangs then:
4. systemd-journald Buffering Issues
If the journal is configured to buffer logs to disk and the disk becomes unavailable or full, journald might hang during shutdown as it tries to flush its buffers.
-
Diagnosis: Look for
systemd-journald.servicetaking a long time to stop injournalctl -xb. You might see disk I/O errors or "no space left on device" messages related to/var/log/journal. -
Fix:
- Check Disk Space: Ensure the partition where
/var/log/journalresides has sufficient free space.
If it’s full, free up space by deleting old logs or resizing the partition.df -h /var/log/journal - Journal Configuration: Examine
/etc/systemd/journald.conf. IfStorage=autoorStorage=persistentis set and the disk is problematic,journaldwill try to write. You can temporarily setStorage=volatileto makejournaldonly use RAM, which will prevent it from blocking shutdown due to disk issues.
Reload[Journal] Storage=volatilesystemdafter changes:
This is a workaround; the real fix is to address the underlying disk problem.systemctl daemon-reload
- Check Disk Space: Ensure the partition where
5. A Frozen Mount Point
If a filesystem mounted via systemd units (e.g., an NFS mount, a CIFS mount, or even a local filesystem with a faulty fsck check) becomes unresponsive, it can block shutdown.
-
Diagnosis: Check
journalctl -xbforA stop job is running for remote-fs.targetor specific mount units (mnt-mydata.mount). You might seeumountcommands timing out. -
Fix:
- Check
fstabandsystemdMount Units: Ensure there are no problematic entries in/etc/fstabor corresponding.mountfiles in/etc/systemd/system/. For network mounts (NFS, CIFS), ensure the server is reachable and the mount options are correct. - Add
nofailOption: For non-critical mounts, especially network ones, add thenofailoption to theirfstabentry. For example, for an NFS mount:
Thenfsserver:/exports/data /mnt/data nfs defaults,nofail,_netdev 0 0nofailoption tellssystemdnot to consider the system failed if the mount cannot be established or unmounted, allowing shutdown to proceed. The_netdevoption is also important for network mounts, indicating that they require network access. - Manual Unmount: If you can identify the specific mount point causing issues, try unmounting it manually before attempting a shutdown.
Theumount -l /mnt/mydata-loption performs a lazy unmount, detaching the filesystem from the hierarchy now and cleaning up references later.
- Check
6. systemd-logind Waiting for User Sessions
If logind is configured to wait for all user sessions to be terminated, and a session is somehow stuck or unresponsive, it can delay shutdown.
-
Diagnosis: You might see
A stop job is running for Session ...orsystemd-logind.servicetaking a long time. -
Fix: This is rare, but can happen if a graphical session crashes and doesn’t properly log out.
- Check Active Sessions:
If you see a session that appears stuck or is not associated with an active user, you can try terminating it:loginctl list-sessionsloginctl terminate-session <session-id> - Configure
KillUserProcesses: In/etc/systemd/logind.conf, ensureKillUserProcesses=yesis uncommented. This tellslogindto kill all processes associated with a user when their session ends, preventing lingering processes from blocking shutdown.
Reload[Login] KillUserProcesses=yessystemdafter changes:systemctl daemon-reload
- Check Active Sessions:
After addressing the specific cause, the next error you might encounter is a timeout during a different service’s shutdown, or potentially an unclean shutdown if the fix involved forceful termination.