qcow2スナップショットを適用して元のディスクイメージを上書きする方法は?

qcow2スナップショットを適用して元のディスクイメージを上書きする方法は?

生のディスク形式で作成された仮想マシンがありましたが、後でvirshとqemu-imgがqcow2形式のスナップショット作成のみをサポートしていることがわかりました。

そのため、デフォルトのrawディスクをqcow2に変換してから、ディスクのスナップショットを作成しました。今質問は、ネイティブのRAWディスクイメージにスナップショットをどのように適用しますか?

私は試した:

$ qemu-img snapshot -a disk1-snapshot1.qcow2 disk1.img
WARNING: Image format was not specified for 'disk1.img' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.
WARNING: Image format was not specified for 'disk1.img' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.
qemu-img: Could not apply snapshot 'disk1-snapshot1.qcow2': -95 (Operation not supported)

ベストアンサー1

生ディスクをqcow2形式に変換したら、「qemu-img」を使用してプライマリイメージからスナップショットを作成します。

qemu-img create -f qcow2 -b <Base-Image>.qcow2 <Base-Image-Snapshot>.qcow2

スナップショットのサイズは約200KBです。また、スナップショットをディスクイメージとして使用する新しいゲスト仮想マシンをインストールする必要があります。

virt-install --virt-type=kvm --name=<New-Guest-VM> --ram 2048 --vcpus=2 --virt-type=kvm --hvm --network network=default --graphics vnc --disk <Base-Image-Snapshot>.qcow2 --boot=hd --noautoconsole

これで、新しいゲスト仮想マシンを起動できます。

そして、スナップショットはベースイメージの変更のみを保存するため、ホストスペースが大幅に節約されます。 :)

おすすめ記事