CentOS on Hyper-V

2011.05.23

2012.01.08

Hyper-Vの環境にCentOSをインストールして,さらにLinux Integration Services v2.1 for Microsoft Hyper-V をインストールする.

CentOS

最新バージョンは5.6 http://www.centos.org/ から辿ってダウンロードをした.

Linux Integration Services v2.1 for Microsoft Hyper-V

これを入れないと,legacy NIC しかhyper-v machine から使えないし,何より時計が狂う.

ダウンロードはここから http://www.microsoft.com/downloads/ja-jp/details.aspx?FamilyID=EEE39325-898B-4522-9B4C-F4B5B9B64551

Linux Integration Services v2.1 for Microsoft Hyper-V.EXE

なる自己解凍圧縮ファイルが得られるので,これを展開すると,LinuxIC v21.iso という iso が得られる.

以前ダウンロードして展開したら入っていた ISOファイルの日付は 2010/03/30 だが,現在のは 2010/07/28 になっている.setupの方法も変わっているようだ.

2012.01.08 現在 Linux Integration Services v2.1 for Microsoft Hyper-V Release 2 がありますが,これをもってしても,CentOS6 には install できません(2012.01.08)

Hyper-V で新たなマシンを作成し,CentOS の DVD をマウントします.

「設定」で表示されるネットワークアダプターーは,一旦削除します.(Linux Integration Services v2.1 for Microsoft Hyper-V を インストールするまでは,通常の仮想NICは使えません.仮想NIC は legacy でないといけません.)

「ハードウェアの追加」をクリックして,レガシィネットワークアダプターを追加します.

この仮想マシンに CentOS5.6 の DVD をマウントします.

インストール は 起動したら

boot:linux text

で起動するのがよいです.serverにはGUI は要らないのですが,ないとさびしいので...見たくなったら,startx でGUIが起動します.

フツーにやって,runlevelを変更するも可

進めていくと,[server gui] なんて選択肢がある.なんだこれ.X とgnomeがインストールされる.Desktop インストールとインストールされるアプリが違う?

一通りおわって reboot 後,setup agent で --- さっさとしないと logon 画面になってしまう.

[Firewall Configuration] を選択して,Run tool を起動.

[Security Level] を Disabled に,[SELINUX] を Disabled に

[System Services] を選択して Run Tool を起動.

iptabels , sendmail disable

root で

yum update

以下は拡張機能の install のため - http://report.station.ez-net.jp/software/linux/centos/Hyper-V/document.asp も参考

yum install gcc

yum install kernel-devel

yum update kernel

ここらあたりで一度rebootが吉(かも)

次に進む前に,追加機能を install する.

Linux Integration Services v2.1 Read Me.pdf 参照

1. Open Hyper-V Manager: Click Start, point to Administrative Tools, and then click

Hyper-V Manager.

2. Create a new virtual machine where you will install Linux: In the Actions menu, click

New, and then click Virtual Machine.

3. Specify the Linux installation media: Right-click the virtual machine that you created, and

then click Settings. In IDE Controller, specify one of the following:

 An image file in ISO format that contains the files required for installation

 A physical CD/DVD drive that contains the installation media

4. Turn on the virtual machine: Right-click the virtual machine that you created, and then

click Connect.

5. Begin installing Linux.

6. Ensure that the optional package Software Development is selected during installation.

It is required to build and install Linux Integration Services.

7. When prompted, restart the virtual machine and complete any first-boot configuration

tasks.

Unless a legacy network adapter was added during the virtual machine‟s

initial configuration, the virtual machine will not have any network support.

8. Log on to the virtual machine.

9. In Hyper-V Manager, configure LinuxIC v21.ISO (located in the directory where you

extracted the downloaded files) as a physical CD/DVD drive on the virtual machine.

10. As the root user, mount the CD in the virtual machine by issuing the following commands

at a shell prompt:

# mkdir /mnt/cdrom

# mount /dev/cdrom /mnt/cdrom

11. Copy Linux Integration Services to the virtual machine. For example:

# mkdir /opt/linux_ic_v21_rtm

# cp –R /mnt/cdrom/* /opt/linux_ic_v21_rtm

12. As the root user, run the following command to compile and install the synthetic drivers. A

reboot is required after installation.

# cd /opt/linux_ic_v21_rtm/

# make

# make install

# reboot

shutdown して,Hyper-V manager で NIC の付け替え(legacy->ordinary)

vNIC もう一枚つける intra 用

これに 固定IPを振る

Red Hat Linux系のディストリビューションでeth0のネットワーク・カードに対して固定のIPアドレスを指定する場合は,/etc/sysconfig/network-scripts/ifcfg-eth0をテキスト・エディタで編集する。以下は設定例。

DEVICE=seth0 ← ネットワーク・インタフェース名

BOOTPROTO=static ← 固定IPアドレスの場合の指定

BROADCAST=192.168.10.255 ← ブロードキャスト・アドレス

IPADDR=192.168.10.110 ← IPアドレス

NETMASK=255.255.255.0 ← ネット・マスク

NETWORK=192.168.10.0 ← ネットワーク・アドレス

ONBOOT=yes ← マシン起動時にネットワークを有効にする場合はyes

reboot

これはサンプルで,実際には seth0 は インターネット用, seth1 が イントラ用なので,上記は seth1 に対して行う.

ここで問題が発生.

seth0 が dhcp 使用するので,nameserverまで 192.168.1.254 になってしまう.

nameserver が reboot のたびに変えられない様に,...どうするんだ...PEERDNS=no を追加するとよいらしい(ためしていない).

seth0 を static にしてみたが,状況は同じ.

X を起動して gnome のメニューからDNS server 設定したら,

system-config-network を なんとかと書いてある.これで reboot しても OK

resolve.conf も書き変わっていて,reboot しても元に戻らない.

で,この設定ファィルはなんだ? 設定ファイルではなくて tool だ.

これで設定すると,resolv.conf が書き変わらない状態で設定される.ほかの何かのファイルも書き換えているに違いない.まぁ,結果オーライにしておこう.

ところで...

windows では NIC 毎に DNS が設定できるが,LINUXではできない.resolv.confにまとめて書く.

DNS server を複数書くのは,障害用のバックアップを書くというイメージがあるので,ちょっとひっかかる.

ところが...つながらない...

gnome のツールから設定し直し.うまくいく(様な気がする).くやしいがgnome 恐るべし.

seth0 を static にしたときに, GATEWAY の記載を忘れたようだ.gnome のツールではこれを記入した.

やっぱり,resolv.conf の上の行でしか名前解決してくれない.

上下入れ替えたら,両方使ってくれる?

HOST名がまだ localhost.localdomain のまま

/etc/sysconfig/network を編集