Yahoo! Japan | Google | Excite | ALC | goo | msn | Amazon

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

2006年11月06日

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

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

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

yum install gccyum install rpm-buildyum install redhat-rpm-configyum install ncurses-devel

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

wget http://mirrors.kernel.org/centos/4.4/updates/SRPMS/kernel-2.6.9-42.0.3.EL.src.rpmmkdir -p /usr/src/redhat/{BUILD,RPMS,SOURCES,SPECS,SRPMS}rpm -i kernel-2.6.9-42.0.3.EL.src.rpmcd /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.hvi 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 mrpropercp configs/kernel-2.6.9-x86_64.config .configmake oldconfigmake ※めっちゃ時間かかるで~make modules_installinstallkernel 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/sdadefault=0timeout=5splashimage=(hd0,0)/boot/grub/splash.xpm.gzhiddenmenutitle 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.imgtitle 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.imgtitle 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 で十分補正可能な範囲なはず,,,

カテゴリー: Linux