このページは「24環境」の情報です

第1回 Debian SH sid をインストールしてみよう

海老原祐太郎
2002/8/17
2003/9/12 CAT709関連追記

八重樫さんが Debian sid のベースアーカイブを用意してくださいました。
早速この sid ベースアーカイブを使ってみます。なんと apt が使えるようになっています。
あらかじめカーネル(zImage)とliloブートローダ(/boot/boot.b)は別途コンパイルしておいてください。
(難易度 ☆)

2003/9/9 追記
CAT709ではオンボードFLASHにカーネルを保存しブートすることができますので、
lilo不要にすることもできます。lilo関連は読み飛ばしてください。

ダウンロード

まずは http://debian.dodes.org を読んでください。
開発機に http://debian.dodes.org/debian/base/base-sh3-020721.tar.gz をダウンロードしておきます。

コンパクトフラッシュのフォーマット

開発機でコンパクトフラッシュにパーテーションを切り、フォーマットします。
以下の例ではコンパクトフラッシュが /dev/hde として説明しています。

~# cfdisk /dev/hde       (パーテーションを切る)
~# mke2fs /dev/hde1      (ext2fsでフォーマット)
~# mount /dev/hde1 /mnt  (マウント)

アーカイブの展開

ダウンロードしておいた base-sh3-020721.tar.gz をコンパクトフラッシュに展開します。

/# cd /mnt
/mnt# tar xzf /ダウンロードした場所/base-sh3-020721.tar.gz
/mnt# ls
bin   cdrom  etc     home    lib  opt   root  tmp  var
boot  dev    floppy  initrd  mnt  proc  sbin  usr

設定ファイルを書く

ベースアーカイブには /etc 以下の設定ファイルがあまりありません。
最低限以下の設定は必須と思われます。

ホスト名

# echo "supercat" > /mnt/etc/hostname

/mnt/etc/lilo.conf-cross (クロスlilo用の設定ファイル)

linear
boot=/dev/hde  (開発機から見たコンパクトフラッシュ)
disk=/dev/hde  (開発機から見たコンパクトフラッシュ)
bios=0x80
install=/boot/boot.b.2107  (ブートローダ version 21.7用)
image=/boot/vmlinuz
label=linux
root=/dev/hda1             (CAT68701から見たroot / パーテーション)
read-only
append="console=ttySC0,115200 mem=32M"

/mnt/etc/fstab

# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/hda1       /       ext2    defaults,errors=remount-ro      0 1
proc            /proc   proc    defaults                        0 0

/mnt/etc/network/interfaces

# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
# The loopback interface
# automatically added when upgrading
auto lo
iface lo inet loopback

# automatically added when upgrading
auto eth0
iface eth0 inet static
address 192.168.7.112    (IPアドレス)
netmask 255.255.255.0    (ネットマスク)
gateway 192.168.7.1      (デフォルトゲートウェイ)
#iface eth0 inet dhcp

/mnt/etc/hosts

127.0.0.1      localhost
192.168.7.112  supercat  (自ホスト)

/mnt/etc/inittab (抜粋)

#1:2345:respawn:/sbin/getty 38400 tty1
1:2345:respawn:/sbin/getty 115200 ttySC0
#2:23:respawn:/sbin/getty 38400 tty2
#3:23:respawn:/sbin/getty 38400 tty3
#4:23:respawn:/sbin/getty 38400 tty4
#5:23:respawn:/sbin/getty 38400 tty5
#6:23:respawn:/sbin/getty 38400 tty6

/mnt/etc/securetty (セキュアtty = rootでのログインを許す端末)

# /etc/securetty: list of terminals on which root is allowed to login.
# See securetty(5) and login(1).
console
ttySC0

/mnt/etc/resolv.conf

search si-linux.co.jp   (自ドメイン名)
nameserver 192.168.7.1  (ネームサーバ)

カーネルとブートローダを仕込む

あらかじめコンパイルしておいたカーネル (zImage) と ブートローダ(boot.b) をコピーし、クロスliloでブートローダを書き込みます。
(章頭に書きましたがCAT709ではliloを使わない方法でブートできますのでこの節は不要です)

# cp /どこか/linux-2.4.19/arch/sh/boot/zImage /mnt/boot/vmlinuz
# cp /どこか/boot.b /mnt/boot/boot.b.2107
# lilo -r /mnt -C /etc/lilo.conf-cross
Added linux *
# umount /mnt

Added linux * が表示されればOKです。アンマウントして取り外してください。

lilo -r で rootを /mnt に変更しています。
lilo -C /etc/lilo.conf-crossは実際には /mnt/etc/lilo.conf-crossになります。
"/dev/hde No such file" 等のエラーが出たら /dev/hde ではなく /mnt/dev/hdeを確 認してください。

CAT709のオンボードFLASHからカーネル起動の場合

カーネルパラメータを書き換えて root ファイルシステムが /dev/hda1 となればokです。
root=0301 ... メジャー番号0x03, マイナー番号 0x01 /dev/hda1 の意味です。
ide0=... IDE0が接続されている物理アドレスとIRQ番号

SH IPL+g version 0.11, Copyright (C) 2001 Free Software Foundation, Inc.
? --- Show this message (HELP)
b --- Boot the system
g --- Invoke GDB stub
l --- Show about license
w --- Show about (no)warranty
k --- download kernel
r --- download rootfs
c --- setup kernel cmdline
m --- setup mac address
s --- start linux
>c
console=ttySC0,115200 root=0301 ide0=0xba0001f0,0xba0003f6,34
>s

CAT68701 の起動

それではコンパクトフラッシュを装着し CAT68701 を起動してみます。
CAT68701のシリアルコンソールに以下のメッセージが出力されるはずです。

IPL+g version 0.11, Copyright (C) 2001 Free Software Foundation, Inc.

This software comes with ABSOLUTELY NO WARRANTY; for details type `w'.
This is free software, and you are welcome to redistribute it under
certain conditions; type `l' for details.

> b
Disk drive detected: IBM-DMDM-10340 MD2IC601 XHAV5679
Set Transfer Mode result: 50
Initialize Device Parameters result: 50
IDLE result: 50
LILO boot: first-image
Loading linux.................done.
Uncompressing Linux... Ok, booting the kernel.
Linux version 2.4.19 (ebihara@boss) (gcc version 3.0.3) #11 2002年 8月 16日 金 曜日 23:50:05 JST
setup_cat68701()
IDE_RESET_TIMEOUT
On node 0 totalpages: 8192
zone(0): 8192 pages.
zone(1): 0 pages.
zone(2): 0 pages.
Kernel command line: ro root=301 console=ttySC0,115200 mem=32M
Setting GDB trap vector to 0x80000100
CPU clock: 98.31MHz
Bus clock: 49.15MHz
Module clock: 32.77MHz
Interval = 81930
Linux version 2.4.19 (ebihara@boss) (gcc version 3.0.3) #11 2002年 8月 16日 金 曜日 23:50:05 JST 
Linux version 2.4.19 (ebihara@boss) (gcc version 3.0.3) #11 2002年 8月 16日 金曜日 23:50:05 JST 
setup_cat68701()
setup_cat68701()
IDE_RESET_TIMEOUT
IDE_RESET_TIMEOUT
On node 0 totalpages: 8192
On node 0 totalpages: 8192
zone(0): 8192 pages.
zone(0): 8192 pages.
zone(1): 0 pages.
zone(1): 0 pages.
zone(2): 0 pages.
zone(2): 0 pages.
Kernel command line: ro root=301 console=ttySC0,115200 mem=32M
Kernel command line: ro root=301 console=ttySC0,115200 mem=32M
Setting GDB trap vector to 0x80000100
Setting GDB trap vector to 0x80000100
CPU clock: 98.31MHz
CPU clock: 98.31MHz
Bus clock: 49.15MHz
Bus clock: 49.15MHz
Module clock: 32.77MHz
Module clock: 32.77MHz
Interval = 81930
Interval = 81930
Calibrating delay loop... 65.33 BogoMIPS
Memory: 30744k/32768k available (1388k kernel code, 2024k reserved, 43k data,  48k init)
Dentry cache hash table entries: 4096 (order: 3, 32768 bytes)
Inode cache hash table entries: 2048 (order: 2, 16384 bytes)
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer-cache hash table entries: 1024 (order: 0, 4096 bytes)
Page-cache hash table entries: 8192 (order: 3, 32768 bytes)
CPU: SH7707/SH7708/SH7709
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Journalled Block Device driver loaded
pty: 256 Unix98 ptys configured
SuperH SCI(F) driver initialized
ttySC0 at 0xfffffe80 is a SCI
Real Time Clock Driver v1.10e
Uniform Multi-Platform E-IDE driver Revision: 6.31
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
hda: IBM-DMDM-10340, ATA DISK drive
ide0 at 0x1f0-0x1f7,0x3f6 on irq 13
hda: 700560 sectors (359 MB) w/96KiB Cache, CHS=695/16/63
Partition check:
hda: hda1 hda2
cs89x0:cs89x0_probe(0x0)
PP_addr=0x3000
cs89x0.c: v2.4.3-pre1 Russell Nelson <nelson@crynwr.com>, Andrew Morton  <andrewm@uow.edu.au>
eth0: cs8900 rev J found at 0x300 [Cirrus EEPROM]
cs89x0 media RJ-45, IRQ 7, programmed I/O, MAC 00:03:82:01:00:54
cs89x0_probe1() successful
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
PPP generic driver version 2.4.2
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 2048 bind 4096)
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
hda: hda1 hda2
hda: hda1 hda2
hda: hda1 hda2
hda: hda1 hda2
VFS: Mounted root (ext2 filesystem) readonly.
Freeing unused kernel memory: 48k freed
INIT: version 2.84 booting
Activating swap.
Checking root file system...
fsck 1.27 (8-Mar-2002)
/dev/hda1: clean, 7794/85680 files, 65457/341680 blocks
System time was Sat Aug 17 09:02:09 UTC 2002.
Setting the System Clock using the Hardware Clock as reference...
System Clock set. System local time is now Sat Aug 17 09:02:11 UTC 2002.
Calculating module dependencies... depmod: Can't open /lib/modules/2.4.19/modules.dep for writing
done.
Loading modules:
modprobe: Can't open dependencies file /lib/modules/2.4.19/modules.dep (No suchfile or directory)
Checking all file systems...
fsck 1.27 (8-Mar-2002)
Setting kernel variables.
Mounting local filesystems...
nothing was mounted
Running 0dns-down to make sure resolv.conf is ok...done.
Setting up IP spoofing protection: rp_filter.
Configuring network interfaces: eth0: 10Base-T (RJ-45) has no cable
eth0: no network cable attached to configured media
SIOCSIFFLAGS: Resource temporarily unavailable
eth0: 10Base-T (RJ-45) has no cable
eth0: no network cable attached to configured media
SIOCSIFFLAGS: Resource temporarily unavailable
done.

Setting the System Clock using the Hardware Clock as reference...
System Clock set. Local time: Sat Aug 17 09:02:19 UTC 2002

Cleaning: /tmp /var/lock /var/run.
Initializing random number generator... done.
Recovering nvi editor sessions... done.
INIT: Entering runlevel: 2
Starting system log daemon: syslogd.
Starting kernel log daemon: klogd.
Starting internet superserver: inetd.
Starting PCMCIA services: modprobe: Can't open dependencies file /lib/modules/2.4.19/modules.dep (No such file or directory)
modprobe: Can't open dependencies file /lib/modules/2.4.19/modules.dep (No suchfile or directory)
cardmgr[163]: cannot access /lib/modules/2.4.19: No such file or directory
cardmgr[163]: no pcmcia driver in /proc/devices
done.
Starting deferred execution scheduler: atd.
Starting periodic command scheduler: cron.

Debian GNU/Linux testing/unstable supercat ttySC0

supercat login: root
Linux supercat 2.4.19 #11 2002年 8月 16日 金曜日 23:50:05 JST sh3 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.
supercat:~#

rootのパスワードの設定

supercat:~# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

一般ユーザーの追加

supercat:~# adduser ebihara
Adding user ebihara...
Adding new group ebihara (1000).
Adding new user ebihara (1000) with group ebihara.
Creating home directory /home/ebihara.
Copying files from /etc/skel
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for ebihara
Enter the new value, or press return for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [y/n] y

タイムゾーンの設定

supercat:~# tzconfig
Your current time zone is set to
Do you want to change that? [n]: y 

Please enter the number of the geographic area in which you live:


1) Africa 7) Australia

2) America 8) Europe

3) US time zones 9) Indian Ocean

4) Canada time zones 10) Pacific Ocean

5) Asia 11) Use System V style time zones

6) Atlantic Ocean 12) None of the above


Then you will be shown a list of cities which represent the time zone
in which they are located. You should choose a city in your time zone.

Number: 5

Aden Almaty Amman Anadyr Aqtau Aqtobe Ashgabat Ashkhabad Baghdad Bahrain
Baku Bangkok Beirut Bishkek Brunei Calcutta Choibalsan Chongqing Chungking
Colombo Dacca Damascus Dhaka Dili Dubai Dushanbe Gaza Harbin Hong_Kong
Hovd Irkutsk Istanbul Jakarta Jayapura Jerusalem Kabul Kamchatka Karachi
Kashgar Katmandu Krasnoyarsk Kuala_Lumpur Kuching Kuwait Macao Magadan
Manila Muscat  Nicosia Novosibirsk Omsk Phnom_Penh Pontianak Pyongyang
Qatar Rangoon Riyadh Riyadh87 Riyadh88 Riyadh89 Saigon Sakhalin Samarkand
Seoul Shanghai Singapore Taipei Tashkent Tbilisi Tehran Tel_Aviv Thimbu
Thimphu Tokyo Ujung_Pandang Ulaanbaatar Ulan_Bator Urumqi Vientiane
Vladivostok Yakutsk Yekaterinburg Yerevan

Please enter the name of one of these cities or zones
You just need to type enough letters to resolve ambiguities
Press Enter to view all of them again
Name: [] Tokyo
Your default time zone is set to 'Asia/Tokyo'.
Local time is now: Sat Aug 17 18:07:02 JST 2002.
Universal Time is now: Sat Aug 17 09:07:02 UTC 2002.

UTCではなくJSTを使うようにする設定 (/etc/default/rcS)

# Set UTC=yes if your system clock is set to UTC (GMT), and UTC=no if not.
UTC=no

時計の設定

supercat:~# date --set "2002/8/17 9:10:0"
Sat Aug 17 09:10:00 JST 2002
supercat:~# hwclock --systohc

何は無くても apt-lineだけは設定しておきましょう。(/etc/apt/sources.list)

deb http://debian.dodes.org/debian sid main non-free contrib
deb-src http://ftp.jp.debian.org/debian/ sid main non-free contrib
deb-src http://non-us.debian.org/debian-non-US sid/non-US main contrib non-free

これでaptを使ってバリバリとインストールできるようになります。
詳しくは第2回 debianパッケージのインストールとビルドを参照してください。

どのくらい容量が必要なの?

~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda1 323M 60M 247M 20% /

340MのMicroDriveを使っていますが、インストールした時点で 60M容量を食っています。
64MのCFだと厳しいですね。

Last-modified: 2006-01-19 (木) 16:36:33 (6664d)