壊れた apt-get と壊れた grub

壊れた apt-get と壊れた grub

少し前に、Windows 10 と Linux Mint 18:Sarah でコンピューターをデュアル ブートしました。Windowshiberfil.sysの再起動機能を使用すると、Windows 10 はデフォルトでファイルを作成しました (システム スナップショットなどを保存するため)。これによって発生した問題は、コンピューターがシステム パーティションを管理する grub を認識せず、すぐに Windows が起動してしまうことでした。

私は「ブート修復」を使用してこの問題を解決したので、今では両方のシステムパーティションにアクセスできます。しかし、その後それが壊れてしまい、apt-get今ではソフトウェアをインストールしたりsudo apt-get install ___sudo apt-get upgrade

壊れているのは私の grub です。つまり、システムは grub2-common と呼ばれる別のバージョンの grub を想定していますが、代わりに 2.02~beta2-36ubuntu3.1 バージョンの grub がインストールされています。

それでは、いくつかのコマンドを実行したときの出力を紹介します。

$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 grub-pc : Depends: grub2-common (= 2.02~beta2-36ubuntu3.2) but 2.02~beta2-36ubuntu3.1 is installed
 grub2-common : Depends: grub-common (= 2.02~beta2-36ubuntu3.1) but 2.02~beta2-36ubuntu3.2 is installed
E: Unmet dependencies. Try using -f.

そこで、推奨されるコマンドを試してみます:

$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  grub2-common
The following packages will be upgraded:
  grub2-common
1 upgraded, 0 newly installed, 0 to remove and 244 not upgraded.
3 not fully installed or removed.
Need to get 0 B/511 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] yes
(Reading database ... 288732 files and directories currently installed.)
Preparing to unpack .../grub2-common_2.02~beta2-36ubuntu3.2_amd64.deb ...
Unpacking grub2-common (2.02~beta2-36ubuntu3.2) over (2.02~beta2-36ubuntu3.1) ...
dpkg: error processing archive /var/cache/apt/archives/grub2-common_2.02~beta2-36ubuntu3.2_amd64.deb (--unpack):
 trying to overwrite '/usr/sbin/grub-install', which is also in package lupin-support 0.57
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/grub2-common_2.02~beta2-36ubuntu3.2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

ソフトウェアをインストールしようとするとどうなりますか? ウイルス対策ソフトウェアをインストールしようとしています。

sudo apt-get install clamav
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 clamav : Depends: clamav-freshclam (>= 0.99.2+dfsg) but it is not going to be installed or
                   clamav-data
          Depends: libclamav7 (>= 0.99~rc1) but it is not going to be installed
 grub-pc : Depends: grub2-common (= 2.02~beta2-36ubuntu3.2) but 2.02~beta2-36ubuntu3.1 is to be installed
 grub2-common : Depends: grub-common (= 2.02~beta2-36ubuntu3.1) but 2.02~beta2-36ubuntu3.2 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

再び、grub で同じ問題が発生します。

最後に、もう 1 つコメントしたいことがあります。これを使用しsudo apt-getて何かをインストールすることはできません...これには grub リポジトリの更新も含まれます。

おそらく、適性状態とは何なのか疑問に思うのではないでしょうか。

sudo aptitude install clamav
The following NEW packages will be installed:
  clamav clamav-base{a} clamav-freshclam{a} libclamav7{a} libllvm3.6v5{ab} 
The following partially installed packages will be configured:
  grub-pc{b} python-pyaudio python-simplejson 
0 packages upgraded, 5 newly installed, 0 to remove and 245 not upgraded.
Need to get 9,109 kB of archives. After unpacking 36.8 MB will be used.
The following packages have unmet dependencies:
 grub2-common : Depends: grub-common (= 2.02~beta2-36ubuntu3.1) but 2.02~beta2-36ubuntu3.2 is installed.
 grub-pc : Depends: grub2-common (= 2.02~beta2-36ubuntu3.2) but 2.02~beta2-36ubuntu3.1 is installed and it is kept back.
 libllvm3.6v5 : Conflicts: libllvm3.6 but 1:3.6-2ubuntu1~trusty1 is installed.
                Conflicts: libllvm3.6:i386 but 1:3.6-2ubuntu1~trusty1 is installed.
The following actions will resolve these dependencies:

     Remove the following packages:
1)     grub-gfxpayload-lists       
2)     grub-pc                     
3)     grub2-common                
4)     libllvm3.6                  
5)     libllvm3.6:i386             



Accept this solution? [Y/n/q/?] Y
The following NEW packages will be installed:
  clamav clamav-base{a} clamav-freshclam{a} libclamav7{a} libllvm3.6v5{a} 
The following packages will be REMOVED:
  grub-gfxpayload-lists{a} grub-pc{a} grub2-common{a} libllvm3.6{a} libllvm3.6:i386{a} 
The following partially installed packages will be configured:
  python-pyaudio python-simplejson 
0 packages upgraded, 5 newly installed, 5 to remove and 244 not upgraded.
Need to get 9,109 kB of archives. After unpacking 29.9 MB will be freed.
Do you want to continue? [Y/n/?] Y
[ ERR] Writing extended state information
E: Failed to execute process to save dpkg selections, dpkg or trying to execute it exited with status/errno: 2
E: failed to save selections to dpkg database

Aptitude は少し先に進んでいるようです。しかし、「はい」を 2 回選択しても、ソフトウェアのインストールに失敗します。

どうすればこの混乱を整理できるでしょうか?

答え1

このエラーもありました:

E: Failed to execute process to save dpkg selections, dpkg or 
trying to execute it exited with status/errno: 2

これはネクロポストですが、私は次の方法で解決しました。

  1. 現在の apt 状態のバックアップを作成します (保存するため)。
  2. バックアップコピーを現在のコピーにコピーします。
  3. apt-getアップデート
  4. 上記で作成したバックアップを削除します。

コマンドリスト:

root@host# cd /var/lib/dpkg
root@host# cp status status.backup
root@host# cp status-old status-old.backup
root@host# cp status-old status
root@host# apt-get update
root@host# apt-get upgrade
root@host# rm status.backup
root@host# rm status-old.backup

apt データベースがなぜ壊れたのかは私にはわかりませんが、一部の文字が壊れているようです (つまり、「c」が「@」になっているなど)。RAM モジュールの不良が原因かもしれませんが、テストではすべて正常でした。

答え2

また、次のようなエラーも発生しました:

E: Failed to execute process to save dpkg selections, dpkg or
trying to execute it exited with status/errno: 2

私の場合、問題は/var/lib/dpkg/available欠落していることが判明しました。修正はtouch欠落しているファイルに対して行われました。使用可能なファイルを再構築することは可能ですが、必須ではありません。

答え3

まず、Linux Mint ターミナルで、grub-common の .deb を取得します。

wget http://archive.ubuntu.com/ubuntu/pool/main/g/grub2/grub-common_2.02-2ubuntu8_amd64.deb

ファイルを解凍し、

sudo dpkg -i grub-common_2.02-2ubuntu8_amd64.deb

grub-common には、gettext-base、libc6、libdevmapper1.02.1、libfreetype6、libfuse2、liblzma5、lsb-base が必要です。

それらの .deb ファイル。

テキストベースを取得:http://archive.ubuntu.com/ubuntu/pool/main/g/gettext/gettext-base_0.19.8.1-6_amd64.deb

libc6:http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc6_2.27-3ubuntu1_amd64.deb

libdevmapper1.02.1:http://archive.ubuntu.com/ubuntu/pool/main/l/lvm2/libdevmapper1.02.1_1.02.145-4.1ubuntu3_amd64.deb

libfreetype6:http://archive.ubuntu.com/ubuntu/pool/main/f/freetype/libfreetype6_2.8.1-2ubuntu2_amd64.deb

libfuse2: http://archive.ubuntu.com/ubuntu/pool/main/f/fuse/libfuse2_2.9.7-1ubuntu1_amd64.deb

liblzma5:http://archive.ubuntu.com/ubuntu/pool/main/x/xz-utils/liblzma5_5.2.2-1.3_amd64.deb

lsb ベース:http://archive.ubuntu.com/ubuntu/pool/main/l/lsb/lsb-base_9.20170808ubuntu1_all.deb

それらはすべて依存関係があり、一部は事前にインストールされていますが、一部はインストールが必要な場合もあります。

間違いがありましたら、解決策を提案できるように教えてください。

答え4

これがダミーロジックなのか何かなのかはわかりません。しかし、これを試してみたところ、スムーズに動作しました。

sudo apt upgrade grub-common grub2-common

関連情報