zuntan02のはてなブログ

備忘録的なものです。時々職場の技術者ブログにも転記してますが、メインはこちらで。

玄箱無印のHDDを入れ替えた(debian-lenny化)

玄箱にKURO-SATA経由で2TBのHDDを接続し、Debian-Lennyを入れたメモ

前回
http://d.hatena.ne.jp/zuntan02/20101231/1293772304

 1)EMモードで起動し、手動でデータ用パーティションを小さめに切る
 2)ファームウェアを書き込み、スワップ領域を生きにする
 3)EMモードで起動し、データ用パーティションを最大に切りなおす
 4)標準モードで起動し、swap領域が生きの状態で再度データ領域をフォーマット

という手順で2TBが使用できる様になったので、その勢いでDebian-Lenny化をやってみます。


※以下の手順は
玄箱Debian 5.0 (lenny) をインストールする
http://www.revulo.com/kuro-box/Debian/lenny.html
に従って作業したときのメモです。新しい情報とかはありません。悪しからず。


パーティションの分割

パーティション予定:lenny用の領域に若干の余裕を持たせています(20GB)。
 最小構成で4GB程度あれば問題ないはず。

/dev/hda1	256 MB 〜 2 GB	ブート用
/dev/hda2	256 MB	スワップ領域
/dev/hda3	20000 MB	lenny 用
/dev/hda4	残り全部	データ用(/mnt/share)

EMモードで起動してから以下の操作を行う

Kroutoshikou KURO-BOX (IETSUNA)
kernel 2.4.17-kuro-box on ppc

KURO-BOX-EM login: root
Password:kuro

パーティションクリア

mfdisk -e /dev/hda
delete partition 1
delete partition 2
delete partition 3
create partitions...
deleate all partitions.
The partition table has been altered!

Syncing disks.

パーティション作成
※/dev/hda4は、最初ファームウェアをインストールするために、小さめに作成しています。

/sbin/mfdisk -c /dev/hda

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-243201, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-243201, default 243201): +2000M

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (256-243201, default 256):
Using default value 256
Last cylinder or +size or +sizeM or +sizeK (256-243201, default 243201): +256M

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (289-243201, default 289):
Using default value 289
Last cylinder or +size or +sizeM or +sizeK (289-243201, default 243201): +20000M

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 4
First cylinder (2839-243201, default 2839):
Using default value 2839
Last cylinder or +size or +sizeM or +sizeK (2839-243201, default 243201): +20000M

Command (m for help): p

Disk /dev/hda: 255 heads, 63 sectors, 243201 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hda1             1       255   2048256   83  Linux
/dev/hda2           256       288    265072+  83  Linux
/dev/hda3           289      2838  20482875   83  Linux
/dev/hda4          2839      5388  20482875   83  Linux

/dev/hda2をスワップ領域に

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 82
Changed system type of partition 2 to 82 (Linux swap)

Command (m for help): p

Disk /dev/hda: 255 heads, 63 sectors, 243201 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hda1             1       255   2048256   83  Linux
/dev/hda2           256       288    265072+  82  Linux swap
/dev/hda3           289      2838  20482875   83  Linux
/dev/hda4          2839      5388  20482875   83  Linux

Command (m for help): w
The partition table has been altered!

Syncing disks.

各領域をフォーマットする

mke2fs -j /dev/hda1
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)
256512 inodes, 512064 blocks
25603 blocks (5.00%) reserved for the super user
First data block=0
16 block groups
32768 blocks per group, 32768 fragments per group
16032 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

Writing inode tables: done
Creating journal (8192 blocks): mkswap /dev/hda2
done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
Setting up swapspace version 1, size = 271429632 bytes
mke2fs -j -m 0 /dev/hda3
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)
2562240 inodes, 5120718 blocks
0 blocks (0.00%) reserved for the super user
First data block=0
157 block groups
32768 blocks per group, 32768 fragments per group
16320 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

mke2fs -j -m 0 /dev/hda4
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)
2562240 inodes, 5120718 blocks
0 blocks (0.00%) reserved for the super user
First data block=0
157 block groups
32768 blocks per group, 32768 fragments per group
16320 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.


ここでKURO-BOXFirmwareUpdateを実行(ファームウェアを書き込み、swapを有効にする)
Windowsのファイアーウォールは無効にして実施のこと
→「アップデートが完了しました。
  再起動完了後、使用できるようになります」

EMモードに戻す

root@KURO-BOX:~echo -n 'NGNG' > /dev/fl3
root@KURO-BOX:~reboot

EMモードで再起動してきたら、root/kuroでログインし、データ領域/dev/hda4をクリア後、最大化

mfdisk -c /dev/hda

Command (m for help): p

Disk /dev/hda: 255 heads, 63 sectors, 243201 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hda1             1       255   2048256   83  Linux
/dev/hda2           256       288    265072+  82  Linux swap
/dev/hda3           289      2838  20482875   83  Linux
/dev/hda4          2839      5388  20482875   83  Linux

Command (m for help): d
Partition number (1-4): 4

Command (m for help): p

Disk /dev/hda: 255 heads, 63 sectors, 243201 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hda1             1       255   2048256   83  Linux
/dev/hda2           256       288    265072+  82  Linux swap
/dev/hda3           289      2838  20482875   83  Linux

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 4
First cylinder (2839-243201, default 2839):
Using default value 2839
Last cylinder or +size or +sizeM or +sizeK (2839-243201, default 243201):
Using default value 243201

Command (m for help): p

Disk /dev/hda: 255 heads, 63 sectors, 243201 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hda1             1       255   2048256   83  Linux
/dev/hda2           256       288    265072+  82  Linux swap
/dev/hda3           289      2838  20482875   83  Linux
/dev/hda4          2839    243201 1930715797+  83  Linux

Command (m for help): w
The partition table has been altered!

Syncing disks.

フォーマットを行うために、通常モードで再起動

echo -n 'OKOK' > /dev/fl3
reboot

通常モードで再起動してきたら、rootでログインしてフォーマット実行

root@KURO-BOX:~mke2fs -j -m 0 /dev/hda4
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)
241352704 inodes, 482678949 blocks
0 blocks (0.00%) reserved for the super user
First data block=0
14731 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000, 214990848

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

http://www.revulo.com/kuro-box/Debian/lenny.html
経由ダウンロードしてきたファイルをsamba経由で玄箱にコピー

debian-lenny-installer-kuroBOX-20090317.tgz
debian-lenny-kuroBOX-20090317.tgz
kernelimage-2.6.25.1-kuroBOX.tgz
kuro-bootsel2.20080419.tar.gz
kuro-bootsel2-debian.tgz
modules-2.6.25.1-kuroBOX.tgz
loader.o

コピーしたファイルは/mnt/shareに入るので、telnet玄箱にログインし、
/tmp以下にファイルを移動して、インストール

mv /mnt/share/* /tmp
cd /tmp
tar xvzf debian-lenny-installer-kuroBOX-20090317.tgz
sh ./debian-lenny-installer-kuroBOX.sh

スクリプト終了後、再起動を行う前にネットワーク周りの設定を行います。
再起動後に参照されるのは/mnt以下となる様なので、以下のファイルを修正。
これは皆様の環境に合わせて設定してください。

/mnt/etc/hosts
/mnt/etc/network/interfaces
/mnt/etc/hosts.allow
/mnt/etc/resolv.conf

再起動すると、上記設定でlennyが起動。

あとやったことは、
telnetで接続し、接続用ユーザ作成、rootのパスワード変更
 →rootの初期パスワードはroot
tmp-kun/tmp-kunでログイン、suでrootになり、passwdでパスワード変更
ログイン用ユーザー追加とtmp-kun削除
adduserコマンドで

[root@KURO-BOX:]adduser hoge

作成したアカウントでログインしsu後、tmp-kunを削除

[root@KURO-BOX:]deluser --remove-home tmp-kun

利用可能なパッケージの一覧を更新、アップグレード

apt-get update
apt-get upgrade

ssh導入

apt-get install ssh

再起動後、teratermssh接続→OK

telne無効化

vi /etc/inetd.conf
#telnet  stream tcp nowait root /usr/sbin/tcpd /usr/sbin/in.telnetd
↑コメントアウトする

rootでssh接続できないようにする

vi /etc/ssh/sshd_config
PermitRootLogin yes → PermitRootLogin no

再起動してrootで接続できないことを確認→ok