玄箱の Debian 化
訓練用に Debian 3.0 (woody) をログインできるところまで構築してみる。
作業環境
- 玄箱(初代/HG)
- ハードウェアの改造
- シリアル コンソール使用可
- U-Boot 化済み
- ハードウェアの改造
玄箱の初期化
- EM モードで起動
- HDD の初期化
- KuroBoxSetup.exe / KuroBoxUpdate.exe
- python スクリプト
- 通常モードで起動
EM モードにする方法
- 一旦 HDD を外す
- 初期化スイッチ
echo -n "NGNG" > dev/fl3
- U-Boot プロンプトで
run writeng
など
アプリのインストール
KURO-BOX login: root
Password: (kuro/kuroadmin)
以下、パスワードの変更やログイン操作は省略します。
■ 付属 CD にある開発環境をインストール
セットアップ ディスクの binray ディレクトリを玄箱にコピーした後
# cd "binrayのパス"
# for f in *.tar.gz; do echo; echo $f; tar -C / -zxvf $f; done
以下、ビルド用の適当な作業ディレクトリを用意
■ GNU wget-1.5.3 (https://ftp.gnu.org/pub/gnu/wget/) をインストール
ソースコードは別 OS でダウンロードして持ってくる。
# tar zxvf wget-1.5.3.tar.gz
# cd wget-1.5.3
# ./configure
# make
# make install
この wget は https 非対応です
■ GNU coreutils-5.2.1 をインストール
# wget http://ftp.gnu.org/pub/gnu/coreutils/coreutils-5.2.1.tar.bz2
# tar jxvf coreutils-5.2.1.tar.bz2
# cd coreutils-5.2.1
# ./configure
# make
# make install
■ GNU gzip-1.2.4 をインストール
# wget http://ftp.gnu.org/pub/gnu/gzip/gzip-1.2.4.tar.gz
# tar zxvf gzip-1.2.4.tar.gz
# cd gzip-1.2.4
# ./configure
# make
# make install
Debian 3.0 (woody) の構築
# cd /mnt
# wget http://archive.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.67_all.deb
# ar vx debootstrap_1.0.67_all.deb data.tar.gz
# tar -C / -zxvf data.tar.gz
# mkdir debian-root
# /usr/sbin/debootstrap --arch powerpc \
--include=less,ntpdate,pmac-fdisk,ssh,sudo,timezoneconf,xinetd \
--exclude=amiga-fdisk,mac-fdisk,openbsd-inetd,pcmcia-cs,yaboot \
woody debian-root http://archive.debian.org/debian
# cd debian-root
/mnt/debian-root
以下を修正する。
ログイン可能なところまで
デバイス ファイル / カーネル モジュールの用意
カーネルはそのままなので幾つかそのまま使う。
# tar -C /lib/modules -cf - `uname -r` | tar -C /mnt/debian-root/lib/modules -xvf -
# tar -C / -cf - dev | tar -C /mnt/debian-root -xvf -
# tar -C /etc -cf - fstab inittab securetty modules modules.conf | tar -C /mnt/debian-root/etc -xvf -
etc/inittab
設定(シリアル コンソールでのログイン)
-con:2345:respawn:/sbin/getty console
+T0:2345:respawn:/sbin/getty -L ttyS0 57600 vt100
ttyS1
関係の設定
# tar -C / -cf - usr/sbin/ppc_uartd | tar -C /mnt/debian-root -xvf -
# tar -C /etc -cf - init.d/ppc_uartd | tar -C /mnt/debian-root/etc -xvf -
# (cd /mnt/debian-root;\
(cd etc/rc0.d; ln -s ../init.d/ppc_uartd K95ppc_uartd);\
(cd etc/rc2.d; ln -s ../init.d/ppc_uartd S95ppc_uartd);\
(cd etc/rc6.d; ln -s ../init.d/ppc_uartd K95ppc_uartd);)
etc/init.d
下のhalt,reboot
を修正
shutdown
コマンドでの電源切断対応
+echo -n "EEEE" > /dev/ttyS1
halt -d -f -i -p $hddown
reboot
コマンドで再起動対応
echo -n "Rebooting... "
+echo -n "CCCC" > /dev/ttyS1
reboot -d -f -i
ネットワーク設定
ネットワーク環境に応じて修正が必要です。
KURO-BOX
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
動作テスト
とりあえず動かしてみる。
ルート パーティションを debian(woody) にする
# echo -n "NGNG" > /dev/fl3
# sync; reboot
# mke2fs -j /dev/hda1
# mount /dev/hda1 /mnt
# mount /dev/hda3 /mnt2
# tar -C /mnt2/debian-root -cf - . | tar -C /mnt -xvf -
# echo -n "OKOK" > /dev/fl3
# sync; reboot
Debian GNU/Linux 3.0 (none) ttyS0
(none) login:
電源ボタンに反応しないなど問題があるが、Debian 3.0 として起動したので、apt-get
などが利用可。あとは好きにカスタマイズする。
セキュリティ関係は適切なものに変更してください
Debian 3.1 (sarge) でもほぼ同様
Debian 4.0/5.0/6.0 (etch/lenny/squeeze) ではカーネル 2.6 を使用
- sarge のカーネルを 2.6 にしてから構築作業する
- HDD のデバイス名が hda から sda になる
- 作業領域(パーティションの取り回し)に注意する
-
etc/init.d
下のhalt, reboot
のttyS1
出力(パッチ)は不要-
ppc_uartd
も不使用
-
-
debootstrap
の--include
にudev
を追加
Debian 7.x (wheezy) ではカーネル 3.2 を使用
- Debian 4/5/6 に加えて
-
root
ではログインできないのでetc/shadow
のパスワードを変更- ユーザーを追加したら
/etc/shadow
を戻す
- ユーザーを追加したら
-
Debian 8.x (jessie) ではカーネル 3.19 を使用
- Debian 7 に加えて
-
debootstrap
では--include
にsystemd
を追加
-
カーネルはこちらの方法でビルド