VMware 用に CentOS カーネル再構築 ( ゚Д゚)マンドクセー

※この情報は古いです。VMware 上の CentOS の時間が狂う…は divider で回避 を参照してください。

VMware 上の CentOS の時間が狂う ( θ_Jθ)コマッタモンダ のとおり、VMware と Linux 2.6 系の相性の悪さは最悪。しょうがないので、カーネルを再構築して、VMware 上でも時間の狂わない CentOS を作る。
注意しないといけないのは、カーネルのセキュリティアップデートが出るたびに、この作業を行わないといけないというところ。 ( ゚Д゚)マンドクセー

カーネル再構築に必要なものをインストール

yum install gcc
yum install rpm-build
yum install redhat-rpm-config
yum install ncurses-devel

カーネルソースのインストールと展開

wget http://mirrors.kernel.org/centos/4.4/updates/SRPMS/kernel-2.6.9-42.0.3.EL.src.rpm
mkdir -p /usr/src/redhat/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
rpm -i kernel-2.6.9-42.0.3.EL.src.rpm
cd /usr/src/redhat/SPECS/
rpmbuild -bp --target=x86_64 kernel-2.6.spec

カーネルをいぢくる

cd ../BUILD/kernel-2.6.9/linux-2.6.9/
vi include/asm-i386/param.h
vi include/asm-x86_64/param.h

--- include/asm-i386/param.h.old
+++ include/asm-i386/param.h
@@ -2,7 +2,7 @@
#define _ASMi386_PARAM_H

#ifdef __KERNEL__
-# define HZ 1000 /* Internal kernel timer frequency */
+# define HZ 100 /* Internal kernel timer frequency */
# define USER_HZ 100 /* .. some user interfaces are in "ticks" */
# define CLOCKS_PER_SEC (USER_HZ) /* like times() */
#endif

--- include/asm-x86_64/param.h.old
+++ include/asm-x86_64/param.h
@@ -2,7 +2,7 @@
#define _ASMx86_64_PARAM_H

#ifdef __KERNEL__
-# define HZ 1000 /* Internal kernel timer frequency */
+# define HZ 100 /* Internal kernel timer frequency */
# define USER_HZ 100 /* .. some user interfaces are in "ticks */
#define CLOCKS_PER_SEC (USER_HZ) /* like times() */
#endif

カーネルにバージョン番号をつける

vi Makefile

--- Makefile.old
+++ Makefile
@@ -1,7 +1,7 @@
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 9
-EXTRAVERSION = -prep
+EXTRAVERSION = -42.0.3.EL.vm
NAME=AC 1

# *DOCUMENTATION*
@@ -511,7 +511,7 @@
# images. Uncomment if you want to place them anywhere other than root.
#

-#export INSTALL_PATH=/boot
+export INSTALL_PATH=/boot

#
# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory

カーネルのコンパイルとインストール

make mrproper
cp configs/kernel-2.6.9-x86_64.config .config
make oldconfig
make ※めっちゃ時間かかるで~
make modules_install
installkernel 2.6.9-42.0.3.EL.vm arch/x86_64/boot/bzImage System.map

grub 設定して再起動

vi /etc/grub.conf

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, eg.
# root (hd0,0)
# kernel /boot/vmlinuz-version ro root=/dev/sda1
# initrd /boot/initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.9-42.0.3.EL.vm)
root (hd0,0)
kernel /boot/vmlinuz-2.6.9-42.0.3.EL.vm ro root=LABEL=/ clock=pit
initrd /boot/initrd-2.6.9-42.0.3.EL.vm.img
title CentOS (2.6.9-42.0.3.EL)
root (hd0,0)
kernel /boot/vmlinuz-2.6.9-42.0.3.EL ro root=LABEL=/
initrd /boot/initrd-2.6.9-42.0.3.EL.img
title CentOS-4 x86_64 (2.6.9-42.EL)
root (hd0,0)
kernel /boot/vmlinuz-2.6.9-42.EL ro root=LABEL=/
initrd /boot/initrd-2.6.9-42.EL.img

shutdown -r now

あとは ntpd を設定して、時間補正を。これだけやっときゃ、たぶん ntpd で十分補正可能な範囲なはず,,,

タイトルとURLをコピーしました