grubを使用したdpkg設定のデバッグが失敗する

grubを使用したdpkg設定のデバッグが失敗する

マイコンピュータの1つでは、dpkgがgrubのインストール/設定を完了できず、次のエラーメッセージのみが表示されます。

サブプロセスをインストールするためのインストール後、スクリプトはエラー終了状態255を返します。

フル出力:

# dpkg --configure grub-pc
Setting up grub-pc (1.99-27+deb7u3) ...
device node not found
device node not found
device node not found
device node not found
Installation finished. No error reported.
Installation finished. No error reported.
dpkg: error processing grub-pc (--configure):
 subprocess installed post-installation script returned error exit status 255
Errors were encountered while processing:
 grub-pc

追加の手がかりを提供するログファイルには何もありません。

いくつかのデバッグオプションを使用してdpkgを実行すると、より多くの情報を確認できます。

# dpkg -D10113 --configure grub-pc
Setting up grub-pc (1.99-27+deb7u3) ...
D000002: fork/exec /var/lib/dpkg/info/grub-pc.postinst ( configure  )
device node not found
device node not found
device node not found
device node not found
Installation finished. No error reported.
Installation finished. No error reported.
dpkg: error processing grub-pc (--configure):
 subprocess installed post-installation script returned error exit status 255
D010000: trigproc_run_deferred
Errors were encountered while processing:
 grub-pc

これで問題がスクリプトのどこかにあることがわかりました/var/lib/dpkg/info/grub-pc.postinst configureが、スクリプトには詳細やデバッグオプションがないようで、コードがほぼ700行になりすぎて読めません。そのスクリプトはどんな呼び出しもしないので、exit 255問題がそこになく、呼び出される別のスクリプトにあると信じたいと思います。

カーネルプロセスの設定操作も失敗します。

# dpkg --configure linux-image-3.16.0-0.bpo.4-amd64
Setting up linux-image-3.16.0-0.bpo.4-amd64 (3.16.39-1+deb8u1~bpo70+1) ...
vmlinuz(/boot/vmlinuz-3.16.0-0.bpo.4-amd64
) points to /boot/vmlinuz-3.16.0-0.bpo.4-amd64
 (/boot/vmlinuz-3.16.0-0.bpo.4-amd64) -- doing nothing at /var/lib/dpkg/info/linux-image-3.16.0-0.bpo.4-amd64.postinst line 263.
initrd.img(/boot/initrd.img-3.16.0-0.bpo.4-amd64
) points to /boot/initrd.img-3.16.0-0.bpo.4-amd64
 (/boot/initrd.img-3.16.0-0.bpo.4-amd64) -- doing nothing at /var/lib/dpkg/info/linux-image-3.16.0-0.bpo.4-amd64.postinst line 263.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-3.16.0-0.bpo.4-amd64
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 255
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-3.16.0-0.bpo.4-amd64.postinst line 634.
dpkg: error processing linux-image-3.16.0-0.bpo.4-amd64 (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 linux-image-3.16.0-0.bpo.4-amd64

ライン634入力は/var/lib/dpkg/info/linux-image-3.16.0-0.bpo.4-amd64.postinst次のコマンドで要約されます。

run-parts --report --exit-on-error --arg=3.16.0-0.bpo.4-amd64 --arg=/boot/vmlinuz-3.16.0-0.bpo.4-amd64 /etc/kernel/postinst.d

このコマンドを手動で実行すると、次の結果が得られます。

run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 255

私が知っている限り、このスクリプトはチェックを実行してから呼び出すラッパーに過ぎず、update-grubエラーなしで動作します。

update-grubただ実行中なので、grub-mkconfigこのコマンドを実行して戻り値を確認します。

# grub-mkconfig -o /boot/grub/grub.cfg
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.16.0-0.bpo.4-amd64
Found initrd image: /boot/initrd.img-3.16.0-0.bpo.4-amd64
Found linux image: /boot/vmlinuz-3.2.0-4-amd64
Found initrd image: /boot/initrd.img-3.2.0-4-amd64
# echo $?
255

これが犯人のようです。スクリプトが機能し、すべてのコアを見つけて有効なグラブ構成を作成し(保存)、/boot/grub/grub.cfg.newコード255で終了します。もちろん、デバッグオプションはありません。

問題を引き続きデバッグするにはどうすればよいですか?

役に立つかもしれないしそうでないかもしれない追加情報:

  • システムはdebian wheezyを実行しています。
  • GRUBのバージョンは1.99-27+deb7u3です。
  • システムにmdraidがあります。
  • このシステムは長年にわたり運営されており、新しく設置されたものではありません。このエラーは最近登場しました。
  • わかりませんが、障害のあるハードドライブを交換した後、このエラーが表示され始めたようです。
  • grubパッケージとカーネルパッケージの設定操作だけが失敗しました。他のすべてのパッケージはエラーなくインストールできます。

後で質問すると、より多くの情報を得ることができます。

zulu668:~# cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 sda4[2] sdb4[1]
      1456504640 blocks super 1.2 [2/2] [UU]

md1 : active raid1 sda3[2] sdb3[1]
      7996352 blocks super 1.2 [2/2] [UU]

md0 : active raid1 sda2[2] sdb2[1]
      499392 blocks super 1.2 [2/2] [UU]

unused devices: <none>
zulu668:~# sudo mdadm --detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Wed Oct 29 12:40:33 2014
     Raid Level : raid1
     Array Size : 499392 (487.77 MiB 511.38 MB)
  Used Dev Size : 499392 (487.77 MiB 511.38 MB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Wed Mar 15 14:51:01 2017
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           Name : zulu668:0  (local to host zulu668)
           UUID : 22e14818:7754cf01:67287402:c31a3328
         Events : 217

    Number   Major   Minor   RaidDevice State
       2       8        2        0      active sync   /dev/sda2
       1       8       18        1      active sync   /dev/sdb2

ベストアンサー1

そのため、この記事を作成しながら問題の範囲を絞り込み、grub-mkconfigデバッグ方法を疑問にしました。

grub-mkconfiggrub.cfgをデフォルトで実行するシェルスクリプトです/etc/grub.dset -e最初は、grub-mkconfig「管理されていない最初のエラーで停止」を意味するコマンドがあります。問題は、 grub.d スクリプトのいずれかが失敗したために発生する可能性が高いです。

まず、犯人を調べましょう。ランニング:

dash -vx grub-mkconfig -o /boot/grub/grub.cfg

dash/bin/sh、Bourne Shellインタプリタは、実行しているすべての行を出力する可能性が高いです。スクリプトがコマンドで失敗する可能性があるため、set -e最後の行は失敗した grub.d 添字である可能性が高くなります。私はあなたが次のようなものを得ると思います:

+ echo ### BEGIN /etc/grub.d/99_buggy_script ###
+ /etc/grub.d/99_buggy_script

スクリプト名自体では、何が起こっているのかについて十分な証拠を提供できない可能性があります。 Bourneシェルスクリプトでもあるため、同じ方法でデバッグできます。 grub.dスクリプトの最初の行を変更してください。

#!/bin/sh

到着する:

#!/bin/sh -vx

そして実行してくださいgrub-mkconfig -o /boot/grub/grub.cfgdash -vxもう必要ありません)。取得できるトレースは grub.d スクリプトからのものです。

さて、問題が明らかになったことを願っています。問題を解決したら、-vxgrub.d添え字の先頭にあるフラグを削除することを忘れないでください。

おすすめ記事