uni(SSDベース)へのvine4.1+RTAI3.4+bigphysareaのインストール

MAX38計算機の酒向メモ をほぼそのまま踏襲。

●ハードウェア構成は

  • Intel Pentium4 3GHz
  • 2GBメモリ
  • HDDではなく、Transcend 32GB SSD TS32GSSD25-M
●まずVine linux 4.1をデスクトップパッケージでデフォルトのままでインストール

●apt updates/install
apt-get update
apt-get upgrade
apt-get install aptitude ntp kterm gnuplot perl-Tk
apt-get install ncurses-devel 
apt-get install samba
●NTPD
gnomeの時間設定ウインドウからntpサーバ問い合わせ を有効にする
ntpサーバは天文センター内(platini=157.82.120.101)にする

●サービスの選択
chkconfig --del postfix
chkconfig --del cpuspeed
chkconfig --del acpid
chkconfig --del cups
chkconfig --del smb
chkconfig --del iptables
#NFS関連はとりあえず外しておく
chkconfig --del netfs
chkconfig --del autofs
chkconfig --del nfs

chkconfig --level 345 ntpd on
chkconfig --level 345 nfs on
#chkconfig --level 345 smb on
chkconfig --level 345 autofs on
●RT Linux Install
  • カーネル用DIRを作成
    cd /usr/src
    mkdir linux2.6.17+RTAI3.4/
    cd linux2.6.17+RTAI3.4/
    
  • RTAIソースをダウンロード
    mkdir download
    cd download
    
    #https://www.rtai.org/より、最新のRTAI (rtai-3.4)と
    #そのManual (RTAI 3.4 User Manual rev.03)をダウンロード
  • RTAIソースを解凍
    README                              hal-linux-2.6.12-i386-r12.patch
    hal-linux-2.4.30-i386.patch         hal-linux-2.6.13-i386-1.0-09.patch
    hal-linux-2.4.31-i386.patch         hal-linux-2.6.14-i386-1.1-02.patch
    hal-linux-2.4.32-i386-1.2-05.patch  hal-linux-2.6.15-i386-1.3-00.patch
    hal-linux-2.4.33-i386-1.2-05.patch  hal-linux-2.6.16-i386-1.3-08.patch
    hal-linux-2.6.10-i386-r12.patch     hal-linux-2.6.17-i386-1.3-08.patch
    hal-linux-2.6.11-i386-r12.patch
    
    より、パッチはたくさんあります。
    linux-2.6.17カーネルにパッチをあてることにしましょう。
  • 本家カーネルソースをダウンロード
    cd /usr/src/linux2.6.17+RTAI3.4/linux-2.6.17rtai
    patch -p1 -b < /usr/src/linux2.6.17+RTAI3.4/rtai-3.4/base/arch/i386/patches/hal-linux-2.6.17-i386-1.3-08.patch
    
    ※今回はbigphysareaパッチをあてない
  • カーネルのconfigファイルをつくる
    cd /usr/src/linux2.6.17+RTAI3.4/linux-2.6.17rtai
    #vineの.configファイルを利用する
    cp  /boot/config-2.6.16-0vl68  ./.config
    
    #.configファイルを編集する
    make menuconfig
    
    
    rtai-3.4のREADME.INSTALLより
    /*-----------------------------------------------------------------------------------*/
     <> “Use register arguments” under “Processor type and features” must be disabled
     <> “Interrupt pipeline” under “Processor type and features” must be enabled (but, unless
         you want to control/debug the patch behaviour) is better to disable statitics gathering as
         it adds some overhead)
     <> “Module versioning support” under “Loadable module support” must be disabled
    
        Note: Attention must be taken for the APIC (Advanced Programmable Interrupt Controller)
        configuration; the option is located under “Processor type and features”. In the previous
        versions the APIC had to be disabled on UP machine, and could only by used on MP ones. With
        the latest RTAI release the APIC can be enabled and used with success even on UP machines
        and with this option enabled the system will benefit of faster timer reprogramming in oneshot
        mode and lesser overhead. Anyhow if the APIC is configured/enabled in the kernel but it's not
        present on your hardware RTAI will complain and give you the following error:
        RTAI[hal]:ERROR, LOCAL APIC CONFIGURED BUT NOT AVAILABLE/ENABLED
    /*-----------------------------------------------------------------------------------*/
    
    よって、
    "Processor type and features" -> "Use register arguments"               [disabled]
    "Processor type and features" -> "Interrupt pipeline"                   [enabled]
    !!! "Processor type and features" -> " Local APIC support on uniprocessors" [disabled] このoptionがみあたらない、、設定せず
    "Loadable module support"     -> "Module versioning support"            [disabled]
    
    また、http://debian.fam.cx/index.php?Software0.000000LinuxKernel#content_1_5
    /*-----------------------------------------------------------------------------------*/
    2.1.2 システム起動に必要な設定について
    システムの起動時に必要なものは モジュール (M) ではなく Y にした方がいいです。
    例えば HDD のアクセス関係
    
        * CONFIG_IDE (IDE 接続の HDD)
        * CONFIG_SCSI (SCSI 接続の HDD)
    
    ルートファイルシステムに使われているファイルシステム関係
    
        * CONFIG_EXT3_FS (ext3 ファイルシステム)
        * CONFIG_REISERFS_FS (reiserfs ファイルシステム)
    
    など。これらを M にした場合、initrd-tools (initramfs-tools, yaird) 等を利用しないと
    起動できなくなります。公式のカーネルパッケージの /boot/config-* は、これらが M になって
    いるので、そのまま流用するとハマります。最も初歩的な kernel panic で起動できなくなる
    原因の一つなので注意。
    /*-----------------------------------------------------------------------------------*/
    
    らしいので、
    Device Drivers  --->  ATA/ATAPI/MFM/RLL support  --->   
    │<*> ATA/ATAPI/MFM/RLL support  
    
    Device Drivers  --->  SCSI device support  --->  
    │<*> SCSI device support  
    
    File systems  --->   
    
    <*> Ext3 journalling file system support
    │[*]   Ext3 extended attributes
    │[*]     Ext3 POSIX Access Control Lists
    │[*]     Ext3 Security Labels
    │[ ] JBD (ext3) debugging support   
    
    <*> Reiserfs support   
    │[ ]   Enable reiserfs debug mode
    │[*]   Stats in /proc/fs/reiserfs
    │[*]   ReiserFS extended attributes
    │[*]     ReiserFS POSIX Access Control Lists
    │[*]     ReiserFS Security Labels   
    
    サウンドドライバはうっとおしいのではずす
    Device Drivers  ---> Sound --->
    < > Sound card support 
    
  • カーネルをmake/install
    cd /usr/src/linux2.6.17+RTAI3.4/linux-2.6.17rtai
    
    #ひたすら待つ、、
    #/*-----------------------------------------------------------------------------------*/
    #http://itpro.nikkeibp.co.jp/members/SI/oss/20031024/3/
    #カーネルをコンパイルする際も,従来必要だったmake depのステップが
    #必要なくなり,makeコマンドを実行するだけでbzImageやモジュール・
    #ドライバがコンパイルされるようになった。なお,引数を与えずにmakeを
    #実行した場合は最低限のメッセージしか表示されない静粛(quiet)モード
    #になる。従来のように実際に実行しているコマンドを表示させたい場合は
    #make V=1
    #のように,V=1オプションを与えて冗長(verbose)モードにする必要がある。
    #/*-----------------------------------------------------------------------------------*/
    
    #カーネルイメージを確認
    ls -la vmlinux
    #-rwxr-xr-x 1 root root 4626914  8月23日 19:20 vmlinux*
    #カーネルのインストール
    make install
    
    最後で/etc/lilo/installに書き込むところでこける。
    /usr/src/linux2.6.17+RTAI3.4/linux-2.6.17/arch/i386/boot/install.sh: line 54: /etc/lilo/insta ll: そのようなファイルやディレクトリはありません
    make[1]: *** [install] エラー 127
    make: *** [install] エラー 2
    
    が、無視
    確認。System.mapとvmlinuzが/bootにコピーされている。OK!
    ls -la /boot/ | grep 8月23日
    
    -rw-r--r--  1 root root  807521  8月23日 19:38 System.map
    -rw-r--r--  1 root root 1727209  8月23日 19:38 vmlinuz
    

    モジュールのインストール
    make modules_install
    
  • カーネルイメージなどの名前をわかりやすくかえる
    emacs -nw /boot/grub/menu.lst
    
    default=0
    timeout=5
    
    title Kernel 2.6.17 + RTAI
            root (hd0,0)
            kernel /vmlinuz-2.6.17rtai-0v001 ro resume2=swap:/dev/hda3 vga=0x314 acpi=off
    
    title Kernel 2.6.16 (Vine Linux 4.0 Original)
            root (hd0,0)
            kernel /vmlinuz-2.6.16-0vl68 ro root=LABEL=/1 resume2=swap:/dev/hda3 vga=0x314
            initrd /initrd-2.6.16-0vl68.img
    
    再起動
    reboot
    
  • rtaiモジュールのmake+install
    su
    cd /usr/src/linux2.6.17+RTAI3.4/rtai-3.4
    
    ln -s /usr/src/linux2.6.17+RTAI3.4/linux-2.6.17rtai /usr/src/linux 
    #リンクを貼っておかないとmake menuconfigがとおらなかった
    
    make menuconfig
    #そのままの設定で、saveして出る
    
    make    
    make install
    
    rtaiがハングアップなので異常終了した場合、rebootすると /dev/rtf*が消えてしまう場合がある。
    これに対応するために、/etc/rc.d/rc.localの最尾に 以下のスクリプトを加える (README.INSTALLより)
    emacs -nw /etc/rc.d/rc.local
    
    #### for RTAI (added by Motohara 2007/08/23)
    
    if test \! -c /dev/rtai_shm; then
            mknod -m 666 /dev/rtai_shm c 10 254
    fi
    for n in `seq 0 9`; do
            f=/dev/rtf$n
            if test \! -c $f; then
                    mknod -m 666 $f c 150 $n
            fi
    done
    #### for RTAI ends here
    

●RTAIの動作確認
  1. latencyの試験
    cd /usr/realtime/testsuite/kern/latency
    
    試験実行
    ./run
    
    *
    *
    * Type ^C to stop this application.
    *
    *
    
    ## RTAI latency calibration tool ##
    # period = 100000 (ns) 
    # avrgtime = 1 (s)
    # do not use the FPU
    # start the timer
    # timer_mode is oneshot
    
    RTAI Testsuite - KERNEL latency (all data in nanoseconds)
    RTH|    lat min|    ovl min|    lat avg|    lat max|    ovl max|   overruns
    RTD|      -1167|      -1167|       -645|       1847|       1847|          0
    RTD|      -1094|      -1167|       -652|       1825|       1847|          0
    RTD|      -1164|      -1167|       -651|       1839|       1847|          0
    RTD|      -1160|      -1167|       -651|       2019|       2019|          0
    RTD|      -1143|      -1167|       -664|       1926|       2019|          0
    RTD|      -1113|      -1167|       -653|       1877|       2019|          0
    RTD|      -1151|      -1167|       -650|       1866|       2019|          0
    RTD|      -1216|      -1216|       -649|       1931|       2019|          0
    RTD|      -1159|      -1216|       -648|       1791|       2019|          0
    RTD|      -1159|      -1216|       -668|       1843|       2019|          0
    RTD|      -1038|      -1216|       -655|       1793|       2019|          0
    RTD|      -1161|      -1216|       -651|       1773|       2019|          0
    RTD|      -1090|      -1216|       -674|       1880|       2019|          0
    RTD|       -975|      -1216|       -656|       2133|       2133|          0
    RTD|      -1155|      -1216|       -650|       1880|       2133|          0
    RTD|      -1169|      -1216|       -678|       1849|       2133|          0
    RTD|      -1163|      -1216|       -658|       1869|       2133|          0
    RTD|      -1066|      -1216|       -677|       1205|       2133|          0
    RTD|      -1203|      -1216|       -654|       1846|       2133|          0
    RTD|      -1178|      -1216|       -647|       1941|       2133|          0
    RTD|      -1163|      -1216|       -653|       1983|       2133|          0
    
    latencyは-1-2usecとかなりいい。
  2. switchesの試験
    cd /usr/realtime/testsuite/kern/switches
    
    試験実行
    ./run
    
    *
    *
    * Type ^C to stop this application.
    *
    *
    Aug 24 20:16:39 uni kernel: RTAI[hal]: <3.4> mounted over IPIPE-NOTHREADS 1.3-08.
    Aug 24 20:16:39 uni kernel: RTAI[hal]: compiled with gcc version 3.3.6 release (Vine Linux 3.3.6-0vl7).
    Aug 24 20:16:39 uni kernel: RTAI[hal]: mounted (IPIPE-NOTHREADS, IMMEDIATE (INTERNAL IRQs VECTORED), ISOL_CPUS_MASK: 0).
    Aug 24 20:16:39 uni kernel: PIPELINE layers:
    Aug 24 20:16:39 uni kernel: f8d08480 9ac15d93 RTAI 200
    Aug 24 20:16:39 uni kernel: c0398300 0 Linux 100
    Aug 24 20:16:39 uni kernel: RTAI[malloc]: vmalloced extent f8d61000, size 2097152.
    Aug 24 20:16:39 uni kernel: RTAI[malloc]: loaded (global heap size=2097152 bytes).
    Aug 24 20:16:39 uni kernel: RTAI[sched]: loaded (IMMEDIATE, MP, USER/KERNEL SPACE: ).
    Aug 24 20:16:39 uni kernel: RTAI[sched]: hard timer type/freq = APIC/12560500(Hz); default timing mode is periodic; linear ordering of timed lists.
    Aug 24 20:16:39 uni kernel: RTAI[sched]: Linux timer freq = 250 (Hz), CPU freq = 3015089000 hz.
    Aug 24 20:16:39 uni kernel: RTAI[sched]: timer setup = 999 ns, resched latency = 2943 ns.
    Aug 24 20:16:39 uni kernel: 
    Aug 24 20:16:40 uni kernel: Wait for it ...
    Aug 24 20:16:40 uni kernel: 
    Aug 24 20:16:40 uni kernel: 
    Aug 24 20:16:40 uni kernel: FOR 10 TASKS: TIME 36 (ms), SUSP/RES SWITCHES 40000, SWITCH TIME (INCLUDING FULL FP SUPPORT) 889 (ns)
    Aug 24 20:16:40 uni kernel: 
    Aug 24 20:16:40 uni kernel: FOR 10 TASKS: TIME 37 (ms), SEM SIG/WAIT SWITCHES 40000, SWITCH TIME (INCLUDING FULL FP SUPPORT) 907 (ns)
    Aug 24 20:16:40 uni kernel: 
    Aug 24 20:16:40 uni kernel: FOR 10 TASKS: TIME 49 (ms), RPC/RCV-RET SWITCHES 40000, SWITCH TIME (INCLUDING FULL FP SUPPORT) 1224 (ns)
    Aug 24 20:16:40 uni kernel: 
    
    
    1usecくらいでスイッチされているのでOK
  3. preemptの試験
    cd /usr/realtime/testsuite/kern/preempt
    
    試験実行
    ./run
    
    *
    *
    * Type ^C to stop this application.
    *
    *
    RTAI Testsuite - UP preempt (all data in nanoseconds)
    RTH|     lat min|     lat avg|     lat max|    jit fast|    jit slow
    RTD|       -1313|        -967|        1156|        5927|        4646
    RTD|       -1313|       -1001|        1325|        5927|        4646
    RTD|       -1313|       -1019|        1325|        5927|        4646
    RTD|       -1313|       -1024|        1325|        5927|        4646
    RTD|       -1313|       -1016|        1325|        5927|        4646
    RTD|       -1313|       -1015|        1325|        5927|        4646
    RTD|       -1313|       -1022|        1325|        5927|        4646
    RTD|       -1316|       -1019|        1325|        5927|        4646
    RTD|       -1316|       -1018|        1908|        5927|        4646
    RTD|       -1316|       -1024|        1908|        5927|        4646
    RTD|       -1316|       -1020|        1908|        5927|        4646
    RTD|       -1316|       -1011|        1908|        5927|        4646
    RTD|       -1316|       -1019|        1908|        5927|        4646
    RTD|       -1316|       -1019|        1908|        5927|        4646
    RTD|       -1316|       -1018|        1908|        5927|        4646
    RTD|       -1316|       -1022|        1908|        5927|        4646
    RTD|       -1316|       -1023|        1908|        5927|        4646
    RTD|       -1316|       -1019|        1908|        5927|        4646
    RTD|       -1316|       -1010|        1908|        5927|        4646
    RTD|       -1316|       -1013|        1908|        5927|        4646
    RTD|       -1316|       -1008|        1908|        5927|        4646
    
    よくわからないが、まあいいのだろう。
    rtaiのキャリブレーション(calibrateツール)
    これは、酒向メモにあるようにやってもしかたがない(キャリブレーションの結果を反映させられない)のでやらない。
●bigphysareaのインストール
  • パッチの用意
    http://www.feise.com/~jfeise/Downloads/zr36120/より kernel2.6.17用のbigphysareaパッチをdownload
    cd /usr/src/linux2.6.17+RTAI3.4/linux-2.6.17rtai
    wget http://www.feise.com/~jfeise/Downloads/zr36120/bigphysarea-2.6.17.diff
    patch -p1 < bigphysarea-2.6.17.diff
    
     patching file Documentation/bigphysarea.txt
     patching file arch/i386/Kconfig
     Hunk #1 succeeded at 612 (offset -27 lines).
     patching file include/linux/bigphysarea.h
     patching file kernel/kallsyms.c
     patching file mm/Makefile
     patching file mm/bigphysarea.c
    
  • カーネルをmake
    make menuconfig
    
    
    bigphysareaを有効に
     Processor type and features  --->
     [*] Support for big physical area reservation
    
    make
    
  • カーネルイメージを確認
    ls -la vmlinux
    
     -rwxr-xr-x 1 root root 4632074  8月24日 12:54 vmlinux*
    
    
  • カーネルのインストール
    make install
    
    確認。System.mapとvmlinuzが/bootにコピーされている。OK!
    ls -la /boot/ | grep 8月24日
    
     -rw-r--r--  1 root root  808396  8月24日 12:59 System.map
     -rw-r--r--  1 root root 1727194  8月24日 12:59 vmlinuz
    
  • モジュールのインストール
    make modules_install
    
  • カーネルイメージなどの名前をわかりやすくかえる
    mv /boot/vmlinuz    /boot/vmlinuz-2.6.17rtai-0v002
    mv /boot/System.map /boot/System.map-2.6.17rtai-0v002
    cp .config /boot/config-2.6.17rtai-0v002
    
  • GRUBを設定+reboot
    GRUBを編集
    emacs -nw /boot/grub/menu.lst
    
    default=0
    timeout=5
    
    title Kernel 2.6.17 + RTAI + bigphysarea
            root (hd0,0)
            kernel /vmlinuz-2.6.17rtai-0v002 ro resume2=swap:/dev/hda3 vga=0x314 bigphysarea=32768 acpi=off
    
    title Kernel 2.6.17 + RTAI
            root (hd0,0)
            kernel /vmlinuz-2.6.17rtai-0v001 ro resume2=swap:/dev/hda3 vga=0x314 acpi=off
    
    title Kernel 2.6.16 (Vine Linux 4.0 Original)
            root (hd0,0)
            kernel /vmlinuz-2.6.16-0vl60 ro root=LABEL=/1 resume2=swap:/dev/hda3 vga=0x314
            initrd /initrd-2.6.16-0vl60.img
    
    
    再起動
    reboot
    
  • 再起動を確認
    bigphysareaがうまく設定されているかを確認
    cat /proc/bigphysarea
    
    Big physical area, size 131072 kB
                           free list:             used list:
    number of blocks:             1                      0
    size of largest block:   131072 kB                   0 kB
    total:                   131072 kB                   0 kB
    
    OK!!!!


Trascend 32GB SSDのためのいろいろ

●/tmpをtmpfsにしてRAM上に展開

> /etc/fstab
tmpfs                   /tmp            tmpfs   defaults,size=512m      0 0
EOF
●hdparm結果
hdparm -I /dev/hde

/dev/hde:

ATA device, with non-removable media
        Model Number:       TS32GSSD25-M                            
        Serial Number:      000001B6
Standards:
        Supported: 4 
        Likely used: 6
Configuration:
        Logical         max     current
        cylinders       16383   16383
        heads           15      15
        sectors/track   63      63
        --
        CHS current addressable sectors:   15481935
        LBA    user addressable sectors:   61930575
        device size with M = 1024*1024:       30239 MBytes
        device size with M = 1000*1000:       31708 MBytes (31 GB)
Capabilities:
        LBA, IORDY(may be)(cannot be disabled)
        Queue depth: 1
        Standby timer values: spec'd by Vendor
        R/W multiple sector transfer: Max = 1   Current = 1
        Advanced power management level: unknown setting (0x0000)
        DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 *udma4 
             Cycle time: min=120ns recommended=120ns
        PIO: pio0 pio1 pio2 pio3 pio4 
             Cycle time: no flow control=120ns  IORDY flow control=120ns
Commands/features:
        Enabled Supported:
                NOP cmd
                READ BUFFER cmd
                WRITE BUFFER cmd
                Power Management feature set
           *    SMART feature set
                Advanced Power Management feature set
                CFA feature set
           *    SMART self-test 
           *    SMART error logging 
HW reset results:
        CBLID- below Vih
        Device num = 0
CFA power mode 1:
        enabled
        Maximum current = 500ma
●mount オプション
noatimeオプションを付ける
emacs -nw /etc/fstab
LABEL=/                 /                       ext3    defaults,noatime        
1 1
LABEL=/boot             /boot                   ext3    defaults,noatime        
1 2
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /dev/shm                tmpfs   defaults        0 0
LABEL=/home             /home                   ext3    defaults,noatime        
1 2
none                    /proc                   proc    defaults        0 0
none                    /sys                    sysfs   defaults        0 0
LABEL=SWAP-hde3         swap                    swap    defaults        0 0
tmpfs                   /tmp                    tmpfs   defaults,size=512m 0 0
ただし、この設定は最終readをチェックするようなソフトウェアにはまずいか?
DBソフトとかではありうる?
●hdparm設定
http://www7.ocn.ne.jp /~kikuya3/linux/hdparm.html
 hdpram -i から得た情報の中に
 MaxMultSect=16 とある、そこでMul-tiple sector mode (aka IDE Block Mode)に
 -m 16  を設定
 その他色々なオプションも有るがこのマシンには有効では無かった
    *他のPCはudma2なので-d 1 -m 16 -X 66 で設定してある、がしかし、
 まだ研究の余地が有る
とある。
man hdparm によると
       -m     Get/set sector count for multiple sector I/O on the
              drive.  A setting of 0 disables this feature.  Mul-
              tiple  sector  mode (aka IDE Block Mode), is a fea-
              ture of most modern IDE hard drives, permitting the
              transfer  of  multiple  sectors  per I/O interrupt,
              rather than the usual  one  sector  per  interrupt.
              When  this feature is enabled, it typically reduces
              operating system overhead for disk I/O  by  30-50%.
              On  many  systems,  it also provides increased data
              throughput  of  anywhere  from  5%  to  50%.   Some
              drives,   however   (most  notably  the  WD  Caviar
              series), seem to  run  slower  with  multiple  mode
              enabled.   Your mileage may vary.  Most drives sup-
              port the minimum settings of 2, 4, 8, or  16  (sec-
              tors).   Larger  settings  may  also  be  possible,
              depending on the drive.  A  setting  of  16  or  32
              seems  optimal  on  many  systems.  Western Digital
              recommends lower settings of 4  to  8  on  many  of
              their  drives,  due  tiny  (32kB) drive buffers and
              non-optimized buffering algorithms.   
なのだが、今回のディスクについては
  MaxMultSect=1
なので、意味はないかなー。一応設定しておく。
hdparm -d 1 -m 1 /dev/hde

で、転送速度チェック。
hdparm -t /dev/hde
/dev/hde:
 Timing buffered disk reads:   72 MB in  3.05 seconds =  23.64 MB/sec
結果は変わらず。

●syslogd
当面は特にいじらないことにする