/var 磁盘空间不足

Far*_*vic 3 partitioning gparted disk-usage

如果类似的问题已得到回答,我提前表示抱歉,但这些解决方案都不适合我。我刚开始使用 Ubuntu(现在 6-7 个月了),最近每当我启动笔记本电脑时,都会弹出一个警告,提示我的 /var 空间不足(还剩大约 100MB)。我一直在浏览论坛,尝试删除我的快照和一些日志文件,但它并没有通过自动删除和类似命令释放大量空间。如果对于我的问题没有比上面提到的更好的解决方案,如果有人至少能给我解释,我将非常感激。这些是我为 /var 分配了多少空间的屏幕截图以及 /var 中磁盘使用情况的屏幕截图。再次感谢您的宝贵时间,非常感谢!

格帕特

磁盘使用分析器

小智 5

这是在 Ubuntu 中清理/var存储问题的方法:

  1. 摆脱不再需要的包

    sudo apt-get autoremove
    
    Run Code Online (Sandbox Code Playgroud)
  2. 从商店中卸载不必要的应用程序。

  3. 清理 Ubuntu 中的 APT 缓存

    sudo du -sh /var/cache/apt # see the size of cache you have
    sudo apt-get clean  # to clean the cache
    
    Run Code Online (Sandbox Code Playgroud)
  4. 清除systemd日志日志

    journalctl --disk-usage # check the storage used in old logs
    sudo journalctl --vacuum-time=3d # to clear logs before 3 days - number before d can be changed
    
    Run Code Online (Sandbox Code Playgroud)
  5. 删除旧版本的 Snap 应用程序。使用任意名称和扩展名创建文件.sh并粘贴以下脚本

    #!/bin/bash
    # Removes old revisions of snaps
    # CLOSE ALL SNAPS BEFORE RUNNING THIS
    set -eu
    LANG=C snap list --all | awk '/disabled/{print $1, $3}' |
        while read snapname revision; do
            snap remove "$snapname" --revision="$revision"
        done
    
    Run Code Online (Sandbox Code Playgroud)

    然后在终端中使用此命令使其可执行

    chmod +x <fileName>
    
    Run Code Online (Sandbox Code Playgroud)

    使用 运行脚本./<fileName>

  6. 清理缩略图缓存

    du -sh ~/.cache/thumbnails # check the thumbnails size
    rm -rf ~/.cache/thumbnails/* # clean the thumbnails 
    
    Run Code Online (Sandbox Code Playgroud)