2009年11月28日土曜日

Hyper-V上のLinux(CentOS)の時間が早く進むのを何とかしたい

Hyper-VにCentOS5.4を導入してみたが、どうにもせっかちさん。時刻がえらく進む。
 
 

ということでMicrosoftの仮想PC用お勧め設定を実施してみた。
 

The system time runs too fast on a Linux-based virtual machine that is hosted in Virtual Server 2005 R2
http://support.microsoft.com/kb/918461/en-us


 

起動時のカーネルオプションに "clock=pit" を指定しなさいということで、設定の意味もリンク先に書いてある。
 
ちょっち引用。
# Programmable Interval Timer (PIT)
This clock has the following characteristics:

* This clock is set by using the clock=pit kernel parameter.
* This clock uses only the PIT counter for time interpolation.
* This clock uses the simplest of the available algorithms.
* This clock does not gain time because it does not use lost tick correction code.

 

...シンプルだ、ということなのかな。。
 
 

手順通りにgrub.confを修正する。
 
[caption id="attachment_1593" align="alignnone" width="648" caption="画像:grub.conf編集"]画像:grub.conf編集[/caption]
 

で、起動してからntpdateでホストOSと時刻を同期後、少し待って比較する。
 
[caption id="attachment_1595" align="alignnone" width="334" caption="画像:同期してから5分後くらい"]画像:同期してから5分後くらい[/caption]
 

もう結構ずれてる...これでも大分マシになっているのだけど。
これじゃあちょっと物足りないなあ。
 
 

ついでに、サーバ起動直後(ntpdなし)が不思議なんだよね。
 
[caption id="attachment_1594" align="alignnone" width="486" caption="画像:起動時のサーバ時刻"]画像:起動時のサーバ時刻[/caption]
 

なんでホストからさらに+9時間なんでしょうか。
+9時間っつったらインストール時にロケールで日本を選択してるんだけど、調整しておかないほうがイイのかな?
追記:仕様ののようなのでUTCを使うべしという助言をいただきました。
/usr/share/zoneinfo/UTC を /etc/localtime にもってきて変更。

 
 

さらに別の方法を試すので、上手くいったら後編に続く。
 
 



追記:
WindowsServerをNTPソースにするのはこちらを参照しました。
http://d.hatena.ne.jp/hidepon_mory/20071106/1207896724