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

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

●ハードウェア構成は

  • Intel Pentium4 3GHz
  • 2GBメモリ
  • Transcend 32GB SSD TS32GSSD25-M はカタログ値でも書き込みが 5MB/s, 実測では1MB/sくらいになってしまうので、
    MTRON 32GB SSD (SATA) SD-S35032GA01 を入れる。公称 sequential write 80MB/sだがどうなるか?
●まずVine linux 4.1をデスクトップパッケージでデフォルトのままでインストール
  • BIOS設定変更
    このPCは以前はIDE-PCIカード経由でIDEブートになっていて、 SATAのディスクを認識しなかった。
    BIOSの設定が変更されていて、SATAがOFFになっていたので、 工場出荷時設定に戻す。
  • パーティション分割は
    ファイルシステム     1K-ブロック  使用        空き 使用% マウント位置
    /dev/sda2             10080520   1733704   7834748  19% /
    /dev/sda1               101086      9108     86759  10% /boot
    /dev/sda5             20770196    176632  19538500   1% /home
    none                   1029264         0   1029264   0% /dev/shm
    
  • grubの強制インストール
    再起動すると、なぜか起動ディスクがない、とおこられる。なぜかgrubがちゃんと 入っていないみたい。
    試行錯誤のすえ、CD-ROM から linux rescue で起動して、
    chroot /mnt/sysimage
    grub-install --root-directory=/ /dev/sda
    
    とすればちゃんと動いた!
●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.20+RTAI3.5/
    cd linux2.6.20+RTAI3.5/
    
  • RTAIソースをダウンロード
    mkdir download
    cd download
    wget https://www.rtai.org/RTAI/rtai-3.5-cv.tar.bz2
    
    #https://www.rtai.org/より、最新のRTAI (rtai-3.5-cv)をダウンロード
  • RTAIソースを解凍
    cd /usr/src/linux2.6.20+RTAI3.5
    tar jxfv download/rtai-3.5-cv.tar.bz2
    ls rtai-3.5-cv/base/arch/i386/patches/
    
    README                              hal-linux-2.6.16-i386-1.3-08.patch
    hal-linux-2.4.32-i386-1.2-07.patch  hal-linux-2.6.17-i386-1.5-02.patch
    hal-linux-2.4.33-i386-1.3-03.patch  hal-linux-2.6.19-i386-1.7-01.patch
    hal-linux-2.4.34-i386-1.3-03.patch  hal-linux-2.6.20-i386-1.7-01.patch
    hal-linux-2.6.15-i386-1.3-07.patch  hal-linux-2.6.20-i386-1.8-04.patch
    
    より、linux-2.6.20カーネルにパッチをあてることにしましょう。
  • 本家カーネルソースをダウンロード
    cd /usr/src/linux2.6.20+RTAI3.5/linux-2.6.20rtai
    patch -p1 -b < /usr/src/linux2.6.20+RTAI3.5/rtai-3.5-cv/base/arch/i386/patches/hal-linux-2.6.20-i386-1.8-04.patch
    
    ※今回はbigphysareaパッチをあてない
  • カーネルのconfigファイルをつくる
    cd /usr/src/linux2.6.20+RTAI3.5/linux-2.6.20rtai
    #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] このoptionがみあたらない、、設定せず
    "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
        < >     PCMCIA IDE support
    Device Drivers  --->  SCSI device support  --->  
        <*> SCSI device support  
        <*> SCSI disk 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  --->  Serial ATA (prod) and Parallel ATA (experimental) drivers  --->      
         ATA device support  
           Intel PIIX/ICH SATA support 
    Moduleにすること。そうしないと起動時におこられる
    
    サウンドドライバはうっとおしいのではずす
    Device Drivers  ---> Sound --->
        < > Sound card support 
    
    Processor type and features  ---> Processor family (Pentium-4/Celeron(P4-based)/Pentium-4 M/old
                                      < > Toshiba Laptop support
                                      < > Dell laptop support
    
  • カーネルをmake/install
    cd /usr/src/linux2.6.20+RTAI3.5/linux-2.6.20rtai
    make
    
    #ひたすら待つ、、
    #/*-----------------------------------------------------------------------------------*/
    #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 5038373  9月12日 15:51 vmlinux*
    #カーネルのインストール
    make install
    
    最後で/etc/lilo/installに書き込むところでこける。
    sh /usr/src/linux2.6.20+RTAI3.5/linux-2.6.20rtai/arch/i386/boot/install.sh 2.6.20 arch/i386/boot/bzImage System.map "/boot"
    /usr/src/linux2.6.20+RTAI3.5/linux-2.6.20rtai/arch/i386/boot/install.sh: line 54: /etc/lilo/install: そのようなファイルやディレクトリはありません
    make[1]: *** [install] エラー 127
    make: *** [install] エラー 2
    
    が、無視
    確認。System.mapとvmlinuzが/bootにコピーされている。OK!
    ls -la /boot/ | grep 9月12日
    
    -rw-r--r--  1 root root  905674  9月12日 16:10 System.map
    -rw-r--r--  1 root root 1835112  9月12日 16:10 vmlinuz
    

    モジュールのインストール
    make modules_install
    
  • initrdファイルの作成
    /sbin/mkinitrd initrd-2.6.20rtai-0v001.img  2.6.20
    mv ./initrd-2.6.20rtai-0v001.img /boot/
    
  • カーネルイメージなどの名前をわかりやすくかえる
    rm -f /boot/vmlinuz.old
    rm -f /boot/System.old
    rm -f /boot/System.map.old
    rm -f /boot/initrd.img
    rm -f /boot/initrd.old.img
    mv /boot/vmlinuz    /boot/vmlinuz-2.6.20rtai-0v001
    mv /boot/System.map /boot/System.map-2.6.20rtai-0v001
    cp .config /boot/config-2.6.20rtai-0v001
    
  • GRUBを設定+reboot
    GRUBを編集
    emacs -nw /boot/grub/menu.lst
    
    default=0
    timeout=5
    
    title Kernel 2.6.20 + RTAI
            root (hd0,0)
            kernel /vmlinuz-2.6.20rtai-0v001 ro resume2=swap:/dev/hda3 vga=0x314 acpi=off
            initrd /initrd-2.6.20rtai-0v001.img
    
    title Kernel 2.6.16 (Vine Linux 4.1 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.20+RTAI3.5/rtai-3.5-cv
    
    ln -s /usr/src/linux2.6.20+RTAI3.5/linux-2.6.20rtai /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/09/13)
    
    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
    

●bigphysareaのインストール
  • パッチの用意
    http://www.feise.com/~jfeise/Downloads/zr36120/より kernel2.6.20用のbigphysareaパッチをdownload
    cd /usr/src/linux2.6.20+RTAI3.5/linux-2.6.20rtai
    wget http://www.feise.com/~jfeise/Downloads/zr36120/bigphysarea-2.6.20.diff
    patch -p1 < bigphysarea-2.6.20.diff
    
    Hunk #1 succeeded at 663 (offset 2 lines).
    patching file include/linux/bigphysarea.h
    patching file kernel/kallsyms.c
    patching file mm/Makefile
    patching file mm/bigphysarea.c
    patching file Documentation/bigphysarea.txt
    
  • カーネルをmake
    make menuconfig
    
    bigphysareaを有効に
    Processor type and features  --->
        [*] Support for big physical area reservation
    
    そのほかの設定もちょっといじっていらないものを捨てる。
    Processor type and features  --->
        < > Toshiba Laptop support
        < > Dell laptop support
    Power management options (ACPI, APM)  --->
        [ ]   Software Suspend 
        APM (Advanced Power Management) BIOS Support  --->
            < > APM (Advanced Power Management) BIOS support
    Networking  --->
        < >   IrDA (infrared) subsystem support  --->
        < >   Bluetooth subsystem support  --->
    Device Drivers  ---> ISDN subsystem  --->
        < > ISDN support
        Multi-device support (RAID and LVM)  --->
            [ ] Multiple devices driver support (RAID and LVM)
        Input device support  --->
            < >   Joystick interface
            [ ]   Joysticks  --->
            [ ]   Touchscreens  --->
    Bus options (PCI, PCMCIA, EISA, MCA, ISA)  --->
        [ ] ISA support
        PCCARD (PCMCIA/CardBus) support  --->
            < > PCCard (PCMCIA/CardBus) support 
    
    make
    
  • カーネルイメージを確認
    ls -la vmlinux
    
    -rwxr-xr-x 1 root root 4896587  9月13日 15:18 vmlinux*
    
  • カーネルのインストール
    make install
    
    確認。System.mapとvmlinuzが/bootにコピーされている。OK!
    ls -la /boot/ | grep 9月13日
    
    -rw-r--r--  1 root root  886918  9月13日 17:27 System.map
    -rw-r--r--  1 root root 1784520  9月13日 17:27 vmlinuz
    
  • モジュールのインストール
    make modules_install
    
  • initrd の作成
    /sbin/mkinitrd initrd-2.6.20rtai-0v002.img  2.6.20
    mv ./initrd-2.6.20rtai-0v002.img /boot/
    
  • カーネルイメージなどの名前をわかりやすくかえる
    mv /boot/vmlinuz    /boot/vmlinuz-2.6.20rtai-0v002
    mv /boot/System.map /boot/System.map-2.6.20rtai-0v002
    cp .config /boot/config-2.6.20rtai-0v002
    
  • GRUBを設定+reboot
    GRUBを編集
    emacs -nw /boot/grub/menu.lst
    
    default=0
    timeout=5
    
    title Kernel 2.6.20 + RTAI + bigphysarea
            root (hd0,0)
            kernel /vmlinuz-2.6.20rtai-0v002 ro root=LABEL=/ vga=0x314 acpi=off bigphysarea=36000
            initrd /initrd-2.6.20rtai-0v002.img
    
    title Kernel 2.6.20 + RTAI
            root (hd0,0)
            kernel /vmlinuz-2.6.20rtai-0v001 ro root=LABEL=/ vga=0x314 acpi=off
            initrd /initrd-2.6.20rtai-0v001.img
    
    title Kernel 2.6.16 (Vine Linux 4.1 Original)
            root (hd0,0)
            kernel /vmlinuz-2.6.16-0vl68 ro root=LABEL=/ resume2=swap:/dev/hda3 vga=0x314
            initrd /initrd-2.6.16-0vl68.img
    
    再起動
    reboot
    
  • 再起動を確認
    bigphysareaがうまく設定されているかを確認
    cat /proc/bigphysarea
    
    Big physical area, size 144000 kB
                           free list:             used list:
    number of blocks:             1                      0
    size of largest block:   144000 kB                   0 kB
    total:                   144000 kB                   0 kB
    
    OK!!!!


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

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

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

/dev/sda:

ATA device, with non-removable media
        Model Number:       MTRON MSD-SATA6035                      
        Serial Number:      2007250000715
        Firmware Revision:  0.15    
Standards:
        Supported: 7 6 5 4 
        Likely used: 7
Configuration:
        Logical         max     current
        cylinders       16383   0
        heads           16      0
        sectors/track   63      0
        --
        LBA    user addressable sectors:   65011712
        device size with M = 1024*1024:       31744 MBytes
        device size with M = 1000*1000:       33285 MBytes (33 GB)
Capabilities:
        LBA, IORDY(cannot be disabled)
        Queue depth: 1
        Standby timer values: spec'd by Vendor, no device specific minimum
        R/W multiple sector transfer: Max = 1   Current = 1
        DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 *udma5 udma6 
             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:
           *    Write cache
           *    Power Management feature set
           *    Mandatory FLUSH CACHE command 
HW reset results:
        CBLID- above Vih
        Device num = 1
Checksum: correct
●mount オプション
noatimeオプションを付ける
emacs -nw /etc/fstab
LABEL=/                 /                       ext3    defaults,noatime        1 1
LABEL=/boot             /boot                   ext3    defaults,noatime        1 2
LABEL=/home             /home                   ext3    defaults,noatime        1 2
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /dev/shm                tmpfs   defaults        0 0
none                    /proc                   proc    defaults        0 0
none                    /sys                    sysfs   defaults        0 0
/dev/sda3               swap                    swap    defaults        0 0
tmpfs                   /tmp            tmpfs   defaults,size=512m      0 0

●転送速度チェック。
hdparm -t /dev/sda

/dev/sda:
 Timing buffered disk reads:  212 MB in  3.01 seconds =  70.43 MB/sec
速い!
●syslogd
当面は特にいじらないことにする