嘗試在沒有網際網路的情況下更新和安裝後損壞
在無法訪問 Internet 的 debian buster 機器上,大多數 apt 命令(如 apt install/remove/autoremove)顯示以下錯誤:
The following packages have unmet dependencies: systemd : Depends: libsystemd0 (= 241-7~deb10u6) but 241-7~deb10u8 is to be installed Recommends: libpam-systemd but it is not installable E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
嘗試執行時
apt --fix-broken install
,出現此錯誤:root@debian10-h1:/var/cuda-repo-debian10-11-4-local# 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: big list of packages Use 'apt autoremove' to remove them. The following packages will be REMOVED: systemd 0 upgraded, 0 newly installed, 1 to remove and 1 not upgraded. After this operation, 13.8 MB disk space will be freed. Do you want to continue? [Y/n] Y (Reading database ... 114294 files and directories currently installed.) Removing systemd (241-7~deb10u6) ... systemd is the active init system, please switch to another before removing systemd. dpkg: error processing package systemd (--remove): installed systemd package pre-removal script subprocess returned error exit status 1 Errors were encountered while processing: systemd E: Sub-process /usr/bin/dpkg returned an error code (1)
我是怎麼到那裡的
我不得不在無法訪問 Internet 的 debian buster 伺服器上安裝程序。到目前為止,當我必須通過 apt 安裝某些東西時,我會
apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances <your-package-here> | grep "^\w" | sort -u)
在 VM 上執行以從包和所有依賴項中下載 .deb 文件,將文件傳輸到我的目標機器,然後執行dpkg -i *.deb
安裝在那裡,這正在工作美好的。我必須安裝 CUDA,所以我按照 nvidia 安裝指南進行操作。在某些時候,我應該執行這些命令:
wget https://developer.download.nvidia.com/compute/cuda/11.4.0/local_installers/cuda-repo-debian10-11-4-local_11.4.0-470.42.01-1_amd64.deb sudo dpkg -i cuda-repo-debian10-11-4-local_11.4.0-470.42.01-1_amd64.deb sudo apt-key add /var/cuda-repo-debian10-11-4-local/7fa2af80.pub sudo add-apt-repository contrib sudo apt-get update sudo apt-get -y install cuda
我執行了前 4 個命令沒有任何問題(第一個在我的虛擬機上連接網際網路),但由於我沒有網際網路連接,所以第 5 個失敗:
root@debian10-h1:/home/user/installation# apt-get update Get:1 file:/var/cuda-repo-debian10-11-4-local InRelease Ign:1 file:/var/cuda-repo-debian10-11-4-local InRelease Get:2 file:/var/cuda-repo-debian10-11-4-local Release [564 B] Get:2 file:/var/cuda-repo-debian10-11-4-local Release [564 B] Err:4 http://deb.debian.org/debian buster InRelease Temporary failure resolving 'deb.debian.org' Reading package lists... Done W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease Temporary failure resolving 'deb.debian.org' W: Some index files failed to download. They have been ignored, or old ones used instead.
第6個也是:
root@debian10-h1:/home/user/installation# apt-get -y install cuda 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: apt-utils : Depends: apt (= 1.8.2.2) but 1.8.2.3 is to be installed cuda : Depends: cuda-11-4 (>= 11.4.0) but it is not going to be installed libglib2.0-bin : Depends: libglib2.0-0 (= 2.58.3-2+deb10u2) but 2.58.3-2+deb10u 3 is to be installed libpython3.7 : Depends: libpython3.7-stdlib (= 3.7.3-2+deb10u2) but 3.7.3-2+deb10u3 is to be installed systemd : Depends: libsystemd0 (= 241-7~deb10u6) but 241-7~deb10u8 is to be installed udev : Depends: libudev1 (= 241-7~deb10u6) but 241-7~deb10u8 is to be installed E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
所以我嘗試了
apt --fix-broken install
:root@debian10-h1:/home/user/installation# 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: big list of packages Use 'apt autoremove' to remove them. The following packages will be REMOVED: big list of packages WARNING: The following essential packages will be removed. This should NOT be done unless you know exactly what you are doing! init systemd-sysv (due to init) 0 upgraded, 0 newly installed, 58 to remove and 1 not upgraded. After this operation, 364 MB disk space will be freed. You are about to do something potentially harmful. To continue type in the phrase 'Yes, do as I say!' ?]n
我試著
apt autoremove
按照建議做,但我得到的E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
和以前一樣。與 相同apt remove cuda
。考慮到由於問題而無法正常工作apt-get update
,我嘗試通過 apt-offline 進行更新,但再次被要求使用apt --fix-broken install
:root@debian10-h1:/home/user/installation# apt-offline set ./my.sig Generating database of files that are needed for an update. Generating database of file that are needed for operation upgrade E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution). ERROR: FATAL: Something is wrong with the APT system
由於我沒有找到其他事情可做,我重試了,
apt --fix-broken install
但這次接受繼續:root@debian10-h1:/home/user/installation# 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: big list of packages Use 'apt autoremove' to remove them. The following packages will be REMOVED: big list of packages WARNING: The following essential packages will be removed. This should NOT be done unless you know exactly what you are doing! init systemd-sysv (due to init) 0 upgraded, 0 newly installed, 58 to remove and 1 not upgraded. After this operation, 364 MB disk space will be freed. You are about to do something potentially harmful. To continue type in the phrase 'Yes, do as I say!' ?]Yes, do as I say! (Reading database ... 120959 files and directories currently installed.) Lot of others thing were removed, I just kept the ones where I got a different message, can post the full list if needed. Removing linux-image-amd64 (4.19+105+deb10u9) ... Removing linux-image-4.19.0-14-amd64 (4.19.171-2) ... W: Removing the running kernel W: Last kernel image has been removed, so removing the default symlinks /etc/kernel/postrm.d/initramfs-tools: update-initramfs: Deleting /boot/initrd.img-4.19.0-14-amd64 /etc/kernel/postrm.d/zz-update-grub: Generating grub configuration file ... Found background image: /usr/share/images/desktop-base/desktop-grub.png Adding boot menu entry for EFI firmware configuration done update-initramfs: deferring update (trigger activated) Removing initramfs-tools (0.133+deb10u1) ... Removing initramfs-tools-core (0.133+deb10u1) ... Removing systemd (241-7~deb10u6) ... systemd is the active init system, please switch to another before removing systemd. dpkg: error processing package systemd (--remove): installed systemd package pre-removal script subprocess returned error exit status 1 Errors were encountered while processing: systemd E: Sub-process /usr/bin/dpkg returned an error code (1)
我已經嘗試過的
- 關注https://askubuntu.com/a/1093253:
sudo apt-get clean
不顯示任何內容,root@debian10-h1:/home/user# dpkg --configure -a Processing triggers for mime-support (3.62) ... Processing triggers for hicolor-icon-theme (0.17-2) ... Processing triggers for libglib2.0-0:amd64 (2.58.3-2+deb10u3) ... Processing triggers for libc-bin (2.28-10) ... Processing triggers for man-db (2.8.5-2) ... Processing triggers for libreoffice-common (1:6.1.5-3+deb10u6) ... Processing triggers for dbus (1.12.20-0+deb10u1) ... Processing triggers for desktop-file-utils (0.23-4) ...
並
sudo apt upgrade --fix-missing
要求我再做apt --fix-broken install
一次。
- 跟隨https://askubuntu.com/a/1244984,但
stat / /dev /var
顯示 root 是所有 3 個目錄的所有者。- 關注https://askubuntu.com/a/380701,但
sudo fuser -v /var/cache/debconf/config.dat
什麼也沒顯示。(+我不認為這是完全相同的問題)。我想知道是否有人知道如何解決該問題,如果需要,我可以提供更多資訊。
我將解釋系統如何在這種情況下結束(至少,我的理論),以及將來如何避免它;但首先,讓我們看看如何解決它。
我懷疑您的設置太糟糕了
apt-offline
,無法通過合理的步驟來解決問題。您最好下載目前版本的第一張完整 DVD並使用它。為此,請刪除所有已配置的儲存庫,將 DVD 映像掛載到您的伺服器上,然後使用apt-cdrom
,--no-mount
選項添加它,這樣apt-cdrom
就不會嘗試管理“DVD 驅動器”本身(假設您使用映像)。這將為您提供最新的軟體包源,您可以使用這些源重新安裝已刪除的軟體包併升級系統,使其處於一致狀態。我對此沒有什麼神奇的秘訣。您必須弄清楚刪除了哪些軟體包。
apt full-upgrade
可能有幫助。至於為什麼系統最終會這樣壞掉,我認為這與 CUDA 無關,而是與您用於離線安裝的技術有關。下載完整的依賴樹,忽略已經安裝的內容,最終必然會下載與其他應該一起升級的依賴樹相交的包集。例如,許多包最終依賴於
libsystemd0
,但它們的依賴關係樹不包括systemd
; 安裝這樣的軟體包集會導致和 不匹配systemd
,libsystemd0
這解釋了您問題中的第一個錯誤。dpkg -i
可以允許發生這種不匹配,但apt
不喜歡它們,需要先修復它們,然後才能做任何明智的事情;這就是apt install --fix-broken
修復,但它需要一個包儲存庫……為了避免這種情況,已安裝的軟體包集必須保持全域一致。對於斷開連接的系統,
apt-offline
這是最好的方法,但它必須一直使用,沒有apt-cache depends
技巧。對於部分連接的系統,即在網路上但沒有直接訪問 Internet 的系統,網路本地包記憶體可能是更好的解決方案;例如見apt-cacher-ng
。