/dev/sda1 磁盘已满-使用率 100%

/dev/sda1 磁盘已满-使用率 100%

我的 Ubuntu 16.04 系统的启动分区已完全满,我在尝试修复它时遇到了问题。

$ df -h
udev                        2,9G       0  2,9G    0% /dev
tmpfs                       597M     63M  535M   11% /run
/dev/mapper/user--vg-root   109G     67G   37G   65% /
tmpfs                       3,0G     13M  3,0G    1% /dev/shm
tmpfs                       5,0M       0  5,0M    0% /run/lock
tmpfs                       3,0G       0  3,0G    0% /sys/fs/cgroup
/dev/sda1                   472M    471M     0  100% /boot
tmpfs                       597M       0  597M    0% /run/user/999
tmpfs                       597M       0  597M    0% /run/user/1000

我尝试过sudo apt-get autoremove但失败了:

Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 linux-image-extra-4.4.0-96-generic : Depends: linux-image-4.4.0-96-generic but it is not installed
 linux-image-generic : Depends: linux-image-4.4.0-96-generic but it is not installed
                       Recommends: thermald but it is not installed
 E: Unmet dependencies. Try using -f.

使用时-f会出现没有剩余空间的错误......

可能需要这些信息:

 $ dpkg -l | grep linux
 ii  console-setup-linux                1.108ubuntu15.3                            all          Linux specific part of console-setup
 ii  libselinux1:amd64                  2.4-3build2                                amd64        SELinux runtime shared libraries
 ii  linux-base                         4.0ubuntu1                                 all          Linux image base package
 iF  linux-firmware                     1.157.11                                   all          Firmware for Linux kernel drivers
 iU  linux-generic                      4.4.0.96.101                               amd64        Complete Generic Linux kernel and headers
 ii  linux-headers-4.4.0-64             4.4.0-64.85                                all          Header files related to Linux kernel version 4.4.0
 ii  linux-headers-4.4.0-64-generic     4.4.0-64.85                                amd64        Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
 ii  linux-headers-4.4.0-66             4.4.0-66.87                                all          Header files related to Linux kernel version 4.4.0
 ii  linux-headers-4.4.0-66-generic     4.4.0-66.87                                amd64        Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
 ii  linux-headers-4.4.0-70             4.4.0-70.91                                all          Header files related to Linux kernel version 4.4.0
 ii  linux-headers-4.4.0-70-generic     4.4.0-70.91                                amd64        Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
 ii  linux-headers-4.4.0-71             4.4.0-71.92                                all          Header files related to Linux kernel version 4.4.0
 ii  linux-headers-4.4.0-71-generic     4.4.0-71.92                                amd64        Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
 ii  linux-headers-4.4.0-72             4.4.0-72.93                                all          Header files related to Linux kernel version 4.4.0
 ii  linux-headers-4.4.0-72-generic     4.4.0-72.93                                amd64        Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
 ii  linux-headers-4.4.0-75             4.4.0-75.96                                all          Header files related to Linux kernel version 4.4.0
 ii  linux-headers-4.4.0-75-generic     4.4.0-75.96                                amd64        Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
 ii  linux-headers-4.4.0-78             4.4.0-78.99                                all          Header files related to Linux kernel version 4.4.0
 ii  linux-headers-4.4.0-78-generic     4.4.0-78.99                                amd64        Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
 ii  linux-headers-4.4.0-79             4.4.0-79.100                               all          Header files related to Linux kernel version 4.4.0
 ii  linux-headers-4.4.0-79-generic     4.4.0-79.100                               amd64        Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
 ii  linux-headers-4.4.0-81             4.4.0-81.104                               all          Header files related to Linux kernel version 4.4.0
 ii  linux-headers-4.4.0-81-generic     4.4.0-81.104                               amd64        Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
 ii  linux-headers-4.4.0-83             4.4.0-83.106                               all          Header files related to Linux kernel version 4.4.0
 ii  linux-headers-4.4.0-83-generic     4.4.0-83.106                               amd64        Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
 ii  linux-headers-4.4.0-87             4.4.0-87.110                               all          Header files related to Linux kernel version 4.4.0
 ii  linux-headers-4.4.0-87-generic     4.4.0-87.110                               amd64        Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
 iU  linux-headers-4.4.0-96             4.4.0-96.119                               all          Header files related to Linux kernel version 4.4.0
 iU  linux-headers-4.4.0-96-generic     4.4.0-96.119                               amd64        Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
 iU  linux-headers-generic              4.4.0.96.101                               amd64        Generic Linux kernel headers
 rc  linux-image-4.4.0-21-generic       4.4.0-21.37                                amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
 ii  linux-image-4.4.0-64-generic       4.4.0-64.85                                amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
 ii  linux-image-4.4.0-66-generic       4.4.0-66.87                                amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
 ii  linux-image-4.4.0-70-generic       4.4.0-70.91                                amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
 ii  linux-image-4.4.0-71-generic       4.4.0-71.92                                amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
 ii  linux-image-4.4.0-72-generic       4.4.0-72.93                                amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
 ii  linux-image-4.4.0-75-generic       4.4.0-75.96                                amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
 ii  linux-image-4.4.0-78-generic       4.4.0-78.99                                amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
 ii  linux-image-4.4.0-79-generic       4.4.0-79.100                               amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
 ii  linux-image-4.4.0-81-generic       4.4.0-81.104                               amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
 iF  linux-image-4.4.0-83-generic       4.4.0-83.106                               amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
 iF  linux-image-4.4.0-87-generic       4.4.0-87.110                               amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
 rc  linux-image-extra-4.4.0-21-generic 4.4.0-21.37                                amd64        Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
 ii  linux-image-extra-4.4.0-64-generic 4.4.0-64.85                                amd64        Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
 ii  linux-image-extra-4.4.0-66-generic 4.4.0-66.87                                amd64        Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
 ii  linux-image-extra-4.4.0-70-generic 4.4.0-70.91                                amd64        Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
 ii  linux-image-extra-4.4.0-71-generic 4.4.0-71.92                                amd64        Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
 ii  linux-image-extra-4.4.0-72-generic 4.4.0-72.93                                amd64        Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
 ii  linux-image-extra-4.4.0-75-generic 4.4.0-75.96                                amd64        Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
 ii  linux-image-extra-4.4.0-78-generic 4.4.0-78.99                                amd64        Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
 ii  linux-image-extra-4.4.0-79-generic 4.4.0-79.100                               amd64        Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
 iF  linux-image-extra-4.4.0-81-generic 4.4.0-81.104                               amd64        Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
 iU  linux-image-extra-4.4.0-83-generic 4.4.0-83.106                               amd64        Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
 iU  linux-image-extra-4.4.0-87-generic 4.4.0-87.110                               amd64        Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
 rc  linux-image-extra-4.4.0-89-generic 4.4.0-89.112                               amd64        Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
 iU  linux-image-extra-4.4.0-96-generic 4.4.0-96.119                               amd64        Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
 iU  linux-image-generic                4.4.0.96.101                               amd64        Generic Linux kernel image
 iU  linux-libc-dev:amd64               4.4.0-89.112                               amd64        Linux Kernel Headers for development
 ii  linuxbrew-wrapper                  20150804-3                                 all          Missing Package Manager For Linux
 ii  util-linux                         2.27.1-6ubuntu3.3                          amd64        miscellaneous system utilities

答案1

这是purge-old-kernels来自的byobu 5.106-0ubuntu1

#!/bin/sh
#
#    purge-old-kernels - remove old kernel packages
#    Copyright (C) 2012 Dustin Kirkland <[email protected]>
#
#    Authors: Dustin Kirkland <[email protected]>
#             Kees Cook <[email protected]>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, version 3 of the License.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Ensure we're running as root
if [ "$(id -u)" != 0 ]; then
    echo "ERROR: This script must run as root.  Hint..." 1>&2
    echo "  sudo $0 $@" 1>&2
    exit 1
fi

# NOTE: This script will ALWAYS keep the currently running kernel
# NOTE: Default is to keep 2 more, user overrides with --keep N
KEEP=2
# NOTE: Any unrecognized option will be passed straight through to apt
APT_OPTS=
while [ ! -z "$1" ]; do
    case "$1" in
        --keep)
            # User specified the number of kernels to keep
            KEEP="$2"
            shift 2
        ;;
        *)
            APT_OPTS="$APT_OPTS $1"
            shift 1
        ;;
    esac
done

# Build our list of kernel packages to purge
CANDIDATES=$(ls -tr /boot/vmlinuz-* | head -n -${KEEP} | grep -v "$(uname -r)$" | cut -d- -f2- | awk '{print "linux-image-" $0 " linux-headers-" $0}' )
for c in $CANDIDATES; do
    dpkg-query -s "$c" >/dev/null 2>&1 && PURGE="$PURGE $c"
done

if [ -z "$PURGE" ]; then
    echo "No kernels are eligible for removal"
    exit 0
fi

apt $APT_OPTS remove --purge $PURGE

相关内容