labunix's blog

labunixのラボUnix

今更ながら、Windows2003R2(32bit/English)評価版をvmdkに変換する。

■今更ながら、Windows2003R2(32bit/English)評価版をvmdkに変換する。
 以下よりダウンロード。

 Microsoft Windows Server 2003 R2 Enterprise Edition VHD
 http://www.microsoft.com/en-us/download/details.aspx?id=19727

■卵が先か鶏が先か。

 WinRARを使えばすぐなのだけど、Windowsを入れるのにWindowsが必要では困る。
 free版unrarでは解凍出来ないので、nonfree版rarを使う。
 補足ですが、Debian Wheezy/JessieのホストOS、chroot環境のいずれでも手順は同じでした。

$ apt-cache show unrar-free | grep "^Sec\|^Ver"
Version: 1:0.0.1+cvs20071127-2
Section: utils

$ unrar --version
unrar 0.0.1

$ /usr/bin/unrar-free --version
unrar 0.0.1

■non-free版unrarをインストール

$ grep non-free /etc/apt/sources.list
deb http://ftp.debian.or.jp/debian jessie main non-free
$ for opt in update upgrade autoremove autoclean;do sudo apt-get $opt -y ;done
$ apt-cache show unrar | grep "^Sec\|^Ver"
Version: 1:4.1.4-1
Section: non-free/utils

$ sudo apt-get install -y unrar

$ unrar --version | grep ^UN
UNRAR 4.10 freeware      Copyright (c) 1993-2012 Alexander Roshal

$ ls -l /usr/bin/unrar* /etc/alternatives/unrar
lrwxrwxrwx 1 root root     22  324 23:34 /etc/alternatives/unrar -> /usr/bin/unrar-nonfree
lrwxrwxrwx 1 root root     23  46  2014 /usr/bin/unrar -> /etc/alternatives/unrar
-rwxr-xr-x 1 root root  36080  520  2012 /usr/bin/unrar-free
-rwxr-xr-x 1 root root 200952  215  2012 /usr/bin/unrar-nonfree

■non-free版はunrarにシンボリックリンクされるので、free版はフルパスで確認出来る。

$ /usr/bin/unrar-free --version
unrar 0.0.1

$ /usr/bin/unrar-nonfree --version | grep ^UN
UNRAR 4.10 freeware      Copyright (c) 1993-2012 Alexander Roshal

■exe/rarのファイルを確認

$ md5sum WIN2K3R2EE.part*
1a56ba1815eb6408d7564e48924f25df  WIN2K3R2EE.part1.exe
c927775f7c3b321f3697cf29a405550e  WIN2K3R2EE.part2.rar
f6b50807b5a54e39ed3046297e7b4769  WIN2K3R2EE.part3.rar

$ du WIN2K3R2EE.part*
716804	WIN2K3R2EE.part1.exe
716804	WIN2K3R2EE.part2.rar
572712	WIN2K3R2EE.part3.rar

■free版rarではexe形式を認識しない。

$ /usr/bin/unrar-free WIN2K3R2EE.part1.exe
/usr/bin/unrar-free: invalid archive 'WIN2K3R2EE.part1.exe': Bad address
Usage: unrar-free [OPTION...] ARCHIVE [FILE...] [DESTINATION]
Try `unrar-free --help' or `unrar-free --usage' for more information.
■non-free版rarで解凍

$ unrar l WIN2K3R2EE.part1.exe  | tail -15
Archive: WIN2K3R2EE.part1.exe
Details: RAR 4, SFX, volume

 Attributes      Size    Date   Time   Name
----------- ---------  -------- -----  ----
    ..A....       314  15-04-09 11:20  README_files/colorschememapping.xml
    ..A....       273  15-04-09 11:20  README_files/filelist.xml
    ..A....       216  15-04-09 11:20  README_files/item0001.xml
    ..A....       341  15-04-09 11:20  README_files/props0002.xml
    ..A....      3081  15-04-09 11:20  README_files/themedata.thmx
    ..A....     76559  15-04-09 11:20  README.htm  
    ..A.... 4128459776  23-03-09 18:33  WIN2K3R2EE.vhd
----------- ---------  -------- -----  ----
           4128540560  volume 1        7

$ unrar e WIN2K3R2EE.part1.exe 
...
Extracting  colorschememapping.xml                                    OK 
Extracting  filelist.xml                                              OK 
Extracting  item0001.xml                                              OK 
Extracting  props0002.xml                                             OK 
Extracting  themedata.thmx                                            OK 
Extracting  README.htm                                                OK 
Extracting  WIN2K3R2EE.vhd                                            35%

Extracting from WIN2K3R2EE.part2.rar

...         WIN2K3R2EE.vhd                                            71%

Extracting from WIN2K3R2EE.part3.rar

...         WIN2K3R2EE.vhd                                            OK 
Extracting  WIN2K3R2EE.vmc                                            OK 
Extracting  VHDTD_WS2003_EULA.xps                                     OK 
All OK

■VHDをVMDKに変換するのにqemu-imgを使う。

$ apt-file search qemu-img
qemu-utils: /usr/bin/qemu-img
qemu-utils: /usr/share/man/man1/qemu-img.1.gz

$ sudo apt-get install -y qemu-utils

$ qemu-img convert WIN2K3R2EE.vhd -O vmdk WIN2K3R2EE.vmdk

$ du WIN2K3R2EE.{vhd,vmdk}
4031704	WIN2K3R2EE.vhd
3680864	WIN2K3R2EE.vmdk

$ md5sum WIN2K3R2EE.{vhd,vmdk}
d1fcc821dac6e621602cba8a9ac0207a  WIN2K3R2EE.vhd
d2cf4bfd6c78abeca96d613d9d968b35  WIN2K3R2EE.vmdk