ubuntu包解压异常(dpkg: error processing)
...
Unpacking linux-headers-6.8.0-56 (6.8.0-56.58) ...
dpkg-deb (subprocess): decompressing archive '/var/cache/apt/archives/linux-headers-6.8.0-56_6.8.0-56.58_all.deb' (size=13837808) member 'data.tar': zstd error: Data corruption detected
dpkg-deb: error: <decompress> subprocess returned error exit status 2
...
env
- ubuntu-24.04.2 LTS (Noble Numbat)
报错日志
root@gaga:/etc/apt/sources.list.d# cat /etc/os-release
PRETTY_NAME="Ubuntu 24.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.2 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo
root@gaga:/etc/apt/sources.list.d# uname -a
Linux gaga 6.8.0-53-generic #55-Ubuntu SMP PREEMPT_DYNAMIC Fri Jan 17 15:37:52 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
根据以上信息,当前内核6.8-53
修复错误日志
...
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
fluent-bit : Depends: libpq5 (>= 9.0~) but it is not going to be installed
linux-headers-6.8.0-56-generic : Depends: linux-headers-6.8.0-56 but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
### 以上错误信息,可以得知是依赖高版本内核头文件。
root@gaga:~# apt --fix-broken install
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
linux-headers-6.8.0-56
The following NEW packages will be installed:
linux-headers-6.8.0-56
0 upgraded, 1 newly installed, 0 to remove and 73 not upgraded.
11 not fully installed or removed.
Need to get 0 B/13.8 MB of archives.
After this operation, 85.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 108130 files and directories currently installed.)
Preparing to unpack .../linux-headers-6.8.0-56_6.8.0-56.58_all.deb ...
Unpacking linux-headers-6.8.0-56 (6.8.0-56.58) ...
dpkg-deb (subprocess): decompressing archive '/var/cache/apt/archives/linux-headers-6.8.0-56_6.8.0-56.58_all.deb' (size=13837808) member 'data.tar': zstd error: Data corruption detected
dpkg-deb: error: <decompress> subprocess returned error exit status 2
dpkg: error processing archive /var/cache/apt/archives/linux-headers-6.8.0-56_6.8.0-56.58_all.deb (--unpack):
cannot copy extracted data for './usr/src/linux-headers-6.8.0-56/include/trace/events/rcu.h' to '/usr/src/linux-headers-6.8.0-56/include/trace/events/rcu.h.dpkg-new': unexpected end of file or stream
Errors were encountered while processing:
/var/cache/apt/archives/linux-headers-6.8.0-56_6.8.0-56.58_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
分析
从你提供的错误日志来看,问题的核心是 apt
在尝试安装 linux-headers-6.8.0-56
包时遇到了数据损坏或解压失败的情况。具体错误信息显示:
zstd error: Data corruption detected
- 表示包的压缩数据可能已损坏。unexpected end of file or stream
- 表明在解压过程中文件不完整。E: Sub-process /usr/bin/dpkg returned an error code (1)
-dpkg
进程因错误退出,导致安装失败。
问题原因分析
- 包文件损坏: 你尝试安装的
/var/cache/apt/archives/linux-headers-6.8.0-56_6.8.0-56.58_all.deb
文件可能在下载时发生了中断或损坏。 - 缓存问题:
apt
的缓存中可能保留了损坏的文件,导致重复尝试使用同一损坏文件。 - 网络问题: 如果下载过程中网络不稳定,可能会导致文件不完整。
- 依赖问题: 日志显示有“11 not fully installed or removed”包,可能存在依赖冲突或之前安装失败的残留问题。
解决
1. 清理 APT 缓存
清除当前缓存的包文件,让 apt
重新下载:
1 | sudo apt clean |
这会删除 /var/cache/apt/archives/
中的所有缓存文件,包括损坏的 linux-headers-6.8.0-56
文件。
2. 更新包列表
确保包索引是最新的:
1 | sudo apt update |
3. 重新尝试修复依赖
运行以下命令修复损坏的依赖关系:
1 | sudo apt --fix-broken install |
如果仍然报错,进入下一步。
实际上到此问题已解决
root@gaga:~# apt --fix-broken install -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
linux-headers-6.8.0-56
The following NEW packages will be installed:
linux-headers-6.8.0-56
0 upgraded, 1 newly installed, 0 to remove and 73 not upgraded.
11 not fully installed or removed.
Need to get 13.8 MB of archives.
After this operation, 85.8 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 linux-headers-6.8.0-56 all 6.8.0-56.58 [13.8 MB]
Fetched 13.8 MB in 3s (4,004 kB/s)
(Reading database ... 108130 files and directories currently installed.)
Preparing to unpack .../linux-headers-6.8.0-56_6.8.0-56.58_all.deb ...
Unpacking linux-headers-6.8.0-56 (6.8.0-56.58) ...
Setting up linux-modules-6.8.0-56-generic (6.8.0-56.58) ...
Setting up linux-libc-dev:amd64 (6.8.0-56.58) ...
Setting up linux-headers-6.8.0-56 (6.8.0-56.58) ...
Setting up linux-modules-extra-6.8.0-56-generic (6.8.0-56.58) ...
Setting up linux-tools-common (6.8.0-56.58) ...
Setting up linux-headers-6.8.0-56-generic (6.8.0-56.58) ...
Setting up linux-image-6.8.0-56-generic (6.8.0-56.58+1) ...
I: /boot/vmlinuz is now a symlink to vmlinuz-6.8.0-56-generic
I: /boot/initrd.img is now a symlink to initrd.img-6.8.0-56-generic
Setting up linux-image-generic (6.8.0-56.58) ...
Setting up linux-headers-generic (6.8.0-56.58) ...
Setting up linux-tools-6.8.0-56 (6.8.0-56.58) ...
Setting up linux-generic (6.8.0-56.58) ...
Setting up linux-tools-6.8.0-56-generic (6.8.0-56.58) ...
Processing triggers for man-db (2.12.0-4build2) ...
Processing triggers for linux-image-6.8.0-56-generic (6.8.0-56.58+1) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-6.8.0-56-generic
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.8.0-56-generic
Found initrd image: /boot/initrd.img-6.8.0-56-generic
Found linux image: /boot/vmlinuz-6.8.0-53-generic
Found initrd image: /boot/initrd.img-6.8.0-53-generic
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done
Scanning processes...
Scanning candidates...
Scanning linux images...
Pending kernel upgrade! ### 内核升级
Running kernel version:
6.8.0-53-generic
Diagnostics:
The currently running kernel version is not the expected kernel version 6.8.0-56-generic.
Restarting the system to load the new kernel will not be handled automatically, so you should consider rebooting.
Restarting services...
Service restarts being deferred:
systemctl restart unattended-upgrades.service
No containers need to be restarted.
No user sessions are running outdated binaries.
No VM guests are running outdated hypervisor (qemu) binaries on this host.
root@gaga:~#
根据提示需要重启系统
root@gaga:~# uname -a
Linux gaga 6.8.0-56-generic #58-Ubuntu SMP PREEMPT_DYNAMIC Fri Feb 14 15:33:28 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
root@gaga:~#
root@gaga:~# apt-get install fluent-bit
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
fluent-bit is already the newest version (3.2.10).
0 upgraded, 0 newly installed, 0 to remove and 73 not upgraded.
root@gaga:~# dpkg -L fluent-bit
/etc
/etc/fluent-bit
/etc/fluent-bit/fluent-bit.conf
/etc/fluent-bit/parsers.conf
/etc/fluent-bit/plugins.conf
/lib
diverted by base-files to: /lib.usr-is-merged
/lib/fluent-bit
/lib/fluent-bit/libfluent-bit.so
/opt
/opt/fluent-bit
/opt/fluent-bit/bin
/opt/fluent-bit/bin/fluent-bit
/usr
/usr/lib
/usr/lib/systemd
/usr/lib/systemd/system
/usr/lib/systemd/system/fluent-bit.service