第7章 コンパクトフラッシュシステム構築

7.1. コンパクトフラッシュシステム例

Armadilloでは、コンパクトフラッシュにLinuxシステムを構築することができます。この章では、起動可能なコンパクトフラッシュシステムの構築手順について説明します。

[警告]

ブートローダがカーネルイメージを読み込むことができるファイルシステムは、EXT2ファイルシステムとなっています。

この章では、表7.1「コンパクトフラッシュシステム例」のようなコンパクトフラッシュシステムを例に、構築手順を説明します。

表7.1 コンパクトフラッシュシステム例

パーティション[a]タイプ容量説明
/dev/hda1ext232MB

起動パーティション。

カーネルイメージを配置する領域です。

/dev/hda2ext3 - ルートファイルシステムを配置する領域です。

[a] Armadillo-9の場合、パーティション名は/dev/hdc1,/dev/hdc2となります。以降、適宜読み替えてください。


7.2. コンパクトフラッシュの初期化

ここでは、コンパクトフラッシュをフォーマットし、パーティション1にEXT2ファイルシステムを、パーティション2にEXT3ファイルシステムを作成するところまでの手順を説明します。

作業の前に、ジャンパピンを以下のように設定してください。

表7.2 コンパクトフラッシュ初期化時のジャンパピン設定

製品ジャンパピン設定
Armadillo-9

JP1:オープン

JP2:オープン

Armadillo-300JP1:1-2

7.2.1. ディスクフォーマット

図7.1「ディスク初期化方法」のように、ディスクをフォーマットします。

[armadillo ~]# fdisk /dev/hda
The number of cylinders for this disk is set to 1324.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): d
No partition is defined yet!

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

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

Command (m for help): p

Disk /dev/hda: 512 MB, 512483328 bytes
12 heads, 63 sectors/track, 1324 cylinders
Units = cylinders of 756 * 512 = 387072 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hda1               1          84       31720+  83  Linux
/dev/hda2              85        1324      468720   83  Linux

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

Calling ioctl() to re-read partition table.
 hda: hda1 hda2
 hda: hda1 hda2
Syncing disks.

図7.1 ディスク初期化方法


7.2.2. ファイルシステムの作成

図7.2「ファイルシステムの構築」のように初期化したディスクのパーティションにファイルシステムを作成します。

[ティップ]

mke2fsで起動パーティション(カーネルイメージを配置するパーティション)にEXT2ファイルシステムを作成する場合は、必ず「-O none」オプションを指定する必要があります。

[armadillo ~]# mke2fs -O none /dev/hda1
mke2fs 1.25 (20-Sep-2001)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
7936 inodes, 31720 blocks
1586 blocks (5%) reserved for the super user
First data block=1
4 block groups
8192 blocks per group, 8192 fragments per group
1984 inodes per group
Superblock backups stored on blocks:
        8193, 16385, 24577

Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 36 mounts or
180.00 days, whichever comes first.  Use tune2fs -c or -i to override.
[armadillo ~]# mke2fs -j /dev/hda2
mke2fs 1.25 (20-Sep-2001)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
117392 inodes, 468720 blocks
23436 blocks (5%) reserved for the super user
First data block=1
58 block groups
8192 blocks per group, 8192 fragments per group
2024 inodes per group
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

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

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

図7.2 ファイルシステムの構築


7.3. カーネルイメージを配置する

コンパクトフラッシュシステムから起動する場合は、起動パーティションの/bootディレクトリにカーネルイメージを配置する必要があります。対応しているカーネルイメージは、非圧縮カーネルイメージ(Image linux.bin)または、圧縮イメージ(Image.gz linux.bin.gz)のどちらかになります。

ここで説明する例では、カーネルイメージの取得にwgetコマンドを使用します。wgetコマンドで指定するURLは製品によって異なりますので、以下の表を参照し適宜読み替えてください。

表7.3 カーネルイメージのダウンロード先URL

製品URL
Armadillo-9http://download.atmark-techno.com/armadillo-9/image/linux-[version].bin.gz
Armadillo-300http://download.atmark-techno.com/armadillo-300/image/linux-a300-[version].bin.gz
Armadillo-500http://download.atmark-techno.com/armadillo-500/image/linux-a500-[version].bin.gz

以下にArmadillo-500での配置例を示します。

[armadillo ~]# mount /dev/hda1 /mnt
[armadillo ~]# mkdir /mnt/boot
[armadillo ~]# cd /mnt/boot
[armadillo ~]# wget http://download.atmark-techno.com/armadillo-500/image/linux-a500-[version].bin.gz
Connecting to download.atmark-techno.com [210.191.215.172]:80
linux-a500-[version].bin.gz 100% |**********************|  **** KB    00:00 ETA
[armadillo ~]# mv linux-a500-[version].bin.gz /mnt/boot/Image.gz
[armadillo ~]# sync
[armadillo ~]# umount /mnt

図7.3 カーネルイメージの配置


7.4. ルートファイルシステムの構築

ここでは、コンパクトフラッシュにルートファイルシステムを構築する手順について説明します。

7.4.1. Debian GNU/Linuxを構築する

Debianを構築する場合、付属CDのdebianディレクトリ以下のアーカイブを使用するか、弊社ダウンロードサイトからアーカイブを取得します。これは、純粋なDebianでインストールされるファイルを分割してアーカイブ化したものとなります。これらをファイルシステム上に展開することでルートファイルシステムを構築することができます。

[ティップ]

ルートファイルシステムにDebianを構築する場合は、パーティションの空き容量が最低でも256MB必要です。

ここで説明する例では、debianアーカイブの取得にwgetコマンドを使用します。wgetコマンドで指定するURLは製品によって異なりますので、以下の表を参照し適宜読み替えてください。

表7.4 debianアーカイブのダウンロード先URL

製品URL
Armadillo-9http://download.atmark-techno.com/armadillo-9/debian/debian-etch-a9-#.tgz
Armadillo-300http://download.atmark-techno.com/armadillo-300/debian/debian-etch-a300-#.tgz
Armadillo-500http://download.atmark-techno.com/armadillo-500/debian/debian-etch-arm#.tgz

以下にArmadillo-500での構築例を示します。

[armadillo ~]# mount /dev/hda2 /mnt
[armadillo ~]# mount -t ramfs ramfs /tmp
[armadillo ~]# cd /tmp

[LOOP]: debian-etch-arm#.tgzの#の部分を1~5まで繰り返します。

[armadillo /tmp]# wget http://download.atmark-techno.com/armadillo-500/debian/debian-etch-arm#.tgz
Connecting to download.atmark-techno.com [210.191.215.172]:80
debian-etch-#.tgz    100% |************************|  **** KB    00:00 ETA
[armadillo /tmp]# gzip -cd debian-etch-arm#.tgz | (cd /mnt; tar xf -)
[armadillo /tmp]# sync
[armadillo /tmp]# rm -f debian-etch-arm#.tgz

[LOOP] に戻る

[armadillo /tmp]# umount /mnt

図7.4 Debianアーカイブの構築例


7.4.2. atmark-distイメージから構築する

atmark-distで作成されるシステムイメージをコンパクトフラッシュのルートファイルシステムとして構築する方法を説明します。Debianを構築する場合に比べ、ディスク容量の少ないコンパクトフラッシュへシステムを構築することができます。

ここで説明する例では、atmark-distイメージの取得にwgetコマンドを使用します。wgetコマンドで指定するURLは製品によって異なりますので、以下の表を参照し適宜読み替えてください。

表7.5 atmark-distイメージのダウンロード先URL

製品URL
Armadillo-9http://download.atmark-techno.com/armadillo-9/image/romfs-[version].img.gz
Armadillo-300http://download.atmark-techno.com/armadillo-300/image/romfs-a300-[version].img.gz
Armadillo-500http://download.atmark-techno.com/armadillo-500/image/romfs-a500-[version].img.gz

以下にArmadillo-500での構築例を示します。

[armadillo ~]# mount -t ramfs ramfs /tmp
[armadillo ~]# cd /tmp
[armadillo /tmp]# wget http://download.atmark-techno.com/armadillo-500/image/romfs-a500-[version].img.gz
Connecting to download.atmark-techno.com [210.191.215.172]:80
romfs-a500-1.00.img.gz 100% |**********************|  **** KB    00:00 ETA
[armadillo /tmp]# gzip -dc romfs-a500-[version].img.gz > romfs.img
[armadillo /tmp]# mount /dev/hda2 /mnt
[armadillo /tmp]# mkdir romfs
[armadillo /tmp]# mount -o loop romfs.img romfs
[armadillo /tmp]# (cd romfs/; tar cf - *) | (cd /mnt; tar xf -)
[armadillo /tmp]# sync
[armadillo /tmp]# umount romfs
[armadillo /tmp]# umount /mnt

図7.5 romfs.img.gzからの作成例


7.5. コンパクトフラッシュシステムの起動

ジャンパにより起動モードを保守モードに設定し、再起動してください。

保守モードで立ち上げ、コンパクトフラッシュのカーネルイメージで起動するためには、図7.6「起動デバイスの指定」を実行してください。ルートファイルシステムの設定については、図7.7「ルートファイルシステム指定例」を実行してください。

hermit> setbootdevice hda1

図7.6 起動デバイスの指定


hermit> setenv console=ttymxc0 root=/dev/hda2 rootdelay=3 noinitrd

図7.7 ルートファイルシステム指定例


7.6. システム設定例

新しくシステムを構築した場合、システム起動時にERRORまたはWARNINGが表示される場合があります。それらを解決する方法を説明します。

7.6.1. Debianシステム

7.6.1.1. modulesディレクトリの更新

WARNING

modprobe: FATAL: Could not load /lib/modules/[version]/modules.dep: No such file or directory

図7.8 WARNING:modules.dep


解決方法

システムにログインし、図7.9「解決方法:modules.dep」のようにコマンドを実行します。

[debian ~]# mkdir -p /lib/modules/`uname -r`
[debian ~]# depmod

図7.9 解決方法:modules.dep


7.6.2. atmark-distシステム

7.6.2.1. fstabの更新

WARNING

fsck.ext2: Bad magic number in super-block while trying to open /dev/ram0
(null):
The superblock could not be read or does not describe a correct ext2
filesystem.  If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>

WARNING: Error while checking root filesystem.
You can login as root now, the system will reboot after logout.

Give root password for system maintenance
(or type Control-D for normal startup):

図7.10 WARNING:fstab


解決方法

Control-Dを押下した後システムにログイン[8]し、/etc/fstab図7.11「解決方法:fstab」のように変更します。

[armadillo ~]# vi /etc/fstab

/dev/hda2       /               ext3    defaults    0   1
proc            /proc           proc    defaults    0   0
usbfs           /proc/bus/usb   usbfs   defaults    0   0
sysfs           /sys            sysfs   defaults    0   0

図7.11 解決方法:fstab




[8] 図7.10「WARNING:fstab」の状態でrootユーザパスワードを入力してログインすると、ルートファイルシステムは書き込み不可状態でマウントされています。そのため、ファイルの編集を行うためには書き込み可能状態に再マウントする必要があります。