3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ovaからvhdxへコンバートするときの備忘録

Last updated at Posted at 2020-08-23

授業で使う仮想マシンはVirtualBoxかVMwareの指定で、配布もovaやらだった。自分のパソコンにはHyper-Vが入っており、VirtualBoxとかと干渉する。アップデートで共存できるようになったらしいが自分の環境ではできない (なんでだろうね)
どうにかしてhyper-Vで動かしたかったので、やったことを備忘録として以下に残しておく。hyper-v ovaとかで検索したらいっぱい出てくるからそれ見てもいいと思う。

というか他サイトをまとめただけなので、目新しい情報はない。

1. 7zで解凍

目的のovaを7zで解凍する。
すると.mf .ovf .vmhdが出てくる。
.vmhdを変換してhyper-vで使う。

2. 変換

まずはmicrosoft virtual machine converterをダウンロード&インストール
そしてpowershellを管理者で起動し次を実行

PS C:\WINDOWS\system32> import-module "C:\Program Files\Microsoft Virtual Machine Converter\MvmcCmdlet.psd1"
PS C:\WINDOWS\system32> ConvertTo-MvmcVhd -SourceLiteralPath "{Fullpath to vmdk}" -DestinationLiteralPath "Fullpath to vhdx" -VhdFormat Vhdx

特に何もなければこれで成功するらしいが、素直に成功したためしがない。
だいたいエラーでConvertTo-MvmcVhd : The entry {適当な文字列} is not a supported disk database entry for the descriptor.と言われる。

そうしたらdsfoとdsfiを探してダウンロードして以下のようにする。(dsfokとかで検索すると出てくるかも)
パスなどはよしなに

PS C:\WINDOWS\system32> .\dsfo.exe {vmdkへのパス} 512 1024 .\temp.txt
OK, 1024 bytes, 0.000s, MD5 = {適当な文字列}

出力されたファイル(今回はtemp.txt)をエディターで開く。
以下の結果はkali-linuxのvirtualboxのイメージに対して行ったもの

temp.txt
# Disk DescriptorFile
version=1
CID=539957cc
parentCID=ffffffff
createType="streamOptimized"

# Extent description
RDONLY 167772160 SPARSE "Kali-Linux-2020.3-vbox-amd64-disk001.vmdk"

# The disk Data Base 
# DDB

ddb.virtualHWVersion = "4"
ddb.adapterType="ide"
ddb.geometry.cylinders="16383"
ddb.geometry.heads="16"
ddb.geometry.sectors="63"
ddb.geometry.biosCylinders="1024"
ddb.geometry.biosHeads="255"
ddb.geometry.biosSectors="63"
ddb.uuid.image="7e158528-0b2d-4734-8ad9-1362ce2e625d"
ddb.uuid.parent="00000000-0000-0000-0000-000000000000"
ddb.uuid.modification="00000000-0000-0000-0000-000000000000"
ddb.uuid.parentmodification="00000000-0000-0000-0000-000000000000"
ddb.comment=""

この中からThe entry {文字列} ...の文字列部分を持つ行をさがしてコメントアウトする。
これで保存して次を実行。

PS C:\WINDOWS\system32> .\dsfi.exe {vmdkへのパス} 512 1024 .\temp.txt
OK, written 1024 bytes at offset 512

そうしたらこの章の冒頭のConvertTo-MvmcVhdを実行する。

最終的に次のようにしたら無事通った。

temp.txt
# Disk DescriptorFile
version=1
CID=539957cc
parentCID=ffffffff
createType="streamOptimized"

# Extent description
RDONLY 167772160 SPARSE "Kali-Linux-2020.3-vbox-amd64-disk001.vmdk"

# The disk Data Base 
# DDB

ddb.virtualHWVersion = "4"
ddb.adapterType="ide"
ddb.geometry.cylinders="16383"
ddb.geometry.heads="16"
ddb.geometry.sectors="63"
ddb.geometry.biosCylinders="1024"
ddb.geometry.biosHeads="255"
ddb.geometry.biosSectors="63"
# db.uuid.image="7e158528-0b2d-4734-8ad9-1362ce2e625d"
# db.uuid.parent="00000000-0000-0000-0000-000000000000"
# db.uuid.modification="00000000-0000-0000-0000-000000000000"
# db.uuid.parentmodification="00000000-0000-0000-0000-000000000000"
# db.comment=""

3. hyper-vで読み込み

やるきがあったら

まとめ

めんどうだからあんまり頻繁にconvertしたくない。
でも授業ではhyper-vを使いたい。

もっと簡単な方法ありそう

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?