R.A. Epigonos et al.

[linux] nfsrootで使う。

debianの純正カーネルはnfs rootモジュールとNICドライバを、組み込みモジュール、組み込みドライバとしていないので、純正カーネルではnfs root出来ない。そこで、基本的な設定は純正カーネルに準拠して、nfs rootに必要な、nfs rootモジュールとNICドライバを組み込みにする。

まずnfs root環境の整備。nfsのrootになる場所(/tftpboot/Linux/)にdebian lennyをdebootstrupでインストール。debootstrapでlennyをインストールした場所にchroot。以降、カーネルコンパイルが終わるまでこの環境の下で作業。

server:~$ su -
server:~# mkdir -p /tftpboot/Linux
server:~# debootstrap --arch i386 lenny /tftpboot/Linux http://ftp.jp.debian.org/debian
server:~# chroot /tftpboot/Linux

純正カーネルのコンパイルに必要なパッケージをインストールするためにaptラインにdeb-srcを追加(/etc/apt/sources.listにdeb-srcのaptラインを追加)。aptitude update、aptitude upgradeを行う。

server:/# cat /etc/apt/sources.list
deb http://ftp.jp.debian.org/debian lenny main
server:/# echo "deb-src http://ftp.jp.debian.org/debian lenny main" >> /etc/apt/sources.list
server:/# cat /etc/apt/sources.list
deb http://ftp.jp.debian.org/debian lenny main
deb-src http://ftp.jp.debian.org/debian lenny main
server:/# aptitude update
server:/# aptitude upgrade

純正カーネルをビルドする際に必要なパッケージのインストール。

server:/# aptitude -R build-dep linux-image-2.6.26-1-686

debian lenny純正カーネルのソースパッケージをインストール(recommendパッケージは無で)。

server:/# aptitude -R install linux-source-2.6.26

ソースがインストールされたディレクトリに移動して、パッケージの解凍。解凍して出来たディレクトリから同じディレクトリにあるlinuxにシンボリックリンクを張る。

server:/# cd usr/src/
server:/usr/src# ls
linux-source-2.6.26.tar.bz2
server:/usr/src# tar jxf linux-source-2.6.26.tar.bz2
server:/usr/src# ln -s linux-source-2.6.26/ linux

debian純正のconfigファイル(/boot/config-2.6.26-1-686)を使うためにカーネルイメージをインストール。途中2回yes/noで質問。1回目をYes、2回目をNoで答える。インストールされた純正コンフィグファイルをコピーする。

server:/usr/src# ls /boot
server:/usr/src# aptitude -R install linux-image-2.6.26-1-686
Package configuration

Configuring linux-image-2.6.26-1-686

There is no vmlinuz symbolic link.

Such a link can be created now and will be updated by subsequently installed
image packages. This will be useful with some boot loaders such as LILO.

Create a symbolic link to the current kernel image?

<Yes>                         <No>

Package configuration

Configuring linux-image-2.6.26-1-686

You are attempting to install an initrd kernel image (version 2.6.26-1-686).
This will not work unless the boot loader is configured to use an initrd.

An initrd image is a kernel image that expects to use an INITial Ram Disk to
mount a minimal root file system into RAM and use that for booting.

The boot loader must be configured to use such images and the system will not
boot until this is done.

This message will appear for any new kernel installation unless the following
is added to /etc/kernel-img.conf:

"do_initrd = Yes"

Abort initrd kernel image installation?

<Yes>                         <No>

server:/usr/src# cp /boot/config-2.6.26-1-686 linux/.config

linuxディレクトリに移動。make oldconfigの途中でgccがないと怒られる(gcc-4.1はある。)のでgccをインストール。シンボリックリンク貼ればよいのかな。さらに、sys/types.hが無いとか言われるのでlibc6-devパッケージをインストールする。warningが残るがこのwirningは無視。

server:/usr/src# cd linux
server:/usr/src/linux# make oldconfig 1> ../oldcfg.stdout 2> ../oldcfg.stderr
server:/usr/src/linux# cat ../oldcfg.stderr
/bin/sh: gcc: command not found
make[1]: *** [scripts/basic/fixdep] Error 127
make: *** [scripts_basic] Error 2
server:/usr/src/linux# aptitude -R install gcc
server:/usr/src/linux# make oldconfig 1> ../oldcfg.stdout 2> ../oldcfg.stderr
server:/usr/src/linux# vi ../oldcfg.stderr
server:/usr/src/linux# aptitude -R install libc6-dev
server:/usr/src/linux# make oldconfig 1> ../oldcfg.stdout 2> ../oldcfg.stderr
server:/usr/src/linux# cat ../oldconfig.stderr
scripts/kconfig/lex.zconf.c:1628: warning: 'input' defined but not used

oldconfigが通ったので次にmenuconfig。ncrusesのライブラリがないと怒られるのでlibncurses5-devをインストール。でnfs bootとNICドライバ(Intel i82559に対応するe100かeepro100)の設定を変更する。と思ったがなぜかNICドライバは組み込みにしなくても動いた。(CONFIG_E100=yではなくCONFIG_E100=mのまま)。

server:/usr/src/linux# make menuconfig
 *** Unable to find the ncurses libraries or the
 *** required header files.
 *** 'make menuconfig' requires the ncurses libraries.
 ***
 *** Install ncurses (ncurses-devel) and try again.
 ***
make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1
make: *** [menuconfig] Error 2
server:/usr/src/linux# aptitude -R install libncurses5-dev
server:/usr/src/linux# make menuconfig
  1. Networking support -- Networking options -- IP: kernel level autoconfiguration
  2. Networking support -- Networking options -- IP: kernel level autoconfiguration -- IP: DHCP support
  3. Networking support -- Networking options -- IP: kernel level autoconfiguration -- IP: BOOTP support
  4. Networking support -- Networking options -- IP: kernel level autoconfiguration -- IP: RARP support
  5. Filesystems -- Network File Systems -- NFS filesystem support

出来たファイルのdiffをとるとこんな感じ。コンフリクトチェックのためにCONFIG_DEBUG_SECTION_MISMATCH=yを入れておいたほうが良かったかな。

server:/usr/src/linux# diff /boot/config-2.6.26-1-686 .config
4c4
< # Sat Jan 10 17:07:32 2009
---
> # Sat Mar 14 03:07:02 2009
505c505,508
< # CONFIG_IP_PNP is not set
---
> CONFIG_IP_PNP=y
> CONFIG_IP_PNP_DHCP=y
> CONFIG_IP_PNP_BOOTP=y
> CONFIG_IP_PNP_RARP=y
3869c3872
< CONFIG_NFS_FS=m
---
> CONFIG_NFS_FS=y
3878c3881,3882
< CONFIG_LOCKD=m
---
> # CONFIG_ROOT_NFS is not set
> CONFIG_LOCKD=y
3881c3885
< CONFIG_NFS_ACL_SUPPORT=m
---
> CONFIG_NFS_ACL_SUPPORT=y
3883,3884c3887,3888
< CONFIG_SUNRPC=m
< CONFIG_SUNRPC_GSS=m
---
> CONFIG_SUNRPC=y
> CONFIG_SUNRPC_GSS=y
3887c3891
< CONFIG_RPCSEC_GSS_KRB5=m
---
> CONFIG_RPCSEC_GSS_KRB5=y
4087c4091
< CONFIG_CRYPTO_BLKCIPHER=m
---
> CONFIG_CRYPTO_BLKCIPHER=y
4106c4110
< CONFIG_CRYPTO_CBC=m
---
> CONFIG_CRYPTO_CBC=y
4144c4148
< CONFIG_CRYPTO_DES=m
---
> CONFIG_CRYPTO_DES=y

で、カーネルパッケージファイルを作る。

server:/usr/src/linux# make-kpkg clean
server:/usr/src/linux# make-kpkg --append_to_version -1-i686 --initrd --revision=custom.2.0 kernel_image
....................................................
  LD [M]  sound/usb/usx2y/snd-usb-usx2y.ko
make[1]: Leaving directory `/usr/src/linux-source-2.6.26'
/usr/bin/make  EXTRAVERSION=-1-i686  ARCH=i386 \
                             -C Documentation/lguest
make[1]: Entering directory `/usr/src/linux-source-2.6.26/Documentation/lguest'
cc -Wall -Wmissing-declarations -Wmissing-prototypes -O3 -I../../include    lguest.c  -lz -o lguest
lguest.c:34:18: error: zlib.h: No such file or directory
make[1]: *** [lguest] Error 1
make[1]: Leaving directory `/usr/src/linux-source-2.6.26/Documentation/lguest'
make: *** [debian/stamp/build/kernel] Error 2

コンパイルの途中でzlib.hがないといわれるので導入。改めてmake-dpkg。

server:/usr/src/linux# aptitude -R install zlib1g-dev
server:/usr/src/linux# make-kpkg --append_to_version -1-i686 --initrd --revision=custom.2.0 kernel_image

出来たパッケージをインストール。質問にはNoで答える。

server:/user/src# cd ../
server:/user/src# make-kpkg --append_to_version -1-i686 --initrd --revision=custom.2.0 kernel_image
Configuring linux-image-2.6.26-1-i686

You are attempting to install an initrd kernel image (version 2.6.26-1-i686)
This will not work unless you have configured your boot loader to use initrd.
(An initrd image is a kernel image that expects to use an INITial Ram Disk to
mount a minimal root file system into RAM and use that for booting).

As a reminder, in order to configure LILO, you need to add an
'initrd=/initrd.img' to the image=/vmlinuz stanza of your /etc/lilo.conf

I repeat, You need to configure your boot loader -- please read your
bootloader documentation for details on how to add initrd images.

If you have already done so, and you wish to get rid of this message, please
put
 "do_initrd = Yes"
in /etc/kernel-img.conf. Note that this is optional, but if you do not, you
will continue to see this message whenever you install a kernel image using
initrd.

Do you want to abort now?

<Yes>                         <No>

chroot環境での仕事はこれで終了。exitして元の環境に戻る。

server:/user/src# exit
server:~#

で、クライアントを起動。ブロックデバイスや、スピーカがこれで使えるようになる。ためしにlsmodしてみると多くのモジュールが読み込まれていることがわかる。

nfsrootclient:~# lsmod

メモリを大量に食わせて落とす。一方の仮想コンソールで走らせて、もう一方の仮想コンソールでtop -sするとメモリが食われていく様子がわかる。確かにメモリ確保に失敗しそうなタイミングでおちる。

nfsrootclient:~# cat test.pl
#!/usr/bin/perl -w

use warnings;
use strict;

my $f;
my $i = 0;
my $j = 0;

for ($i = 0; $i < 1000; $i++ ) {
        for ($j = 0; $j < 1000; $j++ ) {
                print "$i\t$j\n";
                $f->{$i}->{$j}++;
                my @F = (1..100);
                $f->{$i}->{$j} = \@F;
        }
}
nfsrootclient:~# perl test.pl

ブロックデバイスのパーティションタイプをチェックしてswap領域をfstabに追加する。swap領域を有効化して状態チェック。

nfsrootclient:~# fdisk -l /dev/hda
nfsrootclient:~# echo "/dev/hda5       swap    swap    defaults        0       0" >> /etc/fstab
nfsrootclient:~# swapon -a
nfsrootclient:~# swapon -s

再度先のメモリ食いつぶしプログラムを走らせながらtop -sでチェック。VIRTが物理メモリよりも大きくなり、swapが発生し、swap領域を使い果たし、落ちることを確認。swap領域が再起動時に自動マウントされることを確認。

rootパスワードの登録。一般ユーザの登録。rshサーバの導入。終了。

nfsrootclient:~# passwd
nfsrootclient:~# adduser hoge
nfsrootclient:~# aptitude -R install rsh-server
nfsrootclient:~# shutdown -h now

再起動して、サーバ側からrshで接続。

hoga@server:~$ rsh -l hoge 192.168.1.5

ログイン成功したらrootになる。ethtoolの導入。wol出来るようにeth1を変更。終了。

hoge@nfsrootclient:~$ su -
nfsrootclient:~# aptitude -R install ethtool
nfsrootclient:~# ethtool -s eth0 wol g

magic packetに反応するか確認。

server:~# wakeonlan -i 192.168.1.5 00:00:00:00:00:00

aptitudeを使うためにパッケージリストのupdateとupgrade。debian lenny純正カーネルのソースパッケージをインストール(recommendパッケージは無で)。tftpbootのルート(/tftpboot)を/etc/exportsに追加。

server:# echo "/tftpboot 192.168.0.0/255.255.0.0(rw,no_subtree_check,no_root_squash)">> /etc/exports
server:# ls /boot
server:# cp /boot/config-2.6.26-1-686 .config
server:# cat ../oldconfig.stderr

nfs関係のモジュールとNICどらいばを組み込みにする。

server:# make menuconfig
server:# diff /boot/config-2.6.26-1-686 .config
3,4c3,4
< # Linux kernel version: 2.6.26
< # Sat Jan 10 17:07:32 2009
---
> # Linux kernel version: 2.6.26-1-i686
> # Fri Mar 13 09:37:32 2009
505c505,508
< # CONFIG_IP_PNP is not set
---
> CONFIG_IP_PNP=y
> CONFIG_IP_PNP_DHCP=y
> CONFIG_IP_PNP_BOOTP=y
> CONFIG_IP_PNP_RARP=y
1679c1682
< CONFIG_MII=m
---
> CONFIG_MII=y
1749c1752
< CONFIG_E100=m
---
> CONFIG_E100=y
3869c3872
< CONFIG_NFS_FS=m
---
> CONFIG_NFS_FS=y
3878c3881,3882
< CONFIG_LOCKD=m
---
> CONFIG_ROOT_NFS=y
> CONFIG_LOCKD=y
3881c3885
< CONFIG_NFS_ACL_SUPPORT=m
---
> CONFIG_NFS_ACL_SUPPORT=y
3883,3884c3887,3888
< CONFIG_SUNRPC=m
< CONFIG_SUNRPC_GSS=m
---
> CONFIG_SUNRPC=y
> CONFIG_SUNRPC_GSS=y
3887c3891
< CONFIG_RPCSEC_GSS_KRB5=m
---
> CONFIG_RPCSEC_GSS_KRB5=y
4087c4091
< CONFIG_CRYPTO_BLKCIPHER=m
---
> CONFIG_CRYPTO_BLKCIPHER=y
4106c4110
< CONFIG_CRYPTO_CBC=m
---
> CONFIG_CRYPTO_CBC=y
4144c4148
< CONFIG_CRYPTO_DES=m
---
> CONFIG_CRYPTO_DES=y
server:# ls /usr/src
linux        
linux-source-2.6.26
linux-source-2.6.26.tar.bz2
linux-image-2.6.26-1-i686_custom.1.0_i386.deb
server:# cp linux-image-2.6.26-1-i686_custom.1.0_i386.deb /tftpboot/Linux/usr/src

nfsのrootになるディレクトリにchroot。dpkgに依存関係でおこられた。linux-image-2.6.26-1-i686_custom.1.0_i386.debが必要としているパッケージをaptitudeでインストール。純正のlinux-image-2.6.26-1-686パッケージと依存関係はほとんど同じと思われるが、怒られたものだけをインストール。再度カーネルのインストール。

server:# chroot /tftpboot/Linux
server:# cd /usr/src
server:# aptitude show
server:# dpkg -i kernel-image-2.4.26-1-i686_custom.1.0_i386.deb
server:# aptitude show linux-image-2.6.26-1-686
Package: linux-image-2.6.26-1-686
New: yes
State: installed
Automatically installed: no
Version: 2.6.26-13
Priority: optional
Section: admin
Maintainer: Debian Kernel Team <debian-kernel@lists.debian.org>
Uncompressed Size: 59.6M
Depends: module-init-tools, initramfs-tools (>= 0.55) | yaird (>= 0.0.13) | linux-initramfs-tool
PreDepends: debconf | debconf-2.0
Recommends: libc6-i686
Suggests: linux-doc-2.6.26, grub | lilo
Conflicts: initramfs-tools (< 0.55), yaird (< 0.0.13)
Provides: linux-image, linux-image-2.6, linux-modules-2.6.26-1-686
Description: Linux 2.6.26 image on PPro/Celeron/PII/PIII/P4
 This package provides the binary image and pre-built loadable modules for Linux kernel 2.6.26 on Pentium Pro/Celeron/Pentium II/Pentium III/Pentium 4 machines.
server:# aptitude -R install initramfs-tools yaird linux-initramfs-tool
server:# dpkg -i kernel-image-2.4.26-1-i686_custom.1.0_i386.deb

nfsクライアントの起動。ハードウェアが使えるようになっていることを確認。

client:# fdisk /dev/hda

ソーシャルブックマーク

  1. はてなブックマーク
  2. Google Bookmarks
  3. del.icio.us

ChangeLog

  1. Posted: 2009-03-10T18:13:14+09:00
  2. Modified: 2009-03-10T19:52:49+09:00
  3. Generated: 2023-08-27T23:09:10+09:00