12.5. 仮想ディスクの整合性のチェック
ディスクイメージを仮想マシンにアタッチする前に、ディスクイメージに破損や著しい断片化などの問題がないことを確認します。確認には、qemu-img check コマンドを使用します。
必要に応じて、このコマンドを使用してディスクイメージの修復を試みることもできます。
前提条件
- ディスクイメージを使用する仮想マシンがすべてシャットダウンしている。
手順
テストするイメージに対して
qemu-img checkコマンドを使用します。以下に例を示します。# qemu-img check <test-name.qcow2> No errors were found on the image. 327434/327680 = 99.92% allocated, 0.00% fragmented, 0.00% compressed clusters Image end offset: 21478375424チェックでディスクイメージに問題が見つかった場合、コマンドの出力は次のようになります。
167 errors were found on the image. Data may be corrupted, or further writes to the image may corrupt it. 453368 leaked clusters were found on the image. This means waste of disk space, but no harm to data. 259 internal errors have occurred during the check. Image end offset: 21478375424検出された問題の修復を試みるために、
-r allオプションを指定したqemu-img checkコマンドを使用します。ただし、問題の一部しか解決されない可能性があることに注意してください。警告ディスクイメージを修復すると、データの破損やその他の問題が発生する可能性があります。修復を試みる前に、ディスクイメージをバックアップしてください。
# qemu-img check -r all <test-name.qcow2> [...] 122 errors were found on the image. Data may be corrupted, or further writes to the image may corrupt it. 250 internal errors have occurred during the check. Image end offset: 27071414272この出力は、修復後にディスクイメージで見つかった問題の数を示しています。
-
さらにディスクイメージの修復が必要な場合は、
guestfishシェル のさまざまなlibguestfsツールを使用できます。