如何修复Ubuntu从16.04升级到18.04期间因中断而导致的linux-tools损坏?



我正在升级Ubuntu从16.04升级到18.04,但是我错误地在中途重启了机器。我尝试按照这篇文章中选项2中的命令再次升级系统。

1.1。更新软件包存储库列表:

sudo apt-get update
$ sudo apt-get update
Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Get:3 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]                                 
Get:5 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]                              
Get:6 http://security.ubuntu.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [55.2 kB]                                    
Get:7 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 DEP-11 Metadata [60.9 kB]
Get:8 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 DEP-11 Metadata [2,464 B]
Get:9 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 DEP-11 Metadata [297 kB]             
Get:10 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 DEP-11 Metadata [302 kB]
Get:11 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 DEP-11 Metadata [2,468 B]
Fetched 986 kB in 2s (499 kB/s)                                               
Reading package lists... Done

1.2。然后,升级已经安装的包,让系统处理包的依赖关系:

sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
$ sudo apt-get upgrade -y
Reading package lists... Done
Building dependency tree... 50%
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-tools-4.15.0-46-generic : Depends: linux-tools-4.15.0-46 but it is not installed
linux-tools-4.15.0-50-generic : Depends: linux-tools-4.15.0-50 but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
$ sudo apt-get install linux-tools-4.15.0-46-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
linux-tools-4.15.0-46-generic is already the newest version (4.15.0-46.49).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
linux-tools-4.15.0-46-generic : Depends: linux-tools-4.15.0-46 but it is not going to be installed
linux-tools-4.15.0-50-generic : Depends: linux-tools-4.15.0-50 but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
$ sudo apt-get dist-upgrade -y
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-tools-4.15.0-46-generic : Depends: linux-tools-4.15.0-46 but it is not installed
linux-tools-4.15.0-50-generic : Depends: linux-tools-4.15.0-50 but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

1.3。最后,通过删除所有不必要的包来释放磁盘空间:

sudo apt-get autoremove
$ sudo apt-get autoremove
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-tools-4.15.0-46-generic : Depends: linux-tools-4.15.0-46 but it is not installed
linux-tools-4.15.0-50-generic : Depends: linux-tools-4.15.0-50 but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

2.1。运行安装Update Manager命令:

sudo apt-get install update-manager-core

但是我从linux-tools中得到错误。

(base) $ sudo apt-get install update-manager-core
Reading package lists... Done
Building dependency tree       
Reading state information... Done
update-manager-core is already the newest version (1:18.04.11.13).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
linux-tools-4.15.0-43-generic : Depends: linux-tools-4.15.0-43 but it is not going to be installed
linux-tools-4.15.0-46-generic : Depends: linux-tools-4.15.0-46 but it is not going to be installed
linux-tools-4.15.0-50-generic : Depends: linux-tools-4.15.0-50 but it is not going to be installed
(base) xxx@yyy:~$ sudo apt-get --fix-broken install
Reading package lists... Done
Building dependency tree... 50%
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
fonts-dejavu fonts-deva-extra fonts-kalapi fonts-smc fonts-smc-anjalioldlipi fonts-smc-chilanka fonts-smc-dyuthi fonts-smc-karumbi fonts-smc-keraleeyam fonts-smc-manjari fonts-smc-meera fonts-smc-rachana
fonts-smc-raghumalayalamsans fonts-smc-suruma fonts-smc-uroob gcc-6-base:i386 gir1.2-gtk-2.0 gnome-orca icoutils idle-python2.7 ipython3-qtconsole katepart kde-runtime kde-runtime-data kde-style-breeze
kde-style-breeze-qt4 kdelibs-bin kdelibs5-data kdelibs5-plugins kdoctools libamd2.4.1 libass5 libatk1.0-dev libattica0.4 libavcodec-ffmpeg56 libavfilter-ffmpeg5 libavformat-ffmpeg56 libavresample-ffmpeg2
libavutil-ffmpeg54 libblas-common libbluray1 libbotan-1.10-1 libcairo-script-interpreter2 libcairo2-dev libcamd2.4.1 libcapnp-0.5.3 libccolamd2.9.1 libcholmod3.0.6 libchromaprint0 libclang1-3.6 libconfig-file-perl
libcxsparse3.1.4 libdlrestrictions1 libgdk-pixbuf2.0-dev libgflags2v5 libgl2ps0 libglpk36 libgpgme++2v5 libgtk2.0-dev libgtkglext1 libhdf5-10 libhdf5-cpp-11 libirs-export141 libisccfg-export140 libjasper-dev
libkactivities6 libkatepartinterfaces4 libkcmutils4 libkde3support4 libkdeclarative5 libkdecore5 libkdesu5 libkdeui5 libkdewebkit5 libkdnssd4 libkemoticons4 libkf5style5 libkfile4 libkhtml5 libkio5 libkjsapi4 libkjsembed4
libkmediaplayer4 libknewstuff3-4 libknotifyconfig4 libkntlm4 libkparts4 libkpty4 libkrosscore4 libktexteditor4 libkxmlrpcclient4 libllvm3.6v5 libmimic0 libntrack-qt4-1 libntrack0 liboctave3 libopencv-calib3d2.4v5
libopencv-contrib2.4v5 libopencv-core2.4v5 libopencv-features2d2.4v5 libopencv-flann2.4v5 libopencv-gpu2.4v5 libopencv-highgui2.4v5 libopencv-imgproc2.4v5 libopencv-legacy2.4v5 libopencv-ml2.4v5 libopencv-objdetect2.4v5
libopencv-ocl2.4v5 libopencv-photo2.4v5 libopencv-stitching2.4v5 libopencv-superres2.4v5 libopencv-ts2.4v5 libopencv-video2.4v5 libopencv-videostab2.4v5 libopencv2.4-jni libopenjpeg5 libpango1.0-dev libphonon4
libpixman-1-dev libplasma3 libpolkit-qt-1-1 libpostproc-ffmpeg53 libprotoc9v5 libpython3.5-dbg libpython3.5-dev libqbscore1 libqbsqtprofilesetup1 libqca2 libqca2-plugins libqscintilla2-12v5 libqscintilla2-l10n
libqt5clucene5 libqtwebkit4 libschroedinger-1.0-0 libsodium18 libsolid4 libsox2 libsrtp0 libstreamanalyzer0v5 libstreams0v5 libswresample-ffmpeg1 libswscale-ffmpeg3 libthreadweaver4 libumfpack5.7.1 libunwind-dev libva1
libwebpdemux1 libwildmidi1 libx264-148 libx265-79 libxcb-shm0-dev libxcomposite-dev libxcursor-dev libxinerama-dev libxrandr-dev linux-generic linux-generic-hwe-16.04 linux-headers-4.15.0-140
linux-headers-4.15.0-140-generic linux-headers-generic-hwe-16.04 linux-hwe-tools-4.15.0-46 linux-hwe-tools-4.15.0-50 linux-image-4.15.0-140-generic linux-image-generic-hwe-16.04 linux-modules-4.15.0-140-generic
linux-modules-extra-4.15.0-140-generic linux-tools-4.4.0-210 linux-tools-4.4.0-210-generic ntrack-module-libnl-0 orca oxideqt-codecs-extra oxygen-icon-theme phonon phonon-backend-gstreamer phonon-backend-gstreamer-common
plasma-scriptengine-javascript pylint python-astroid python-backports.functools-lru-cache python-cairo python-concurrent.futures python-configparser python-egenix-mxdatetime python-egenix-mxtools python-gobject-2
python-gtk2 python-isort python-lazy-object-proxy python-logilab-common python-mccabe python-singledispatch python-spyderlib-doc python-wrapt python3-pep8 python3-spyderlib python3.5-dbg python3.5-dev
x11proto-composite-dev x11proto-dri2-dev x11proto-gl-dev x11proto-randr-dev x11proto-xinerama-dev xserver-xorg-input-all-hwe-16.04 xserver-xorg-input-evdev-hwe-16.04 xserver-xorg-input-synaptics-hwe-16.04
xserver-xorg-input-wacom-hwe-16.04 xserver-xorg-legacy-hwe-16.04 xserver-xorg-video-amdgpu-hwe-16.04 xserver-xorg-video-qxl-hwe-16.04 xserver-xorg-video-vesa-hwe-16.04
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
linux-tools-4.15.0-46 linux-tools-4.15.0-50
The following NEW packages will be installed:
linux-tools-4.15.0-46 linux-tools-4.15.0-50
0 upgraded, 2 newly installed, 0 to remove and 1 not upgraded.
2 not fully installed or removed.
Need to get 0 B/9,255 kB of archives.
After this operation, 41.8 MB of additional disk space will be used.
(Reading database ... 487109 files and directories currently installed.)
Preparing to unpack .../linux-tools-4.15.0-46_4.15.0-46.49_amd64.deb ...
Unpacking linux-tools-4.15.0-46 (4.15.0-46.49) ...
dpkg: error processing archive /var/cache/apt/archives/linux-tools-4.15.0-46_4.15.0-46.49_amd64.deb (--unpack):
trying to overwrite '/usr/lib/libcpupower.so.4.15.0-46', which is also in package linux-hwe-tools-4.15.0-46 4.15.0-46.49~16.04.1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack .../linux-tools-4.15.0-50_4.15.0-50.54_amd64.deb ...
Unpacking linux-tools-4.15.0-50 (4.15.0-50.54) ...
dpkg: error processing archive /var/cache/apt/archives/linux-tools-4.15.0-50_4.15.0-50.54_amd64.deb (--unpack):
trying to overwrite '/usr/lib/libcpupower.so.4.15.0-50', which is also in package linux-hwe-tools-4.15.0-50 4.15.0-50.54~16.04.1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/linux-tools-4.15.0-46_4.15.0-46.49_amd64.deb
/var/cache/apt/archives/linux-tools-4.15.0-50_4.15.0-50.54_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我的最后一个选择是重新安装操作系统,但它会擦除我的数据,或者我需要备份很多数据,这需要很多时间。

我找到了解决方案https://askubuntu.com/questions/1062171/dpkg-deb-error-paste-subprocess-was-killed-by-signal-broken-pipe

$ sudo dpkg -i --force-overwrite /var/cache/apt/archives/linux-tools-4.15.0-46_4.15.0-46.49_amd64.deb
$ sudo apt -f install

,

$ sudo dpkg -i --force-overwrite /var/cache/apt/archives/linux-tools-4.15.0-50_4.15.0-50.54_amd64.deb
$ sudo apt -f install

最新更新