无法删除旧内核/sda 已满

无法删除旧内核/sda 已满

SDA1 已满,我无法运行升级

root@ubuntu-nextcloud:/home/nextcloud# df -h
Filesystem                              Size  Used Avail Use% Mounted on
udev                                    6.9G     0  6.9G   0% /dev
tmpfs                                   1.4G  9.0M  1.3G   1% /run
/dev/mapper/ubuntu--nextcloud--vg-root  585G  273G  282G  50% /
tmpfs                                   4.0G     0  4.0G   0% /dev/shm
tmpfs                                   5.0M     0  5.0M   0% /run/lock
tmpfs                                   4.0G     0  4.0G   0% /sys/fs/cgroup
/dev/loop0                              179M  179M     0 100% /snap/nextcloud/1474
/dev/loop1                               80M   80M     0 100% /snap/core/1689
/dev/loop3                              161M  161M     0 100% /snap/nextcloud/1337
/dev/loop2                               79M   79M     0 100% /snap/core/1441
/dev/loop5                              179M  179M     0 100% /snap/nextcloud/1540
/dev/loop4                               79M   79M     0 100% /snap/core/1577
/dev/sda1                               472M  461M     0 100% /boot
tmpfs                                   829M     0  829M   0% /run/user/1000

有一堆旧内核,我想删除它们。

root@ubuntu-nextcloud:/home/nextcloud# dpkg --list | grep linux-image
ii  linux-image-4.4.0-31-generic       4.4.0-31.50                                amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-4.4.0-59-generic       4.4.0-59.80                                amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-4.4.0-62-generic       4.4.0-62.83                                amd64        Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-4.4.0-63-generic       4.4.0-63.84                                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-67-generic       4.4.0-67.88                                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
iF  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
iF  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-extra-4.4.0-31-generic 4.4.0-31.50                                amd64        Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-extra-4.4.0-59-generic 4.4.0-59.80                                amd64        Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-extra-4.4.0-62-generic 4.4.0-62.83                                amd64        Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-extra-4.4.0-63-generic 4.4.0-63.84                                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-67-generic 4.4.0-67.88                                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
iF  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
iU  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
iU  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
iU  linux-image-extra-4.4.0-77-generic 4.4.0-77.98                                amd64        Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
iU  linux-image-generic                4.4.0.77.83                                amd64        Generic Linux kernel image

无论我尝试什么,都不起作用:

root@ubuntu-nextcloud:/home/nextcloud# sudo apt-get purge linux-image-4.4.0-31-generic
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-31-generic : Depends: linux-image-4.4.0-31-generic but it is not going to be installed
 linux-image-extra-4.4.0-77-generic : Depends: linux-image-4.4.0-77-generic but it is not going to be installed
 linux-image-generic : Depends: linux-image-4.4.0-77-generic but it is not going to be installed
                       Recommends: thermald but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

下次尝试

root@ubuntu-nextcloud:/home/nextcloud# purge-old-kernels --keep 3
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-31-generic : Depends: linux-image-4.4.0-31-generic but it is not going to be installed
 linux-image-extra-4.4.0-59-generic : Depends: linux-image-4.4.0-59-generic but it is not going to be installed
 linux-image-extra-4.4.0-62-generic : Depends: linux-image-4.4.0-62-generic but it is not going to be installed
 linux-image-extra-4.4.0-63-generic : Depends: linux-image-4.4.0-63-generic but it is not going to be installed
 linux-image-extra-4.4.0-64-generic : Depends: linux-image-4.4.0-64-generic but it is not going to be installed
 linux-image-extra-4.4.0-66-generic : Depends: linux-image-4.4.0-66-generic but it is not going to be installed
 linux-image-extra-4.4.0-67-generic : Depends: linux-image-4.4.0-67-generic but it is not going to be installed
 linux-image-extra-4.4.0-70-generic : Depends: linux-image-4.4.0-70-generic but it is not going to be installed
 linux-image-extra-4.4.0-77-generic : Depends: linux-image-4.4.0-77-generic but it is not going to be installed
 linux-image-generic : Depends: linux-image-4.4.0-77-generic but it is not going to be installed
                       Recommends: thermald but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

下次尝试

root@ubuntu-nextcloud:/home/nextcloud# dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | grep -E "(image|headers)" | xargs sudo apt-get -y purge
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-77-generic : Depends: linux-image-4.4.0-77-generic but it is not going to be installed
 linux-image-generic : Depends: linux-image-4.4.0-77-generic but it is not going to be installed
                       Recommends: thermald but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

最后的想法

    root@ubuntu-nextcloud:/home/nextcloud# apt-get autoremove -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  linux-image-4.4.0-77-generic
Suggested packages:
  fdutils linux-doc-4.4.0 | linux-source-4.4.0 linux-tools
The following NEW packages will be installed:
  linux-image-4.4.0-77-generic
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
12 not fully installed or removed.
Need to get 0 B/21.9 MB of archives.
After this operation, 66.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 414438 files and directories currently installed.)
Preparing to unpack .../linux-image-4.4.0-77-generic_4.4.0-77.98_amd64.deb ...
Done.
Unpacking linux-image-4.4.0-77-generic (4.4.0-77.98) ...
dpkg: error processing archive /var/cache/apt/archives/linux-image-4.4.0-77-generic_4.4.0-77.98_amd64.deb (--unpack):
 cannot copy extracted data for './boot/abi-4.4.0-77-generic' to '/boot/abi-4.4.0-77-generic.dpkg-new': failed to write (No space left on device)
No apport report written because the error message indicates a disk full error
                                                                              dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.4.0-77-generic /boot/vmlinuz-4.4.0-77-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.4.0-77-generic /boot/vmlinuz-4.4.0-77-generic
Errors were encountered while processing:
 /var/cache/apt/archives/linux-image-4.4.0-77-generic_4.4.0-77.98_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@ubuntu-nextcloud:/home/nextcloud# 

编辑:只需将旧内核文件暂时移动到临时文件夹,即可创建少量空间并让命令再次工作。

答案1

cd /boot

在目录中找到最旧的内核/boot

sudo dpkg --force-all -P Full_name_of_oldest_kernel
sudo apt autoremove --purge

有多种方法可以自动执行上述命令以实现可持续性。cron job例如。

答案2

我成功了:

  1. 创建一个临时文件夹(例如 /home/user/temp)
  2. 运行 uname -r 来确定哪个内核正在运行,不要触碰它!
  3. 将特定未使用的内核的内核文件移动到此临时文件夹。

您将获得一些空间,并且命令应该可以再次工作。来源:http://natesbox.com/blog/ubuntu-unable-to-installupdate-packages-full-boot-partition/

附言:我忘记为该服务器设置自动删除以进行自动更新。我认为这可能是导致问题的原因。

相关内容