NICが手に入ったのでドライバいれようとしたらKernelのソースが必要だったので、Linux Kernel3.0.4をいれつつRTパッチ適用もしちゃう日記

ただの備忘録

Kernel 3.0.4


Get free Linux Kernel 3.0.4
kernel.orgがメンテナンス中なのでjaistさんにお世話になります。

cd /usr/src/
wget ftp://ftp.jaist.ac.jp/pub/Linux/kernel.org/linux/kernel/v3.0/linux-3.0.4.tar.gz
tar xzvf linux-3.0.4.tar.gz
cd linux-3.0.4


RealTimeパッチ適用したければ以下を実施。
配布元は不正な証明書を使ってるようです。

wget --no-check-certificate https://tglx.de/~tglx/rt/patch-3.0.4-rt14.gz
gunzip patch-3.0.4-rt14.gz
patch -p1 < patch-3.0.4-rt14


現在のカーネルの設定を引き継ぐ。
以下はCentOS 5.6のkernelのやつ。

 cp /boot/config-2.6.18-238.el5PAE .config


グラフィカルにconfigをいじるにはncurses-develが必要なので入れます。

yum install ncurses-devel


configを適当にいじりまわします。

make menuconfig


例によって出来上がった.configにおまじない。
kernel-panicはもう嫌だ。

CONFIG_SYSFS_DEPRECATED=y
CONFIG_SYSFS_DEPRECATED_V2=y

気になる人はudevとかCONFIG_SYSFS_DEPRECATEDで調べればいいよ。


ようやくmake。だがなぜかこんなエラーが出る。

(〜中略〜)

HOSTCC samples/hidraw/hid-example
In file included from /usr/include/linux/input.h:14,
from samples/hidraw/hid-example.c:14:
/usr/include/sys/types.h:62: error: conflicting types for ‘dev_t’
/usr/include/linux/types.h:13: error: previous declaration of ‘dev_t’ was here
/usr/include/sys/types.h:67: error: conflicting types for ‘gid_t’
/usr/include/linux/types.h:27: error: previous declaration of ‘gid_t’ was here
/usr/include/sys/types.h:72: error: conflicting types for ‘mode_t’
/usr/include/linux/types.h:15: error: previous declaration of ‘mode_t’ was here
/usr/include/sys/types.h:77: error: conflicting types for ‘nlink_t’
/usr/include/linux/types.h:16: error: previous declaration of ‘nlink_t’ was here
v82: error: conflicting types for ‘uid_t’
/usr/include/linux/types.h:26: error: previous declaration of ‘uid_t’ was here
In file included from /usr/include/sys/types.h:133,
from /usr/include/linux/input.h:14,
from samples/hidraw/hid-example.c:14:
/usr/include/time.h:105: error: conflicting types for ‘timer_t’
/usr/include/linux/types.h:22: error: previous declaration of ‘timer_t’ was here
In file included from /usr/include/linux/input.h:14,Qq
from samples/hidraw/hid-example.c:14:
/usr/include/sys/types.h:235: error: conflicting types for ‘blkcnt_t’
/usr/include/linux/types.h:114: error: previous declaration of ‘blkcnt_t’ was here
samples/hidraw/hid-example.c:15:26: error: linux/hidraw.h: そのようなファイルやディレクトリはありません
samples/hidraw/hid-example.c: In function ‘main’:
samples/hidraw/hid-example.c:48: error: storage size of ‘rpt_desc’ isn’t known
samples/hidraw/hid-example.c:49: error: storage size of ‘info’ isn’t known
samples/hidraw/hid-example.c:65: error: ‘HIDIOCGRDESCSIZE’ undeclared (first use in this function)
samples/hidraw/hid-example.c:65: error: (Each undeclared identifier is reported only once
samples/hidraw/hid-example.c:65: error: for each function it appears in.)
samples/hidraw/hid-example.c:73: error: ‘HIDIOCGRDESC’ undeclared (first use in this function)
samples/hidraw/hid-example.c:84: 警告: implicit declaration of function ‘HIDIOCGRAWNAME’
samples/hidraw/hid-example.c:91: 警告: implicit declaration of function ‘HIDIOCGRAWPHYS’
samples/hidraw/hid-example.c:98: error: ‘HIDIOCGRAWINFO’ undeclared (first use in this function)
samples/hidraw/hid-example.c:49: 警告: unused variable ‘info’
samples/hidraw/hid-example.c:48: 警告: unused variable ‘rpt_desc’
samples/hidraw/hid-example.c: In function ‘bus_str’:
samples/hidraw/hid-example.c:171: error: ‘BUS_VIRTUAL’ undeclared (first use in this function)
make[2]: *** [samples/hidraw/hid-example] エラー 1
make[1]: *** [samples/hidraw] エラー 2
make: *** [vmlinux] エラー 2

大体こんな感じのエラー。
一部のエラー文で検索すると、海外のフォーラムにも出ていた。
http://www.spinics.net/lists/mm-commits/msg84683.html


hidraw絡みのエラーらしい。よくわからない。
ちなみに、このソースコード(samples/hidraw/hid-example.c)をコンパイルしようとすると、
sys/types.hとlinux/types.hが同名の名前でtypedefしようとしており、
今回のソースコードを見る限り、必ず衝突するのでsamplesをコンパイル対象にしていればここで止まるはず。
多分。


対策。
samples/Makefile

                          hw_breakpoint/ kfifo/ kdb/ hidraw/

ここを

                          hw_breakpoint/ kfifo/ kdb/

こうすればいいだけだったりする。


あってるかわからないmakeコマンドを実施

make
make modules
make modules_install
make install

エラーっぽいのが出なければOK


最後にreboot後に新しく作ったkernelを使うようにする。

vi /etc/grub.conf

おそらく新しく作ったkernelは一番上にくるので、番号は0のはず。
以下のように変更。

default=0


再起動

reboot


reboot後、kernelを切り替えて起動すると、sshでログインできなくなっていた。
調べてみると、eth0の起動スクリプトがリネームされていて起動できない状態になっていた。
わけがわからない。どうしてこうなった・・・

cd /etc/sysconfig/network-scripts
mv ifcfg-eth0.bak ifcfg-eth0
ifup eth0


sshで接続しなおして、起動を確認。

uname -a

Linux localhost 3.0.4-rt14 #5 SMP PREEMPT RT Thu Sep 22 21:38:01 JST 2011 i686 i686 i386 GNU/Linux

ようやくNIC

今回使うのは、こちら。
Intel® PRO/1000 PT Dual Port Server Adapter
やふおくで3000〜4000円ぐらい。
PCI-Ex x4を使うので普通のマザーじゃ刺さりません。僕はPCI-Ex x16に挿してます。
NTT-X Storeにある安い鯖にはx4スロットがあるので挿せます。


公式ドライバのREADME
http://downloadmirror.intel.com/15817/eng/README.txt


ソースコードダウンロードからコンパイル、インストールまで。

cd /usr/src/
wget http://downloadmirror.intel.com/15817/eng/e1000e-1.5.1.tar.gz
tar xzvf e1000e-1.5.1.tar.gz
cd e1000e-1.5.1/src
make && make install


モジュール差し替え?

rmmod e1000e; modprobe e1000e

お好みで公式ドライバのREADMEを見てオプションの設定をしていく。



NICの設定。
network絡みのスクリプトファイルがいっぱいあるところにいく

cd /etc/sysconfig/network-scripts

新しいNICの設定。いまさらだけど隠してます。

vi ifcfg-eth1

DEVICE=eth1
BOOTPROTO=static
BROADCAST=192.168.XXX.XXX
HWADDR=XX:XX:XX:XX:XX:XX
IPADDR=192.168.XXX.XXX
NETMASK=255.255.XXX.XXX
NETWORK=192.168.XXX.XXX
ONBOOT=yes
MTU=1438


NICを再起動する。
が、今まで使ってたeth0は使わないので、ifupしない。
1行で打たないとネットが切られるだけなので、直接叩かないとifupできなくなる。

ifdown eth0; ifdown eth1; ifup eth1;

このコマンドを打ったら、ケーブルを挿しかえる。


eth0はもう使わないので、リネームするなりして使えなくする。

mv ifcfg-eth0 ifcfg-eth0.bak


いらないけど再起動

reboot


確認

ifconfig -a

eth1だけ元気に走り回って、後は死んでいれば完了。
お疲れ様でした(俺)