一、安裝 Debian
當把硬碟裝上 Kuro-Box 開啟電源後預設會進入 EM Mode。若你的網路環境有 DHCP, 那麼 Kuro-Box 在開機後會由 DHCP 取得IP;若沒有, 則 Kuro-Box 會自己將 IP 設為 192.168.11.150。若 Kuro-Box 沒有進入 EM Mode, 或是想要重新安裝, 在開機後請按機器後面的 reset 鈕 3 秒以上。這時會自動關機, 重新按電源鈕啟動機器後, 它就會進入 EM Mode。
- 連線到 Kuro-Box:
 請自行由 DHCP 伺服器查詢 Kuro-Box 所取得的 IP, 然後 telnet到該 IP。若無 DHCP, 則是 telnet 到 192.168.11.150:
 telnet 192.168.11.150
 Kuroutoshikou KURO-BOX/HG (IESHIGE)
 Linux/ppc 2.4.17_mvl21
 KURO-BOX-EM login: root ← 登入帳號
 由主機名稱得知目前的狀態為 EM Mode。若你有 DHCP 伺服器, 可由 DHCP 上的主機名稱得知 Kuro-Box 是否處於 EM Mode,若不是在 EM Mode 下, 主機名稱將為 KURO-BOX
 Password:kuroadmin ← 密碼
 BusyBox v0.60.5 (2003.07.30-12:03+0000) Built-in shell (ash)
 Enter 'help' for a list of built-in commands.
 # ← 成功登入
- 刪除原硬碟分割區並建立新的分割區:
 # mfdisk -c /dev/hda
 Command (m for help): p ← 列出目前的分割區
 Disk /dev/hda: 255 heads, 63 sectors, 525 cylinders
 Units = cylinders of 16065 * 512 bytes
 Device Boot Start End Blocks Id System
 /dev/hda1 1 525 4000153+ 83 Linux ← 目前的分割區
 Command (m for help): d ← 按 d 刪除
 Partition number (1-4): 1 ← 刪除第 1 個分割區
 Command (m for help): p ← 列出分割區
 Disk /dev/hda: 255 heads, 63 sectors, 525 cylinders
 Units = cylinders of 16065 * 512 bytes
 Device Boot Start End Blocks Id System
 ← 已經沒有任何分割區
 Command (m for help): n ← 建立新分割區
 Command action
 e extended
 p primary partition (1-4)
 p ← 使用主分割區
 Partition number (1-4): 1 ← 建立第 1 個主分割區
 First cylinder (1-525, default 1): ← 按 [Enter] 鍵使用預設
 Using default value 1
 Last cylinder or +size or +sizeM or +sizeK (1-525, default 525): +3900M ← 設定為 3.9G
 Command (m for help): n ← 建立新分割
 Command action
 e extended
 p primary partition (1-4)
 p ← 使用主分割區
 Partition number (1-4): 2 ← 建立第 2 個主分割區
 First cylinder (499-525, default 499): ← 按 [Enter] 鍵使用預設
 Using default value 499
 Last cylinder or +size or +sizeM or +sizeK (499-525, default 525): ← 按 [Enter] 鍵使用預設
 Using default value 525
 Command (m for help): p ← 列出分割區
 Disk /dev/hda: 255 heads, 63 sectors, 525 cylinders
 Units = cylinders of 16065 * 512 bytes
 Device Boot Start End Blocks Id System
 /dev/hda1 1 498 4000153+ 83 Linux
 /dev/hda2 499 525 216877+ 83 Linux
 Command (m for help): t ← 改變分割區檔案系統
 Partition number (1-4): 2 ← 改變第 2 個分割區
 Hex code (type L to list codes): 82 ← 將檔案系統改為 swap
 Changed system type of partition 2 to 82 (Linux swap)
 Command (m for help): w ← 寫入 Partition table
 The partition table has been altered!
 Syncing disks.
 !!! 一般建議割一個較小的主分割區 (重新開機後會掛載為 /)、一個 swap 以及一個較大的主分割區 (開機後會自動掛載到 /mnt)。因為我的硬碟只有 4G, 所以就省略了 /mnt 的分割區。
- 格式化新建的分割區:
 # mke2fs -j /dev/hda1 ← 將 /dev/hda1 格式化為 ext3
 mke2fs 1.22, 22-Jun-2001 for EXT2 FS 0.5b, 95/08/09
 Filesystem label=
 OS type: Linux
 Block size=4096 (log=2)
 Fragment size=4096 (log=2)
 500960 inodes, 1000038 blocks
 50001 blocks (5.00%) reserved for the super user
 First data block=0
 31 block groups
 32768 blocks per group, 32768 fragments per group
 16160 inodes per group
 Superblock backups stored on blocks:
 32768, 98304, 163840, 229376, 294912, 819200, 884736
 Writing inode tables: done
 Creating journal (8192 blocks): done
 Writing superblocks and filesystem accounting information: done
 This filesystem will be automatically checked every 30 mounts or
 180 days, whichever comes first. Use tune2fs -c or -i to override.
 # mkswap /dev/hda2 ← 格式化 swap
 Setting up swapspace version 1, size = 222076928 bytes
- 掛載分割區:
 # mount -t ext3 /dev/hda1 /mnt ← 將 /dev/hda1 掛載到 EM Mode 的 /mnt (重新開機後, 它會掛載到 /)
- 上傳別人做好的 debian 基本系統:
 請到http://www.kurobox.com/mwiki/index.php/Debian_sylver網站下載給 Kuro-Box 用的 debian 2.6 核心版本基本系統。我下載的為http://www.kurobox.com/sylver/debian/debian-sarge-2.6.17.1-mh1_kuro-box-20060623.tgz
 (原始文件:請到 http://kuro.dsk.jp/ 網站下載給 Kuro-Box 用的 debian 基本系統, 我下載的為debian_2005_04_09_dist.tgz。)
 你可由 Windows 上傳:
 D:\downloads\KuroBox>ftp 192.168.11.150
 Connected to 192.168.11.150.
 220 KURO-BOX-EM FTP server (Version 6.4/OpenBSD/Linux-ftpd-0.17) ready.
 User (192.168.11.150:(none)): root ← 帳號
 331 Password required for root.
 Password:kuroadmin ← 密碼
 230- Linux 2.4.17 ppc unknown
 230 User root logged in.
 ftp> cd /mnt ← 切換到 /dev/hda1 所掛載的目錄
 250 CWD command successful.
 ftp> bin ← 以二進位的格式上傳
 200 Type set to I.
 ftp> put debian-sarge-2.6.17.1-mh1_kuro-box-20060623.tgz← 上傳檔案
 200 PORT command successful.
 150 Opening BINARY mode data connection for 'debian-sarge-2.6.17.1-mh1_kuro-box-20060623.tgz'.
 226 Transfer complete.
 ftp: 39301055 bytes sent in 8.40Seconds 4677.03Kbytes/sec.
 ftp> bye ← 離線
 221 Goodbye.
- 解開壓縮檔:
 回到 telnet 連線, 請如下解開壓縮檔:
 # cd /mnt
 # ls
 debian-sarge-2.6.17.1-mh1_kuro-box-20060623.tgz lost+found
 # tar zxvf debian-sarge-2.6.17.1-mh1_kuro-box-20060623.tgz
- 編輯 /etc/hosts.allow 檔:
 在預設的情況下, Kuro-Box 只允許 192.168.0.0/255.255.255.0 及 127.0.0.1 的 IP 存取由 inetd所管理的服務 (例如 telnet)。因此, 若你要設給 Kuro-Box 使用的 IP 不在這個範圍 (例如你要設定真實的 IP), 重開機之後將會無法 telnet 進去, 因為被擋掉了。
 # vi /mnt/etc/hosts.allow
 ALL : 192.168.0.0/255.255.255.0
 ALL : 127.0.0.1
 ALL : .hinet.net ← 允許所有 Hi-Net 的 IP 均可連線
- 設定網路卡的 IP:
 此 Debian 預設 eth0 的 IP 為 192.168.0.100, 若你想更改, 請編輯 /mnt/etc/network/interfaces檔:
 # vi /mnt/etc/network/interfaces
 iface eth0 inet static ← 若要設定 DHCP, 請將 static 改為 dhcp
 address 192.168.1.100 ← 若要設定 DHCP, 請刪此行
 network 192.168.1.0 ← 若要設定 DHCP, 請刪此行
 netmask 255.255.255.0 ← 若要設定 DHCP, 請刪此行
 broadcast 192.168.1.255 ← 若要設定 DHCP, 請刪此行
 gateway 192.168.1.1 ← 若要設定 DHCP, 請刪此行
 iface lo inet loopbackauto eth0 lo9.
- 若設定固定 IP, 請編輯 /mnt/etc/resolv.conf 檔, 修改 DNS Server 資訊:
 # vi /mnt/etc/resolv.conf
 search
 nameserver 168.95.1.1 ← 修改 DNS Server 資訊
 nameserver 168.95.192.1 ← 修改 DNS Server 資訊
- 將 ok 訊息寫入 /dev/fl3:
 你需要執行下列指令將 OK 訊息寫到 flash 中, 否則下次重新開機後仍會進入 EM Mode:
 # write_ok
 argv: write_ok
- 重新開機
 # reboot
- 依前面所設定的 IP telnet 到 Kuro-Box:
 C:\> telnet 192.168.1.100
 Debian GNU/Linux 3.0 KURO-BOXKURO-BOX login: tmp-kun ← 預設設號
 Password:tmp-kun ← 預設密碼
 Last login: Sun May 2 15:10:53 2004 from 192.168.0.32 on pts/0Linux KURO-BOX 2.4.17_mvl21 #24 2004 10畸 19 紹豖 17:17:03 JST ppc unknownMost of the programs included with the Debian GNU/Linux system arefreely redistributable; the exact distribution terms for each programare described in the individual files in /usr/share/doc/*/copyrightDebian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extentpermitted by applicable law.
 tmp-kun@KURO-BOX:~$ passwd ← 更改密碼
 Changing password for tmp-kun(current) UNIX password:tmp-kun ← 輸入預設的密碼
 Enter new UNIX password: ← 新的密碼
 Retype new UNIX password:← 新的密碼
 passwd: password updated successfully
- 切換為 root 身份, 並改變密碼:
 tmp-kun@KURO-BOX:~$ su -
 Password:root ← root 使用者的密碼預設為 root
 KURO-BOX:~# passwd ← 更改密碼
 Enter new UNIX password: ← 新的密碼
 Retype new UNIX password:← 新的密碼
 passwd: password updated successfully
- 升級套件資訊與升級系統套件:
 修改source.list內的套件主機來取得最新的套件資訊
 KURO-BOX:~# nano /etc/apt/sources.list
 #deb http://security.debian.org stable/updates main contrib
 #deb ftp://ftp.dti.ad.jp/pub/Linux/debian stable main contrib
 #deb ftp://ftp.dti.ad.jp/pub/Linux/debian-non-US stable/non-US main contrib
 #deb-src ftp://ftp.dti.ad.jp/pub/Linux/debian stable main contrib
 #deb-src ftp://ftp.dti.ad.jp/pub/Linux/debian-non-US stable/non-US main contrib
 deb http://ftp.tw.debian.org/debian/ testing main contrib
 deb-src http://ftp.tw.debian.org/debian/ testing main contrib
 deb http://ftp.tw.debian.org/debian/ unstable main contrib
 deb-src http://ftp.tw.debian.org/debian/ unstable main contrib
 完成後存檔,然後再來新增一個檔案/etc/apt/apt.conf來讓 debian 依我們指定的版本來安裝更新
 # nano /etc/apt/apt.conf
 加入
 APT::Default-Release "testing"; ← 指定用testing版
 然後存檔
 以下會透過網路升級, 請確定 Kuro-Box 可以正常上網:
 KURO-BOX:~# aptitude update
 KURO-BOX:~# aptitude upgrade
- 安裝所需的套件:
 KURO-BOX:~# aptitude install ssh ← 安裝 OpenSSH
- 關閉 telnet 服務:
 既然有了 SSH, 我們就不需要不安全的 telnet 了
 KURO-BOX:~# nano /etc/inetd.conf
 ...
 #:STANDARD: These are standard services.
 #telnet stream tcp nowait root /usr/sbin/tcpd /usr/sbin/in.telnetd ← 在最前面加上 # 註解
 ftp stream tcp nowait root /usr/sbin/tcpd /usr/sbin/proftpd
 ...
 KURO-BOX:~# rboot ← 重新啟動
- 測試telnet是否關閉,然後用ssh登入:
 C:\> telnet 192.168.1.100
 正連線到 192.168.1.100...無法開啟到主機的連線, 在連接埠 23: 連線失敗
 到http://www.csie.ntu.edu.tw/~piaip/pietty/下載PieTTY用ssh登入
 login as:root ← 用root登入
 root@192.168.1.100's password: ******** ← 輸入password
 Last login: Thu Apr 26 23:04:19 2007 from 192.168.1.4 Linux KURO-BOX 2.6.17.1-mh1_kuro-box #4 Fri Jun 23 02:52:02 CEST 2006 ppc GNU/Linux The programs included with the Debian GNU/Linux system are free software; 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.
 KURO-BOX:~#
- 系統備份
 1. 設定進入 EM 模式,重開機
 ※debian 2.4 的核心
 #echo -n "NGNG" > /dev/fl3
 #reboot
 ※debian 2.6 的核心
 # echo -n "NGNG" > /dev/mtdblock2
 # reboot
 2. EM 模式下 root 登錄
 3. 掛載分割區
 # mount /dev/hda1 /mnt
 # mount /dev/hda3 /mnt2
 4. 備份系統到 /mnt2/bkup.tar
 # cd /mnt
 # tar cvf /mnt2/bkup.tar .
 # write_ok
 # reboot
 (5. 還原
 # cd /mnt
 # tar xvf /mnt2/bkup.tar
 # write_ok
 # reboot)
 
