Xenのインストール
自分はOSをインストールするときに「仮想化」のパッケージグループを選択して、XenとKVM関係のパッケージをごりっとインストールしたので、OSのインストール完了時にはすでにDomain-0(dom0)が出来ていて、使用メモリも最大限が割当たってる状態でした。
# xm list Name ID Mem VCPUs State Time(s) Domain-0 0 4916 4 r----- 37.4
Xenのバージョンを上げる
CentOS 5.4のデフォルトではXen3.0.3なので、これは残念ということでXenのバージョンを上げます。
ここからXen3.4.2のパッケージを引っ張ってくる。自分は極力yumにrpm管理させたいのでrepoファイルを取ってきて/etc/yum.repos.dに追加しました。
# cd /etc/yum.repost.d # wget http://www.gitco.de/repo/CentOS5-GITCO_x86_64.repo
するとgitcoのレポジトリを見に行って、新しいパッケージを取ってきてくれます。
$ yum search xen Installed Packages <-- JAISTの方 Name : xen Arch : x86_64 Version : 3.0.3 Release : 94.el5_4.3 ... Available Packages <-- gitcoの方 Name : xen Arch : x86_64 Version : 3.4.1 Release : 7.el5 ... $ sudo yum update xen virt-manager
これでXen Hypervisorが3.4.2になりました。(kernel-xenは変更してません)
Domain-U(domU)を作成する
CentOSではvirt-installを使ってdomUを簡単に作成することができます。今回は下記のようなオプションを作成しました。準仮想化で、CPU数は1、10GBの仮想ディスクを作成します。またインストーラはsshしているコンソール上で行うのでGUIはオフ。
$ virt-install \ --paravirt \ --name=masaru \ --vcpus=1 \ --ram=2048 \ --file=/var/xen/masaru/disk.img \ --file-size=10 \ --nonsparse \ --location=http://ftp.riken.jp/Linux/centos/5/os/x86_64/ \ --nographics インストールを開始しています... ファイル vmlinuz を読出中... | 1.9 MB 00:00 TA ファイル initrd.img を読出中... | 7.1 MB 00:01 ETA ストレージファイルを作成中... | 10 GB 01:18 ETA ドメインを作成中... | 0 B 00:14 Connected to domain masaru Escape character is ^] Bootdata ok (command line is method=http://ftp.riken.jp/Linux/centos/5/os/x86_64/) Linux version 2.6.18-164.el5xen (mockbuild@builder10.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Thu Sep 3 04:03:03 EDT 2009 BIOS-provided physical RAM map: Xen: 0000000000000000 - 0000000080800000 (usable) No mptable found. Built 1 zonelists. Total pages: 526336 Kernel command line: method=http://ftp.riken.jp/Linux/centos/5/os/x86_64/ Initializing CPU#0 PID hash table entries: 4096 (order: 12, 32768 bytes) Xen reported: 2500.000 MHz processor. Console: colour dummy device 80x25 Dentry cache hash table entries: 524288 (order: 10, 4194304 bytes) Inode-cache hash table entries: 262144 (order: 9, 2097152 bytes) Software IO TLB disabled Memory: 2038528k/2105344k available (2490k kernel code, 57932k reserved, 1388k data, 184k init) Calibrating delay using timer specific routine.. 6253.36 BogoMIPS (lpj=12506731) Security Framework v1.0.0 initialized SELinux: Initializing. selinux_register_security: Registering secondary module capability Capability LSM initialized as secondary Mount-cache hash table entries: 256 ... XENBUS: Device with no driver: device/vbd/51712 XENBUS: Device with no driver: device/vif/0 XENBUS: Device with no driver: device/console/0 Initalizing network drop monitor service Write protecting the kernel read-only data: 478k Greetings. anaconda installer init version 11.1.2.195 starting mounting /proc filesystem... done creating /dev filesystem... done mounting /dev/pts (unix98 pty) filesystem... done mounting /sys filesystem... done anaconda installer init version 11.1.2.195 using /dev/xvc0 as console trying to remount root filesystem read write... done mounting /tmp as ramfs... done running install... running /sbin/loader
とこんな具合に仮想マシンが起動し、インストーラが走ります。うまく表示されてないですが、選択したいところでスペースおしたり、タブで項目移動するのは一緒です。
Welcome to CentOS +---------+ Choose a Language +---------+ | | | What language would you like to use | | during the installation process? | | | | Croatian ^ | | Czech : | | Danish # | | Dutch : | | English : | | Estonian : | | Finnish : | | French v | | | | +----+ | | | OK | | | +----+ | | | | | +---------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
インストール用のネットワークの設定なのでIPv4のDHCPのみ選択して次へ。
Welcome to CentOS +----------------+ Configure TCP/IP +----------------+ | | | [*] Enable IPv4 support | | (*) Dynamic IP configuration (DHCP) | | ( ) Manual configuration | | | | [ ] Enable IPv6 support | | (*) Automatic neighbor discovery (RFC 2461) | | ( ) Dynamic IP configuration (DHCP) | | ( ) Manual configuration | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +----------------------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
インストーラのディスクイメージを引っ張ってきています。
Welcome to CentOS +----------------------------+ Retrieving +----------------------------+ | | | Retrieving images/stage2.img... | | | +----------------------------------------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
GUIは使わないので"Use text mode"を選択。
+------+ Would you like to use VNC? +-------+ | | | The VNC mode installation offers more | | functionality than the text mode, would | | you like to use it instead? | | | | +---------------+ +-----------+ | | | Use text mode | | Start VNC | | | +---------------+ +-----------+ | | | | | +-------------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
こんにちは!
Welcome to CentOS +------------------+ CentOS +-------------------+ | | | Welcome to CentOS! | | | | | | +----+ | | | OK | | | +----+ | | | | | +-----------------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
仮想ディスク初期化してないので出る表示。ぜひ初期化してください。
Welcome to CentOS +---------------+ Warning +---------------+ | | | The partition table on device xvda ^ | | (Xen Virtual Block Device 10237 MB) # | | was unreadable. : | | To create new partitions it must be : | | initialized, causing the loss of : | | ALL DATA on this drive. : | | : | | This operation will override any : | | previous installation choices about : | | which drives to ignore. : | | : | | Would you like to initialize this v | | | | +-----+ +----+ | | | Yes | | No | | | +-----+ +----+ | | | | | +-----------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
xvdaというXen用のディスクデバイスを選択。(当然ながら実態は仮想ディスク)
Welcome to CentOS +-------------------------+ Partitioning Type +-------------------------+ | | | Installation requires partitioning of your hard drive. The | | default layout is reasonable for most users. You can either | | choose to use this or create your own. | | | | Remove all partitions on selected drives and create default layout. | | Remove linux partitions on selected drives and create default layout. | | Use free space on selected drives and create default layout. | | Create custom layout. | | | | Which drive(s) do you want to use for this installation? | | [*] xvda 10237 MB (Xen Virtual Block Device) ^ | | # | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +-----------------------------------------------------------------------+ <Space>,<+>,<-> selection | <F2> Add drive | <F12> next screen
はい、お願いします。
Welcome to CentOS +-------------------+ Warning +--------------------+ | | | You have chosen to remove all Linux partitions | | (and ALL DATA on them) on the following drives: | | | | xvda (Xen Virtual Block Device 10237 MB) | | | | Are you sure you want to do this? | | | | +----+ +-----+ | | | No | | Yes | | | +----+ +-----+ | | | | | +--------------------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
一応パーティションの情報を確認します。
Welcome to CentOS +-------+ Review Partition Layout +-------+ | | | Review and modify partitioning layout? | | | | +-----+ +----+ | | | Yes | | No | | | +-----+ +----+ | | | | | +-----------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
次はファイルシステムの設定画面。swapに4096MBとか割当たってたので2048MBに変更。
Welcome to CentOS +------------------------------+ Partitioning +------------------------------+ | | | Device Start End Size Type Mount Point | | VG VolGroup00 10112M VolGroup ^ | | LV LogVol00 8064M ext3 / : | | LV LogVol01 2048M swap : | | /dev/xvda # | | xvda1 1 13 101M ext3 /boot : | | xvda2 14 1305 10134M physical v : | | : | | : | | : | | v | | | | +-----+ +------+ +--------+ +------+ +----+ +------+ | | | New | | Edit | | Delete | | RAID | | OK | | Back | | | +-----+ +------+ +--------+ +------+ +----+ +------+ | | | | | +----------------------------------------------------------------------------+ F1-Help F2-New F3-Edit F4-Delete F5-Reset F12-OK
ブートローダにはGRUBを使います。
Welcome to CentOS +----------+ Boot Loader Configuration +-----------+ | | | Which boot loader would you like to use? | | | | (*) Use GRUB Boot Loader | | ( ) No Boot Loader | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +--------------------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
特に設定することはないのでデフォルト値を使用。
Welcome to CentOS +------------------+ Boot Loader Configuration +------------------+ | | | A few systems will need to pass special options to the kernel | | at boot time for the system to function properly. If you need | | to pass boot options to the kernel, enter them now. If you | | don't need any or aren't sure, leave this blank. | | | | console=xvc0____________________________________ | | | | [ ] Force use of LBA32 (not normally required) | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +-----------------------------------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
GRUBのパスワードを設定する場合はここで設定。自分はいらないので空のまま進める。
Welcome to CentOS +-------------+ Boot Loader Configuration +-------------+ | | | A boot loader password prevents users from passing | | arbitrary options to the kernel. For highest | | security, we recommend setting a password, but this | | is not necessary for more casual users. | | | | [ ] Use a GRUB Password | | | | Boot Loader Password: ________________________ | | Confirm: ________________________ | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +-------------------------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
起動デバイスにLVMを選択します。
Welcome to CentOS +-------------------+ Boot Loader Configuration +-------------------+ | | | The boot manager CentOS uses can boot other operating systems | | as well. You need to tell me what partitions you would like to | | be able to boot and what label you want to use for each of them. | | | | Default Boot label Device | | * CentOS /dev/VolGroup00/LogVol00 ^ | | : | | : | | # | | v | | | | +----+ +------+ +------+ | | | OK | | Edit | | Back | | | +----+ +------+ +------+ | | | | | +-------------------------------------------------------------------+ <Space> select | <F2> select default | <F4> delete | <F12> next screen>
ブートローダのインストール先を選択。MBRに入れてください。
Welcome to CentOS +----------+ Boot Loader Configuration +----------+ | | | Where do you want to install the boot loader? | | | | /dev/xvda Master Boot Record (MBR) | | /dev/xvda1 First sector of boot partition | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +-------------------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
ネットワークの設定は当然します。Yesを選択。
Welcome to CentOS +----+ Configure Network Interface +-----+ | | | Would you like to configure the eth0 | | network interface in your system? | | | | +-----+ +----+ | | | Yes | | No | | | +-----+ +----+ | | | | | +----------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
IPv6は特にいらないのでデフォルトのままでOKを押す。
Welcome to CentOS ++ Network Configuration for eth0 ++ | | | Xen Virtual Ethernet | | 00:16:36:78:65:75 | | | | [*] Activate on boot | | [*] Enable IPv4 support | | [ ] Enable IPv6 support | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +----------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
DHCPにするのでこのままOKを押す。
Welcome to CentOS +-----+ IPv4 Configuration for eth0 +-----+ | | | Xen Virtual Ethernet | | 00:16:36:78:65:75 | | | | (*) Dynamic IP configuration (DHCP) | | ( ) Manual address configuration | | | | IP Address Prefix (Netmask) | | ________________ / ________________ | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +-----------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
ホスト名もとりあえずDHCPによる割り振りにします。
Welcome to CentOS +--------------------+ Hostname Configuration +--------------------+ | | | If your system is part of a larger network where hostnames are | | assigned by DHCP, select automatically via DHCP. Otherwise, | | select manually and enter a hostname for your system. If you | | do not, your system will be known as 'localhost.' | | | | (*) automatically via DHCP | | ( ) manually ________________________ | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +------------------------------------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
タイムゾーンはAsia/Tokyoを選択。
Welcome to CentOS +-------+ Time Zone Selection +-------+ | | | What time zone are you located in? | | | | [*] System clock uses UTC | | | | Asia/Tbilisi ^ | | Asia/Tehran : | | Asia/Thimphu # | | Asia/Tokyo : | | Asia/Ulaanbaatar v | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +-------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
rootのパスワードの設定。
Welcome to CentOS +--------------+ Root Password +---------------+ | | | Pick a root password. You must type it | | twice to ensure you know what it is and | | didn't make a mistake in typing. Remember | | that the root password is a critical part | | of system security! | | | | Password: ********________________ | | Password (confirm): ********________________ | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +----------------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
インストールするパッケージグループの選択をします。
Welcome to CentOS +----------------------+ Package selection +----------------------+ | | | The default installation of CentOS includes a set of software | | applicable for general internet usage. What additional tasks | | would you like your system to include support for? | | | | [*] Server - GUI ^ | | [ ] Virtualization : | | [ ] Clustering # | | [ ] Storage Clustering v | | | | [*] Customize software selection | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +-----------------------------------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
自分が選んだパッケージは下記の通り。
- Administration Tools
- Base
- Development Tools
- Editors
- GNOME Desktop Environment
- Graphical Internet
- Web Server
- X Window System
そしていよいよインストールを始めます!
Welcome to CentOS +---------+ Installation to begin +----------+ | | | A complete log of your installation will | | be in /root/install.log after rebooting | | your system. You may want to keep this | | file for later reference. | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +--------------------------------------------+ <Space>,<+>,<-> selection | <F2> Group Details | <F12> next screen
進捗がずーっと表示されます。
Welcome to CentOS +------------------+ Package Installation +------------------+ | | | Name : | | Size : | | Summary: | | | | | | Status:+---------+ Install Starting +----------+ | | | | | | | Starting install process. This may | | | | take several minutes... | | | | | Time | | Total +---------------------------------------+ | | Complet | | Remaining: 944 2311M | | | | 0% | | | +------------------------------------------------------------+ <Space>,<+>,<-> selection | <F2> Group Details | <F12> next screen
いよいよインストールが終わって再起動します!
Welcome to CentOS +----------------------+ Complete +-----------------------+ | | | Congratulations, your CentOS installation is complete. | | | | Remove any media used during the installation process | | and press <Enter> to reboot your system. | | | | | | +--------+ | | | Reboot | | | +--------+ | | | | | +---------------------------------------------------------+ <Enter> to reboot
domUが再起動される様子がターミナルに表示されます。
sending termination signals...done sending kill signals...done disabling swap... /dev/mapper/VolGroup00-LogVol01 unmounting filesystems... /mnt/runtime done disabling /dev/loop0 /proc done /dev/pts done /sys done /tmp/ramfs done /selinux done /mnt/sysimage/boot done /mnt/sysimage/sys done /mnt/sysimage/proc done /mnt/sysimage/selinux done /mnt/sysimage/dev done /mnt/sysimage done rebooting system Restarting system. ゲストのインストールが完了しました... ゲストを再起動しています
Ctrl-]を押してdom0に戻ってみます。下記のコマンドで無事にdomUが作成されたことを確認します。
# xm list Name ID Mem VCPUs State Time(s) Domain-0 0 2464 4 r----- 1583.4 masaru 3 2048 1 -b---- 1219.4