我正在尝试删除 Ubuntu 17.10 上的旧内核,但遇到了未满足依赖项错误。我当前的内核是 linux 4.13.0-38-generic。
我的输出dpkg -l | grep linux-image | awk '{print$2}
是这样的:
linux-image-4.13.0-36-generic
linux-image-4.13.0-37-generic
linux-image-4.13.0-38-generic
linux-image-4.13.0-39-generic
linux-image-extra-4.13.0-36-generic
linux-image-extra-4.13.0-37-generic
linux-image-extra-4.13.0-38-generic
linux-image-extra-4.13.0-39-generic
linux-image-extra-4.13.0-41-generic
linux-image-generic
当我尝试删除旧内核(sudo apt-get purge linux-image-x.x.x-x-generic
)时出现以下错误:
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
linux-image-extra-4.13.0-41-generic : Depends: linux-image-4.13.0-41-generic but it is not installed
linux-image-generic : Depends: linux-image-4.13.0-41-generic but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
为了修复损坏的依赖关系,我使用sudo apt --fix-broken install
,当询问是否要继续时单击“是”,并得到以下输出:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
libqpdf18 linux-headers-4.13.0-37 linux-headers-4.13.0-37-generic
linux-image-4.13.0-37-generic linux-image-extra-4.13.0-37-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
linux-image-4.13.0-41-generic
Suggested packages:
fdutils linux-doc-4.13.0 | linux-source-4.13.0 linux-tools
The following NEW packages will be installed:
linux-image-4.13.0-41-generic
0 upgraded, 1 newly installed, 0 to remove and 15 not upgraded.
5 not fully installed or removed.
Need to get 0 B/20.9 MB of archives.
After this operation, 72.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
(Reading database ... 374331 files and directories currently installed.)
Preparing to unpack .../linux-image-4.13.0-41-generic_4.13.0-41.46_amd64.deb ...
Examining /etc/kernel/preinst.d/
run-parts: executing /etc/kernel/preinst.d/intel-microcode 4.13.0-41-generic /boot/vmlinuz-4.13.0-41-generic
Done.
Unpacking linux-image-4.13.0-41-generic (4.13.0-41.46) ...
dpkg: error processing archive /var/cache/apt/archives/linux-image-4.13.0-41-generic_4.13.0-41.46_amd64.deb (--unpack):
cannot copy extracted data for './boot/vmlinuz-4.13.0-41-generic' to '/boot/vmlinuz-4.13.0-41-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.13.0-41-generic /boot/vmlinuz-4.13.0-41-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.13.0-41-generic /boot/vmlinuz-4.13.0-41-generic
Errors were encountered while processing:
/var/cache/apt/archives/linux-image-4.13.0-41-generic_4.13.0-41.46_amd64.deb
输出uname -r
为:4.13.0-38-generic
的输出df -h
为:
Filesystem Size Used Avail Use% Mounted on
udev 63G 0 63G 0% /dev
tmpfs 13G 2.7M 13G 1% /run
/dev/mapper/sdb2_crypt 1.9T 1004G 779G 57% /
tmpfs 63G 39M 63G 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 63G 0 63G 0% /sys/fs/cgroup
/dev/nvme0n1p1 1.1T 472G 573G 46% /mnt/scratch
/dev/sdb1 231M 222M 0 100% /boot
/dev/md126p1 9.1T 3.0T 6.2T 33% /mnt/10TB
tmpfs 13G 84K 13G 1% /run/user/1001
tmpfs 13G 0 13G 0% /run/user/1004
答案1
您需要先释放目录中的空间。/boot
您有四个4.4.13.0
链内核:-36
、-37
和。您只需要和。因此您需要删除和。我没有安装它们,但为了让你了解它们的样子,我使用了以下命令:-38
-39
-38
-39
-36
-37
$ ll /boot/*4.4.0-124*
-rw-r--r-- 1 root root 1251054 May 2 08:58 /boot/abi-4.4.0-124-generic
-rw-r--r-- 1 root root 190654 May 2 08:58 /boot/config-4.4.0-124-generic
-rw-r--r-- 1 root root 43369621 May 17 06:00 /boot/initrd.img-4.4.0-124-generic
-rw-r--r-- 1 root root 255 May 2 08:58 /boot/retpoline-4.4.0-124-generic
-rw------- 1 root root 3898100 May 2 08:58 /boot/System.map-4.4.0-124-generic
-rw------- 1 root root 7143952 May 2 08:58 /boot/vmlinuz-4.4.0-124-generic
在您的系统上重复此命令,用4.4.0-124
和4.13.0-36
替换4.13.0-37
。您将看到每个内核占用大约 450 MB 的空间/boot
。
然后很小心输入以下命令(但不是注释#
):
sudo rm -f /boot/*4.13.0-36*
sudo rm -f /boot/*4.13.0-37*
sudo apt install -f # Ensure all dependency errors are now fixed.
sudo apt update # There should be no errors reported.
sudo apt autoremove # This will finish removing kernels -36 & -37.
sudo apt upgrade # This should install new kernel 4.13.0-41
sudo reboot # You will now boot into kernel 4.13.0-41
重新启动后,以及启动新内核更新后的任何其他时间运行:
sudo apt autoremove # This will keep you at current kernel plus previous version (4.13.0-39) and remove all others
如果你有丝毫的怀疑或不确定在下面发表评论。