インターネットなしでアップデートとインストールを試みた後、aptが破損する

インターネットなしでアップデートとインストールを試みた後、aptが破損する

インターネットにアクセスできない 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)

私はそこに行きましたか?

インターネットにアクセスできない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)マシンで実行してパッケージとすべての依存関係から.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 updateapt-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/1093253sudo 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ルートが3つのディレクトリすべての所有者であることを示しています。

  • すでにフォロー中https://askubuntu.com/a/380701しかし、sudo fuser -v /var/cache/debconf/config.dat何も表示しません。 (+私はこれがまったく同じ問題だとは思わない)。

この問題を解決する方法を知っている人がいるかどうか疑問に思います。必要に応じて追加情報を提供できます。

ベストアンサー1

システムがどのようにこのような状況に至ったか(少なくとも私の理論はそうです)、今後これを防ぐ方法を説明します。しかし、まず問題を解決する方法を見てみましょう。

apt-offline問題を解決するための合理的な対策を講じるには、設定が間違っているようです。ダウンロードしてもいいと思います。Current Pointがリリースした最初の長編DVD、そしてそれを使用してください。これを行うには、構成されているすべてのリポジトリを削除し、サーバーにDVDイメージをマウントしてから、次を使用します。apt-cdrom、DVDドライブ自体を管理しようとしないように、この--no-mountオプションを使用してください(画像を使用していると仮定)。apt-cdrom

これにより、削除されたパッケージを再インストールし、システムを一貫した状態にアップグレードするために使用できる最新のパッケージソースが提供されます。これに対する魔法の秘密はありません。どのパッケージが削除されたかを調べる必要があります。apt full-upgrade役に立つかもしれません。

システムがこのようにクラッシュした理由は、CUDAとは関係がなく、オフラインでインストールするために使用した技術に関連していると思います。すでにインストールされているアイテムを無視して完全な依存関係ツリーをダウンロードすると、一緒にアップグレードする必要がある他の依存関係ツリーと交差する一連のパッケージが必然的にダウンロードされます。たとえば、多くのパッケージは最終的に依存しますlibsystemd0が、その依存関係ツリーには含まれませんsystemd。これらのパッケージセットをインストールすると、矛盾が発生し、systemdこれlibsystemd0は質問の最初のエラーを説明します。dpkg -iこれらの矛盾が発生することを許可することは大丈夫ですが、aptそれを嫌い、合理的な措置を講じる前にそれを修正する必要があります。これはapt install --fix-brokenまさに解決策ですが、パッケージリポジトリが必要です。

この状況を回避するには、インストールされているパッケージセットがグローバルに一貫性を維持する必要があります。切断されたシステムの場合、apt-offlineこれは最善の方法ですが、常に使用する必要があり、apt-cache dependsトリックはありません。部分的に接続されたシステムでは、つまりネットワークにあるがインターネットに直接アクセスできない状況では、ネットワークローカルパケットキャッシュがより良い解決策かもしれません。apt-cacher-ng

おすすめ記事