Purpose: A complete Linux sysadmin guide and automated bash script to permanently disable background APT periodic updates, unattended upgrades, and systemd firmware refresh timers that cause Ubuntu boot hangs and display manager (GDM3) lockups.
Whether on a high-performance workstation, headless server, or specialized lab machine, encountering an Ubuntu system that hangs during boot or refuses to initialize the graphical display manager (gdm3 / lightdm) can be extremely frustrating.
This guide details the exact root cause of boot-time update freezes and provides a step-by-step fix—along with an automated script—to reclaim total control over when your Ubuntu system updates.
📦 1-Click Script Download
1. Root Cause & Symptoms
The Symptoms
- Upon turning on the machine, Ubuntu hangs indefinitely at a blank screen or blinking cursor.
- The desktop display manager (
gdm3orsddm) fails to present the login interface. - Manual terminal execution of
apt updateordpkgreturns lock errors:text E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 1420 (unattended-upgr)
The Root Cause
By default, Ubuntu enables background systemd timers (apt-daily.timer, apt-daily-upgrade.timer, and fwupd-refresh.timer) that fire immediately upon system boot or network acquisition.
When these services launch:
1. unattended-upgrades grabs exclusive DPKG locks (/var/lib/dpkg/lock-frontend) to check for security patches.
2. If graphics drivers, kernel modules, or display dependencies are queued, GPU initialization stalls while waiting for APT locks to release.
3. On systems with multi-GPU setups, custom kernel parameters, or heavy background services, this race condition freezes the display manager initialization sequence.
2. Step-by-Step Resolution
To eliminate boot lockups permanently, we must disable automatic updates across two distinct system layers: APT Periodic Configuration and Systemd Services & Timers.
Step 2.1: Disabling APT Periodic Automations
APT reads configuration files inside /etc/apt/apt.conf.d/. We disable automatic package list refreshes, downloading, and auto-upgrades by editing /etc/apt/apt.conf.d/20auto-upgrades and /etc/apt/apt.conf.d/10periodic:
sudo cat << 'EOF' > /etc/apt/apt.conf.d/20auto-upgrades
APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::AutocleanInterval "0";
APT::Periodic::Unattended-Upgrade "0";
EOF
sudo cp /etc/apt/apt.conf.d/20auto-upgrades /etc/apt/apt.conf.d/10periodic
Step 2.2: Disabling Systemd Timers & Masking Services
Timers can still trigger background update units if not stopped, disabled, and masked. Masking creates a symlink to /dev/null, preventing any service or dependency from spawning the process.
# 1. Stop active background timers and services
sudo systemctl stop apt-daily.timer apt-daily-upgrade.timer fwupd-refresh.timer unattended-upgrades.service 2>/dev/null || true
# 2. Disable systemd timers
sudo systemctl disable apt-daily.timer apt-daily-upgrade.timer fwupd-refresh.timer unattended-upgrades.service 2>/dev/null || true
# 3. Mask services so they cannot be started automatically
sudo systemctl mask apt-daily.service apt-daily-upgrade.service fwupd-refresh.service 2>/dev/null || true
3. Full Automation Script (fix_autoupdates.sh)
Below is the complete bash automation script to fix APT configurations, clean broken unit symlinks, mask services, and verify parameters in one command:
▶ Click to View Source Code: fix_autoupdates.sh
#!/usr/bin/env bash
# ==============================================================================
# Purpose: Disable all Ubuntu automatic updates (APT periodic, unattended upgrades,
# fwupd firmware refresh timers) to prevent boot delays & display manager freezes.
# ==============================================================================
set -e
echo "=== 1. Fixing APT Configuration Files ==="
cat << 'EOF' > /etc/apt/apt.conf.d/20auto-upgrades
APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::AutocleanInterval "0";
APT::Periodic::Unattended-Upgrade "0";
EOF
cp /etc/apt/apt.conf.d/20auto-upgrades /etc/apt/apt.conf.d/10periodic
echo "APT configuration files fixed."
echo "=== 2. Cleaning Up Invalid Systemd Services ==="
rm -f /etc/systemd/system/fwupd-.service /etc/systemd/system/fwupd-refresh.service
echo "=== 3. Disabling Background Systemd Timers & Services ==="
systemctl stop apt-daily.timer apt-daily-upgrade.timer fwupd-refresh.timer unattended-upgrades.service 2>/dev/null || true
systemctl disable apt-daily.timer apt-daily-upgrade.timer fwupd-refresh.timer unattended-upgrades.service 2>/dev/null || true
systemctl mask apt-daily.service apt-daily-upgrade.service fwupd-refresh.service 2>/dev/null || true
echo "=== 4. Verifying APT Configuration ==="
apt-config dump | grep Periodic
echo "=== All Auto-Updates Have Been Successfully Disabled! ==="
4. Verification
After executing the script or manual commands, verify that all APT periodic settings evaluate to "0":
apt-config dump | grep Periodic
Expected Output:
APT::Periodic ""
APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::AutocleanInterval "0";
APT::Periodic::Unattended-Upgrade "0";
Your system will now boot cleanly and instantly without waiting for background APT locks or unattended upgrade tasks. Updates can still be performed manually at any time by running sudo apt update && sudo apt upgrade.