Jan 26, 2004

             onlsbc1, ネットワークブートシステムの検討
          			---  ネットワークブート #9
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
               (http://www-online.kek.jp/~inoue/para-CAMAC/
                                   Work/SBC-Linux29.html)



                        高エネルギー加速器研究機構
                            素粒子原子核研究所
                         物理、オンライングループ
                                井上 栄二

        目的

	    SBC-Linux28.htmlでの作業により、コンパクトフラッシュにインストールし
	  たGRUBを使って、ネットワークブートでディスクレスシステムを立ち上げる
	  ことができた。 ここでは、ディスクレスシステムの /usr について検討
	  する。


        項目

        (1). onlsbc1の2.5"IDEハードディスクシステムの/usrの検討
          (1-1).  2.5"IDE Debian GNU/Linuxシステムのマウント
          (1-2).  /usrディレクトリのパッキング
        (2). ディスクレスサーバの /tftpbootディレクトリの検討
          (2-1).  /usrディレクトリの展開
          (2-2).  展開した /usrディレクトリの修正
             (2-2-1).  /usr/srcディレクトリの修正
          (2-3).  /tftpboot/130.87.153.3/etc/fstabファイルの修正
        (3). ディスクレスシステムの起動テスト


  --------------------------------------------------------------------


 (1). onlsbc1の2.5"IDEハードディスクシステムの/usrの検討

	CC/NET用のLinuxシステムとして使用するには、/usrの下のファイルを多少修正
	しなければならない。 しかし、これまでに作成したディスクレスシステムは
	サーバの /usrディレクトリをリードオンリーのパーミッション付きでそのまま
	エクスポートしているものを、クライアントは使用している。 これではCC/NET
	用としてディスクレスクライアントを使用することはできない。

	先に、onlsbc1の2.5"IDEハードディスク上に Debian GNU/Linux 3.0 をインス
	トールした。 このシステムでは、Xもインストールしてあり、ローカルハード
	ディスクシステムとして Debian GNU/Linux 3.0 が、正常に動作している。
	このシステムの /usrを、ディスクレスクライアント用の /usrにコピーして使う
	ことを検討する。


   (1-1).  2.5"IDE Debian GNU/Linuxのマウント

	ディスクレスシステムを立ち上げる。 onlsbc1の2.5"IDEハードディスク上にイ
	ンストールしてある Debian GNU/Linux 3.0 を、/mntディレクトリに、マウント
	する。

root@onlsbc1:/home/inoue# /sbin/shutdown -h now
root@onlsbc1:/home/inoue#
Broadcast message from root (pts/0) (Thu Jan 22 10:26:46 2004):

The system is going down for system halt NOW!

	2.5"IDEハードディスクとコンパクトフラッシュを両方ともつないだ状態で、
	2.5"IDEハードディスクの Red Hat Linuxシステムを立ち上げる。 FD起動GRUBで
	ディスクレスシステムを立ち上げる。

onlsun3[41]% ssh onlsbc1
inoue@onlsbc1's password:
Linux onlsbc1 2.4.18 #1 2004年 1月 9日 金曜日 15:25:22 JST i586 unknown

Most of the programs included with the Debian GNU/Linux system are
freely redistributable; the exact distribution terms for each program
are described in the individual files in /usr/share/doc/*/copyright

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
You have new mail.
Last login: Thu Jan 22 10:12:57 2004 from onlsun3.kek.jp
inoue@onlsbc1:~$

	2.5"IDEハードディスクにインストールした Debian GNU/Linux 3.0 のパーティ
	ションを /mntディレクトリにマウントする。

root@onlsbc1:/home/inoue# fdisk -l

ディスク /dev/hdc: ヘッド 16, セクタ 63, シリンダ 993
ユニット = シリンダ数 of 1008 * 512 バイト

 デバイス ブート   始点      終点  ブロック   ID  システム
/dev/hdc1   *         1       993    500440+  83  Linux

ディスク /dev/hda: ヘッド 255, セクタ 63, シリンダ 4864
ユニット = シリンダ数 of 16065 * 512 バイト

 デバイス ブート   始点      終点  ブロック   ID  システム
/dev/hda1   *         1        69    554211   83  Linux
/dev/hda2            70      1000   7478257+  83  Linux
/dev/hda3          1001      1039    313267+  82  Linux スワップ
/dev/hda4          1040      4864  30724312+   f  Win95 拡張領域 (LBA)
/dev/hda5          1040      2364  10643031   83  Linux
/dev/hda6          2365      3589   9839781   83  Linux
/dev/hda7          3590      4864  10241406   83  Linux
root@onlsbc1:/home/inoue#
root@onlsbc1:/home/inoue# mount -t ext3 /dev/hda6 /mnt
root@onlsbc1:/home/inoue# df -k
Filesystem           1k-blocks      Used Available Use% Mounted on
130.87.153.112:/tftpboot/130.87.153.3
                      14278840   1880156  11673352  14% /
130.87.153.112:/usr   14278840   1880152  11673352  14% /usr
130.87.153.112:/home  14278840   1880152  11673352  14% /home
/dev/hda6              9685276    829196   8364092  10% /mnt
root@onlsbc1:/home/inoue#
root@onlsbc1:/home/inoue# ls -l /mnt
合計 112
drwxr-xr-x    2 root     root         4096 11月 27 17:08 bin
drwxr-xr-x    3 root     root         4096 11月 27 09:32 boot
drwxr-xr-x    2 root     root         4096 11月 27 02:29 cdrom
drwxr-xr-x    9 root     root        24576  1月 21 10:55 dev
drwxr-xr-x   57 root     root         4096  1月 21 10:55 etc
drwxr-xr-x    2 root     root         4096 11月 27 02:29 floppy
drwxrwsr-x    3 root     staff        4096 11月 27 08:40 home
drwxr-xr-x    2 root     root         4096 11月 27 02:29 initrd
drwxr-xr-x    5 root     root         4096 11月 27 09:11 lib
drwx------    2 root     root        16384 11月 27 01:41 lost+found
drwxr-xr-x    2 root     root         4096  2月  9  2002 mnt
drwxr-xr-x    2 root     root         4096 12月 11 08:53 mnt1
drwxr-xr-x    2 root     root         4096 12月 11 08:53 mnt2
drwxr-xr-x    2 root     root         4096 11月 27 02:29 opt
drwxr-xr-x    2 root     root         4096  2月  9  2002 proc
drwxr-xr-x    6 root     root         4096 11月 27 16:17 root
drwxr-xr-x    2 root     root         4096 11月 27 15:11 sbin
drwxrwxrwt    6 root     root         4096  1月 21 10:55 tmp
drwxr-xr-x   13 root     root         4096 11月 27 13:59 usr
drwxr-xr-x   13 root     root         4096 11月 27 02:29 var
lrwxrwxrwx    1 root     root           25 11月 27 01:58 vmlinuz -> boot/vmlinuz
-2.4.18-bf2.4
root@onlsbc1:/home/inoue#


   (1-2).  /usrディレクトリのパッキング

	マウントした2.5"IDEハードディスクにインストールしてある Debian GNU/Linux
	の /usrディレクトリ全体を tarファイルにする。

inoue@onlsbc1:/home$ pwd
/home
inoue@onlsbc1:/home$ ls -l
合計 4
drwxr-xr-x   31 inoue    inoue        4096  1月 19 11:24 inoue
inoue@onlsbc1:/home$ chmod go+w inoue
inoue@onlsbc1:/home$ ls -l
合計 4
drwxrwxrwx   31 inoue    inoue        4096  1月 19 11:24 inoue
inoue@onlsbc1:/home$

root@onlsbc1:/mnt# pwd
/mnt
root@onlsbc1:/mnt# ls -l
合計 112
drwxr-xr-x    2 root     root         4096 11月 27 17:08 bin
drwxr-xr-x    3 root     root         4096 11月 27 09:32 boot
drwxr-xr-x    2 root     root         4096 11月 27 02:29 cdrom
drwxr-xr-x    9 root     root        24576  1月 21 10:55 dev
drwxr-xr-x   57 root     root         4096  1月 21 10:55 etc
drwxr-xr-x    2 root     root         4096 11月 27 02:29 floppy
drwxrwsr-x    3 root     staff        4096 11月 27 08:40 home
drwxr-xr-x    2 root     root         4096 11月 27 02:29 initrd
drwxr-xr-x    5 root     root         4096 11月 27 09:11 lib
drwx------    2 root     root        16384 11月 27 01:41 lost+found
drwxr-xr-x    2 root     root         4096  2月  9  2002 mnt
drwxr-xr-x    2 root     root         4096 12月 11 08:53 mnt1
drwxr-xr-x    2 root     root         4096 12月 11 08:53 mnt2
drwxr-xr-x    2 root     root         4096 11月 27 02:29 opt
drwxr-xr-x    2 root     root         4096  2月  9  2002 proc
drwxr-xr-x    6 root     root         4096 11月 27 16:17 root
drwxr-xr-x    2 root     root         4096 11月 27 15:11 sbin
drwxrwxrwt    6 root     root         4096  1月 21 10:55 tmp
drwxr-xr-x   13 root     root         4096 11月 27 13:59 usr
drwxr-xr-x   13 root     root         4096 11月 27 02:29 var
lrwxrwxrwx    1 root     root           25 11月 27 01:58 vmlinuz -> boot/vmlinuz
-2.4.18-bf2.4
root@onlsbc1:/mnt#
root@onlsbc1:/mnt# tar cf /home/inoue/diskless-debian-usr-Jan222004.tar usr
root@onlsbc1:/mnt#

root@onlsbc1:/mnt# cd /home/inoue
root@onlsbc1:/home/inoue# gzip diskless-debian-usr-Jan222004.tar
root@onlsbc1:/home/inoue# ls -l diskless*
-rw-r--r--    1 nobody   nogroup  212619751  1月 22 14:59 diskless-debian-usr-Ja
n222004.tar.gz
root@onlsbc1:/home/inoue#


 (2). ディスクレスサーバの /tftpbootディレクトリの検討

	上記の項目(1-2)で作成した /usrディレクトリの tarファイルを、サーバ側の
	/tftpbootディレクトリの下に展開し、これをクライアントにエクスポートして
	使用するように変更する。


   (2-1).  /usrディレクトリの展開

	この作業はディスクレスサーバ、onlpc03上で行う。

onlsun3[34]% ssh onlpc03
inoue@onlpc03's password:
Linux onlpc03 2.4.18 #1 2003年 12月 24日 水曜日 14:32:09 JST i686 unknown

Most of the programs included with the Debian GNU/Linux system are
freely redistributable; the exact distribution terms for each program
are described in the individual files in /usr/share/doc/*/copyright

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
You have new mail.
Last login: Mon Jan 19 09:18:19 2004 from onlsun3.kek.jp
inoue@onlpc03:~$
inoue@onlpc03:~$ ls -l diskless*
-rw-r--r--    1 nobody   nogroup  212619751  1月 22 14:59 diskless-debian-usr-Ja
n222004.tar.gz
inoue@onlpc03:~$
inoue@onlpc03:~$ su
Password:
onlpc03:/home/inoue# cd /tftpboot/130.87.153.3
onlpc03:/tftpboot/130.87.153.3# pwd
/tftpboot/130.87.153.3
onlpc03:/tftpboot/130.87.153.3# ls -l
合計 1992
-rw-r--r--    1 root     root       593097  1月 13 09:03 System.map
drwxr-xr-x    2 root     root         4096 11月 28 09:06 bin
-rw-r--r--    1 root     root      1371992  1月 13 09:04 bzImage
drwxr-xr-x   10 root     root        24576  1月 22 14:09 dev
drwxr-xr-x   70 root     root         4096  1月 22 14:15 etc
drwxr-xr-x    3 root     root         4096  1月 19 09:55 home
drwxr-xr-x    5 root     root         4096 11月 28 09:06 lib
drwxr-xr-x    2 root     root         4096  1月 19 10:10 mnt
drwxr-xr-x    2 root     root         4096 12月 25 09:42 proc
drwxr-xr-x    2 root     root         4096 11月 28 09:06 sbin
drwxrwxrwt    5 root     root         4096  1月 23 06:30 tmp
drwxr-xr-x    2 root     root         4096 12月 25 09:42 usr
drwxr-xr-x   13 root     root         4096 10月 22 19:26 var
onlpc03:/tftpboot/130.87.153.3# ls -l usr
合計 0
onlpc03:/tftpboot/130.87.153.3# tar xzf /home/inoue/diskless-debian-usr-Jan22200
4.tar.gz
onlpc03:/tftpboot/130.87.153.3# ls -l usr
合計 76
drwxr-xr-x    6 root     root         4096 11月 27 13:59 X11R6
drwxr-xr-x    3 root     root        20480 11月 27 17:23 bin
drwxr-xr-x    2 root     root         8192 11月 27 17:23 doc
drwxr-xr-x    2 root     root         4096 11月 27 09:11 games
drwxr-xr-x   28 root     root         4096 11月 27 15:50 include
drwxr-xr-x    2 root     root         4096 11月 27 17:23 info
drwxr-xr-x   40 root     root        16384 11月 27 17:22 lib
drwxrwsr-x   10 root     staff        4096 11月 27 02:29 local
drwxr-xr-x    2 root     root         4096 11月 27 17:03 sbin
drwxr-xr-x   78 root     root         4096 11月 27 17:22 share
drwxrwsr-x    2 root     src          4096  2月  9  2002 src
onlpc03:/tftpboot/130.87.153.3#


   (2-2).  展開した /usrディレクトリの修正

     (2-2-1).  /usr/srcディレクトリの修正

	サーバ onlpc03 の /usr/share/src 下のカーネルソースに関係する各ファイル
	を /tftpboot/130.87.153.3/usr/src ディレクトリにコピーする。

onlpc03:/tftpboot/130.87.153.3# ls -l usr/src
合計 0
onlpc03:/tftpboot/130.87.153.3#

onlpc03:/usr/src# pwd
/usr/src
onlpc03:/usr/src# ls -l
合計 6676
drwxr-xr-x    3 root     root         4096 12月 10 09:27 kernel-headers-2.4.18-b
f2.4
-rw-r--r--    1 root     src       6809288 12月 24 15:25 kernel-image-2.4.18_nfs
root.Dec242003_i386.deb
drwxr-xr-x   14 root     root         4096  1月  9 16:16 kernel-source-2.4.18
lrwxrwxrwx    1 root     src            20 12月 10 09:24 linux -> kernel-source-
2.4.18
drwxr-xr-x    7 root     root         4096 10月 22 14:42 rpm
onlpc03:/usr/src#
onlpc03:/usr/src# tar cf - . | (cd /tftpboot/130.87.153.3/usr/src; tar xpf - )
onlpc03:/usr/src#
onlpc03:/tftpboot/130.87.153.3/usr/src# pwd
/tftpboot/130.87.153.3/usr/src
onlpc03:/tftpboot/130.87.153.3/usr/src# ls -l
合計 6676
drwxr-xr-x    3 root     root         4096 12月 10 09:27 kernel-headers-2.4.18-b
f2.4
-rw-r--r--    1 root     src       6809288 12月 24 15:25 kernel-image-2.4.18_nfs
root.Dec242003_i386.deb
drwxr-xr-x   14 root     root         4096  1月  9 16:16 kernel-source-2.4.18
lrwxrwxrwx    1 root     src            20  1月 23 15:24 linux -> kernel-source-
2.4.18
drwxr-xr-x    7 root     root         4096 10月 22 14:42 rpm
onlpc03:/tftpboot/130.87.153.3/usr/src#

	ここで、ディスクレスクライアント onlsbc1 をシャットダウンして、サーバ側
	の /etc/exportsファイルを修正する。

root@onlsbc1:/home/inoue# shutdown -h now
root@onlsbc1:/home/inoue#
Broadcast message from root (pts/0) (Fri Jan 23 15:26:32 2004):

The system is going down for system halt NOW!

	onlsbc1 はシャットダウンした。 サーバ側の修正を続行する。

onlpc03:/etc# pwd
/etc
onlpc03:/etc# vi exports
# /etc/exports: the access control list for filesystems which may be exported
#               to NFS clients.  See exports(5).
#/tftpboot/130.87.153.3 130.87.0.0/255.255.252.0(rw,no_root_squash)
#/tftpboot/130.87.153.3 onlsbc1.kek.jp(rw,no_root_squash)
/tftpboot/130.87.153.3 130.87.153.3(rw,no_root_squash)
#/usr    130.87.153.3(ro)
/home    130.87.153.3(rw)
~
~
exports: 7 lines, 347 characters
onlpc03:/etc#

onlpc03:/etc# exportfs
/tftpboot/130.87.153.3
                onlsbc1.kek.jp
/home           onlsbc1.kek.jp
/usr            onlsbc1.kek.jp
/tftpboot/130.87.153.3
                130.87.0.0/255.255.252.0
onlpc03:/etc#
onlpc03:/etc# exportfs -r
onlpc03:/etc# exportfs
/tftpboot/130.87.153.3
                onlsbc1.kek.jp
/home           onlsbc1.kek.jp
onlpc03:/etc#


   (2-3).  /tftpboot/130.87.153.3/etc/fstabファイルの修正

onlpc03:/tftpboot/130.87.153.3/etc# pwd
/tftpboot/130.87.153.3/etc
onlpc03:/tftpboot/130.87.153.3/etc# vi fstab
# /etc/fstab: static file system information.
#
#                        
130.87.153.112:/tftpboot/130.87.153.3   /       nfs     rw,rsize=8192,wsize=8192
        0       0
#130.87.153.112:/usr                    /usr    nfs     ro,rsize=8192
        0       0
130.87.153.112:/home                    /home   nfs     rw,rsize=8192,wsize=8192
        0       0
proc                                    /proc   proc    defaults
        0       0
/dev/fd0                                /floppy         auto    user,noauto
        0       0

#/dev/sdb4      none            swap    sw                      0       0
#/dev/cdrom     /cdrom          iso9660 ro,user,noauto          0       0
~
~
fstab: 11 lines, 455 characters
onlpc03:/tftpboot/130.87.153.3/etc#


 (3). ディスクレスシステムの起動テスト

	ディスクレスクライアント onlsbc1 を立ち上げる。

onlsun4[35]% ssh onlsbc1
inoue@onlsbc1's password:
Linux onlsbc1 2.4.18 #1 2004年 1月 9日 金曜日 15:25:22 JST i586 unknown

Most of the programs included with the Debian GNU/Linux system are
freely redistributable; the exact distribution terms for each program
are described in the individual files in /usr/share/doc/*/copyright

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
You have new mail.
Last login: Fri Jan 23 15:37:32 2004
inoue@onlsbc1:~$ df -k
Filesystem           1k-blocks      Used Available Use% Mounted on
130.87.153.112:/tftpboot/130.87.153.3
                      14278840   2856264  10697244  22% /
130.87.153.112:/home  14278840   2856264  10697248  22% /home
inoue@onlsbc1:~$

inoue@onlsbc1:~$ ls -l /usr
合計 76
drwxr-xr-x    6 root     root         4096 11月 27 13:59 X11R6
drwxr-xr-x    3 root     root        20480 11月 27 17:23 bin
drwxr-xr-x    2 root     root         8192 11月 27 17:23 doc
drwxr-xr-x    2 root     root         4096 11月 27 09:11 games
drwxr-xr-x   28 root     root         4096 11月 27 15:50 include
drwxr-xr-x    2 root     root         4096 11月 27 17:23 info
drwxr-xr-x   40 root     root        16384 11月 27 17:22 lib
drwxrwsr-x   10 root     staff        4096 11月 27 02:29 local
drwxr-xr-x    2 root     root         4096 11月 27 17:03 sbin
drwxr-xr-x   78 root     root         4096 11月 27 17:22 share
drwxrwsr-x    5 root     src          4096  1月 23 15:25 src
inoue@onlsbc1:~$ ls -l /usr/src
合計 6676
drwxr-xr-x    3 root     root         4096 12月 10 09:27 kernel-headers-2.4.18-b
f2.4
-rw-r--r--    1 root     src       6809288 12月 24 15:25 kernel-image-2.4.18_nfs
root.Dec242003_i386.deb
drwxr-xr-x   14 root     root         4096  1月  9 16:16 kernel-source-2.4.18
lrwxrwxrwx    1 root     src            20  1月 23 15:24 linux -> kernel-source-
2.4.18
drwxr-xr-x    7 root     root         4096 10月 22 14:42 rpm
inoue@onlsbc1:~$

root@onlsbc1:/home/inoue# vi /usr/src/t1
Testing
~
~
/usr/src/t1: new file: 1 lines, 8 characters
root@onlsbc1:/home/inoue# cat /usr/src/t1
Testing
root@onlsbc1:/home/inoue# ls -l /usr/src
合計 6680
drwxr-xr-x    3 root     root         4096 12月 10 09:27 kernel-headers-2.4.18-b
f2.4
-rw-r--r--    1 root     src       6809288 12月 24 15:25 kernel-image-2.4.18_nfs
root.Dec242003_i386.deb
drwxr-xr-x   14 root     root         4096  1月  9 16:16 kernel-source-2.4.18
lrwxrwxrwx    1 root     src            20  1月 23 15:24 linux -> kernel-source-
2.4.18
drwxr-xr-x    7 root     root         4096 10月 22 14:42 rpm
-rw-r--r--    1 root     src             8  1月 23  2004 t1
root@onlsbc1:/home/inoue# rm /usr/src/t1
root@onlsbc1:/home/inoue#

	ok.  ディスクレスクライアント onlsbc1 は正常に立ち上がった。 /usr/src
	ディレクトリは、上記の項目(2)で作成したカーネルソースがリード/ライトで
	マウントされている。


---xxxx