You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何阻止apt执行任何操作?嵌入式Linux磁盘占用异常求助

Disable Automatic APT Updates on Embedded Linux (Stop Disk Usage Creep)

Got it, let's tackle this problem head-on. The disk usage creep you're seeing is almost certainly caused by apt's automatic update services quietly downloading package updates to your cache directory (/var/cache/apt/archives/) in the background. Since you don't need any updates at all, we can completely disable all of apt's automatic update-related behavior with these steps:

1. Stop and Disable APT's Systemd Services/Timers

APT relies on systemd timers and background services to trigger automatic updates. We need to stop, disable, and mask these components to ensure they never run again:

  • First, stop any currently running update services:
    sudo systemctl stop apt-daily.service apt-daily-upgrade.service
    
  • Disable them so they won't start on system boot:
    sudo systemctl disable apt-daily.service apt-daily-upgrade.service
    
  • Stop and disable the timers that trigger these services periodically:
    sudo systemctl stop apt-daily.timer apt-daily-upgrade.timer
    sudo systemctl disable apt-daily.timer apt-daily-upgrade.timer
    
  • Mask the services and timers to block any other system processes from triggering them:
    sudo systemctl mask apt-daily.service apt-daily-upgrade.service
    sudo systemctl mask apt-daily.timer apt-daily-upgrade.timer
    

2. Modify APT's Core Automatic Update Config

Next, we'll edit the config file that controls apt's periodic update behavior:

  • Open the config file with a simple editor like nano:
    sudo nano /etc/apt/apt.conf.d/20auto-upgrades
    
  • Set both values to 0 to disable package list updates and unattended upgrades entirely:
    APT::Periodic::Update-Package-Lists "0";
    APT::Periodic::Unattended-Upgrade "0";
    
  • Save and exit (in nano: press Ctrl+O, hit Enter, then Ctrl+X).

You already know this trick, but let's formalize it: run this command to clear all downloaded package cache and reclaim your disk space right away:

sudo apt-get clean

If you only want to remove outdated packages from the cache, use sudo apt-get autoclean instead—but clean will wipe the entire cache completely, which is ideal for your use case.

4. Verify the Changes

To confirm nothing is still scheduled to run, check for any remaining apt-related timers:

systemctl list-timers *apt*

If the output shows no active timers, you've successfully disabled all automatic apt update operations. Your disk usage should no longer creep up due to background apt activities.

内容的提问来源于stack exchange,提问作者Zephyr

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:20:41