に再挑戦
夏ですね。本を買ってそれを読みつつ自宅鯖をXen化しようと企つつ企画倒れに終わってからおよそ1年、こりずにまた再挑戦する季節がやってきましたよ。
前回の失敗はHowTo本を片手にGUIで地雷をスイスイ回避〜みたいな軟弱な方法で挑んだためと結論づけ、今回は逆の方向からいってみますよーと。
とりあえず、ソースコードはどこから落とすのか探すこと30分(もかかったよ!)、以下から最新のver3.1を入手。
http://www.xensource.com/download/dl_31tarballs.html
READMEを読んだらいきなりmakeできるみたいなことが書いてあるので、右も左も分からないままmake実行。
make world
案外makeに時間がかかる。
暇なので別ディレクトリでtgzを展開してファイル数とかステップ数を見てみた。
mir@t43:~/xen-tmp/xen-3.1.0-src$ find | egrep '^.*\.(c|cc|h|cpp)$' | wc -l 2030 mir@t43:~/xen-tmp/xen-3.1.0-src$ find | egrep '^.*\.(c|cc|h|cpp)$' | xargs wc -l | grep '合計' 689717 合計
ファイル数は2000強、ステップ数は70万弱。
結構時間はかかったけれども、makeはできた(みたい)。途中でinclude/compiler.hがないよとかエラーでたたけど大丈夫なのかな?
さておき、READMEの続きを読んだらいろいろ指定方法が書いてあったので、それみてもう一度リビルドしよっかなぁ。
いろいろ指定してビルド
DESTDIR=/home/mir/xen/dist \ KERNELS="linux-2.6-xen0 linux-2.6-xenU" \ make world && make install
今度はDESTDIRとか指定してみた。既存のカーネルの上書きとかされたら困るし。make installでどうなるか、わくわく。
ビルドにまた時間がかかるのでMakefileをちょっと読む。
make helpでターゲット一覧を取得できた。
mir@t43:~/xen/xen-3.1.0-src$ make help Installation targets: install - build and install everything install-xen - build and install the Xen hypervisor install-tools - build and install the control tools install-kernels - build and install guest kernels install-docs - build and install user documentation Building targets: dist - build and install everything into local dist directory world - clean everything, delete guest kernel build trees then make dist xen - build and install Xen hypervisor tools - build and install tools kernels - build and install guest kernels kbuild - synonym for make kernels docs - build and install user documentation dev-docs - build developer-only documentation Cleaning targets: clean - clean the Xen, tools and docs (but not guest kernel trees) distclean - clean plus delete kernel build trees and local downloaded files kdelete - delete guest kernel build trees kclean - clean guest kernel build trees Miscellaneous targets: prep-kernels - prepares kernel directories, does not build mkpatches - make patches against vanilla kernels from sparse trees uninstall - attempt to remove installed Xen tools (use with extreme care!) Environment: XEN_PYTHON_NATIVE_INSTALL=y - native python install or dist install into prefix/lib/python<VERSION> instead of <PREFIX>/lib/python true if set to non-empty value, false otherwise
MySQLにもこの一覧機能欲しいところ。JavaでAnt使ってた時代"-projecthelp"とかで取得できて便利だった。
make install
DESTDIR指定してるのに/以下に入れようとして権限エラー。なんで。
Makefile
これってDISTDIRを指定しとけってことかしらん。
# build xen, the tools, and a domain 0 plus unprivileged linux-xen images, # and place them in the install directory. 'make install' should then # copy them to the normal system directories .PHONY: world world: $(MAKE) clean $(MAKE) kdelete $(MAKE) dist # build and install everything into local dist directory .PHONY: dist dist: DESTDIR=$(DISTDIR)/install dist: dist-xen dist-kernels dist-tools dist-docs $(INSTALL_DIR) $(DISTDIR)/check $(INSTALL_DATA) ./COPYING $(DISTDIR) $(INSTALL_DATA) ./README $(DISTDIR) $(INSTALL_PROG) ./install.sh $(DISTDIR) $(INSTALL_PROG) tools/check/chk tools/check/check_* $(DISTDIR)/check
ソースからインストールする方法(マニュアル)
発見!
でもあまり役に立つ情報はなかった。orz
DISTDIR指定でうまくいったかも
make installはもう/以下に上書きしてしまうっぽい。make worldの時にDISTDIRを指定しておくとそこに生成物を置いてくれるみたい。というか指定しないとソースディレクトリ以下にdistディレクトリが作られてそこに生成物が入るみたいだから、別にDISTDIR指定とかだったかも。単にdist/installを見れ、という話かも。
mir@t43:~/xen$ cd dist mir@t43:~/xen/dist$ ll 合計 40 -rw-r--r-- 1 mir mir 19355 5月 18 23:45 COPYING -rw-r--r-- 1 mir mir 7884 5月 18 23:45 README drwxr-xr-x 2 mir mir 4096 7月 20 19:37 check/ drwxr-xr-x 7 mir mir 4096 7月 20 19:36 install/ -rwxr-xr-x 1 mir mir 1161 5月 18 23:45 install.sh* mir@t43:~/xen/dist$ cd install mir@t43:~/xen/dist/install$ ll 合計 20 drwxr-xr-x 2 mir mir 4096 7月 20 19:36 boot/ drwxr-xr-x 7 mir mir 4096 7月 20 19:36 etc/ drwxr-xr-x 3 mir mir 4096 7月 20 19:23 lib/ drwxr-xr-x 7 mir mir 4096 7月 20 19:36 usr/ drwxr-xr-x 6 mir mir 4096 7月 20 19:37 var/ mir@t43:~/xen/dist/install$ find | wc -l 692 mir@t43:~/xen/dist/install$ ls usr/bin lomount xen-detect xenperf xenstore-control xenstore-list xenstore-read xenstore-write xentrace_format pygrub xencons xenstore-chmod xenstore-exists xenstore-ls xenstore-rm xentrace xentrace_setsize mir@t43:~/xen/dist/install$ ls boot System.map-2.6.18-xen0 config-2.6.18-xen0 vmlinux-syms-2.6.18-xen0 vmlinuz-2.6-xen0 vmlinuz-2.6.18-xen0 xen-3.1.0.gz xen-3.gz xen.gz System.map-2.6.18-xenU config-2.6.18-xenU vmlinux-syms-2.6.18-xenU vmlinuz-2.6-xenU vmlinuz-2.6.18-xenU xen-3.1.gz xen-syms-3.1.0