Feb 22, 2005
								KEK, Online
								by E.Inoue

確認事項: このメモは以下の3項を満たす環境で作業を行うことを想定
         している。


  (1). knoppixシステムが利用可能なPCを使用する。
  (2). PCはUSBポートが利用可能である。
  (3). USB-コンパクトフラッシュR/Wアダプタを所有している。

(3). KNOPPIXシステムからの復旧 上記の項目(2-6)で作成した CC/NET用の KNOPPIX CD を使ってコンパクトフラッ シュ上に Debian GNU/Linux システムを復旧する。 (3-1). 作成した KNOPPIX CDを起動 onlpc03.kek.jp のマシンに、上記の項目(2-6)で作成した CC/NET用の KNOPPIX CD をセットし電源をonした。 KNOPPIXシステムは正常に立ち上がった。 (3-2). KNOPPIXのCDに組み込んだ compact.tar.gzからの復旧 KNOPPIXシステムに組み込んだ CC/NET用の復旧ファイルを確認する。 knoppix@ttyp1[/]$ pwd / knoppix@ttyp1[/]$ ls KNOPPIX boot dev home mnt opt ramdisk sbin sys usr bin cdrom etc lib none proc root sfs tmp var knoppix@ttyp1[/]$ knoppix@ttyp1[/]$ ls KNOPPIX TOYO cdrom floppy lib none root tmp vmlinuz bin dev home lost+found opt sbin usr vmlinuz.old boot etc initrd mnt proc sys var knoppix@ttyp1[/]$ knoppix@ttyp1[/]$ ls -l KNOPPIX/TOYO 合計 189006 -rw-r--r-- 1 root root 193452462 2005-02-22 13:53 compact-debian-Feb182005.tar.gz lrwxrwxrwx 1 root root 31 2005-02-22 13:56 compact.tar.gz -> compact-debian-Feb182005.tar.gz -rw-r--r-- 1 root root 89121 2005-02-22 14:01 out knoppix@ttyp1[/]$ (3-2-1). コンパクトフラッシュの準備 root@ttyp1[/]# fdisk -l Disk /dev/sda: 40.0 GB, 40029954048 bytes 255 heads, 63 sectors/track, 4866 cylinders Units = シリンダ数 of 16065 * 512 = 8225280 bytes デバイス Boot Start End Blocks Id System /dev/sda1 * 1 127 1020096 b W95 FAT32 /dev/sda2 128 2040 15366172+ c W95 FAT32 (LBA) /dev/sda3 3847 4866 8193150 f W95 Ext'd (LBA) /dev/sda4 2041 3846 14506695 83 Linux /dev/sda5 3847 4866 8193118+ b W95 FAT32 領域テーブル項目がディスクの順序と一致しません Disk /dev/sdb: 40.0 GB, 40029954048 bytes 255 heads, 63 sectors/track, 4866 cylinders Units = シリンダ数 of 16065 * 512 = 8225280 bytes デバイス Boot Start End Blocks Id System /dev/sdb1 1 13 104391 83 Linux /dev/sdb2 1983 4866 23165730 83 Linux /dev/sdb3 111 1982 15036840 f W95 Ext'd (LBA) /dev/sdb4 14 110 779152+ 82 Linux スワップ /dev/sdb5 * 111 716 4867663+ 83 Linux /dev/sdb6 717 1610 7181023+ 83 Linux /dev/sdb7 * 1611 1982 2988058+ 83 Linux 領域テーブル項目がディスクの順序と一致しません Disk /dev/sdc: 80.0 GB, 80020684800 bytes 255 heads, 63 sectors/track, 9728 cylinders Units = シリンダ数 of 16065 * 512 = 8225280 bytes デバイス Boot Start End Blocks Id System /dev/sdc1 * 1 1217 9775521 83 Linux /dev/sdc2 1218 2434 9775552+ 83 Linux /dev/sdc3 2435 3651 9775552+ 83 Linux /dev/sdc4 3652 9728 48813502+ f W95 Ext'd (LBA) /dev/sdc5 3652 4868 9775521 83 Linux /dev/sdc6 4869 6085 9775521 83 Linux /dev/sdc7 6086 7302 9775521 83 Linux /dev/sdc8 7303 8519 9775521 83 Linux /dev/sdc9 8520 9728 9711261 83 Linux Disk /dev/sdd: 80.0 GB, 80020684800 bytes 255 heads, 63 sectors/track, 9728 cylinders Units = シリンダ数 of 16065 * 512 = 8225280 bytes デバイス Boot Start End Blocks Id System /dev/sdd1 * 1 1217 9775521 83 Linux /dev/sdd2 1218 2434 9775552+ 83 Linux /dev/sdd3 2435 3651 9775552+ 83 Linux /dev/sdd4 3652 9728 48813502+ f W95 Ext'd (LBA) /dev/sdd5 3652 4868 9775521 83 Linux /dev/sdd6 4869 6085 9775521 83 Linux /dev/sdd7 6086 7302 9775521 83 Linux /dev/sdd8 7303 8519 9775521 83 Linux /dev/sdd9 8520 9728 9711261 83 Linux Disk /dev/sde: 1024 MB, 1024966656 bytes 32 heads, 63 sectors/track, 993 cylinders Units = シリンダ数 of 2016 * 512 = 1032192 bytes デバイス Boot Start End Blocks Id System /dev/sde1 1 993 1000912+ 83 Linux Disk /dev/hda: 20.5 GB, 20576747520 bytes 255 heads, 63 sectors/track, 2501 cylinders Units = シリンダ数 of 16065 * 512 = 8225280 bytes デバイス Boot Start End Blocks Id System /dev/hda1 * 1 382 3068383+ b W95 FAT32 /dev/hda3 652 2501 14860125 f W95 Ext'd (LBA) /dev/hda5 652 668 136521 82 Linux スワップ /dev/hda6 669 923 2048256 b W95 FAT32 /dev/hda7 924 1289 2939863+ b W95 FAT32 /dev/hda8 1290 1544 2048256 b W95 FAT32 /dev/hda9 1545 1799 2048256 b W95 FAT32 /dev/hda10 1800 2501 5638783+ b W95 FAT32 root@ttyp1[/]# USB コンパクトフラッシュ・アダプタは /dev/sde として KNOPPIXシステムに認識 されている。 コンパクトフラッシュのメディアをパーティショニングする。 注. 私が作業しているPCの環境では、USB コンパクトフラッシュ・アダプタが /dev/sdeデバイスとして認識されている。 ユーザが使用しているPCの環境に よってデバイス名は異なるので注意すること。 root@ttyp1[/]# fdisk /dev/sde コマンド (m でヘルプ): m コマンドの動作 a ブート可能フラグをつける b bsd ディスクラベルを編集する c dos 互換フラグをつける d 領域を削除する l 既知の領域タイプをリスト表示する m このメニューを表示する n 新たに領域を作成する o 新たに空の DOS 領域テーブルを作成する p 領域テーブルを表示する q 変更を保存せずに終了する s 空の Sun ディスクラベルを作成する t 領域のシステム ID を変更する u 表示/項目ユニットを変更する v 領域テーブルを照合する w テーブルをディスクに書き込み、終了する x 特別な機能 (エキスパート専用) コマンド (m でヘルプ): p Disk /dev/sde: 1024 MB, 1024966656 bytes 32 heads, 63 sectors/track, 993 cylinders Units = シリンダ数 of 2016 * 512 = 1032192 bytes デバイス Boot Start End Blocks Id System /dev/sde1 1 993 1000912+ 83 Linux コマンド (m でヘルプ): d Selected partition 1 コマンド (m でヘルプ): n コマンドアクション e 拡張 p 基本領域 (1-4) p 領域番号 (1-4): 1 最初 シリンダ (1-993, default 1): Using default value 1 終点 シリンダ または +サイズ または +サイズM または +サイズK (1-993, default 993): Using default value 993 コマンド (m でヘルプ): w 領域テーブルは交換されました! ioctl() を呼び出して領域テーブルを再読込みします。 ディスクを同期させます。 root@ttyp1[/]# ファイルシステムを作成する。 root@ttyp1[/]# mke2fs -j /dev/sde1 mke2fs 1.35 (28-Feb-2004) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 125184 inodes, 250228 blocks 12511 blocks (5.00%) reserved for the super user First data block=0 8 block groups 32768 blocks per group, 32768 fragments per group 15648 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376 Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 36 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. root@ttyp1[/]# コンパクトフラッシュをマウントする。 root@ttyp1[/]# mount -t ext3 /dev/sde1 /mnt/sde1 root@ttyp1[/]# df -k Filesystem 1K-ブロック 使用 使用可 使用% マウント位置 /dev/root 3471 1166 2305 34% / /dev/scd0 715302 715302 0 100% /cdrom /dev/cloop 1607184 1607184 0 100% /KNOPPIX /ramdisk 301592 7064 294528 3% /ramdisk /dev/sde1 985160 16428 918688 2% /mnt/sde1 root@ttyp1[/]# (3-2-2). compact.tar.gzを展開 /KNOPPIX/TOYO/compact-debian-Feb182005.tar.gzファイルをコンパクトフラッ シュ上に展開する。 root@ttyp1[TOYO]# pwd /KNOPPIX/TOYO root@ttyp1[TOYO]# ls -l 合計 189006 -rw-r--r-- 1 root root 193452462 2005-02-22 13:53 compact-debian-Feb182005.tar.gz lrwxrwxrwx 1 root root 31 2005-02-22 13:56 compact.tar.gz -> compact-debian-Feb182005.tar.gz -rw-r--r-- 1 root root 89121 2005-02-22 14:01 out root@ttyp1[TOYO]# root@ttyp1[TOYO]# cd /mnt/sde1 root@ttyp1[sde1]# pwd /mnt/sde1 root@ttyp1[sde1]# ls -l 合計 16 drwx------ 2 root root 16384 2005-02-23 14:52 lost+found root@ttyp1[sde1]# root@ttyp1[sde1]# tar xzf /KNOPPIX/TOYO/compact.tar.gz root@ttyp1[sde1]# 注. 私の旧式のPCでは、ファイルを展開するのに約30分かかった。 root@ttyp1[sde1]# pwd /mnt/sde1 root@ttyp1[sde1]# ls -l 合計 104 drwxr-xr-x 2 root root 4096 2004-09-09 20:00 bin drwxr-xr-x 3 root root 4096 2004-09-21 10:41 boot drwxr-xr-x 11 root root 24576 2004-09-17 16:41 dev drwxr-xr-x 52 root root 4096 2004-09-17 16:41 etc drwxrwsr-x 3 root staff 4096 2004-09-09 13:52 home drwxr-xr-x 2 root root 4096 2004-09-09 19:38 initrd lrwxrwxrwx 1 root root 28 2005-02-23 16:05 initrd.img -> boot/initrd.img-2.4.25-1-386 drwxr-xr-x 9 root root 4096 2004-09-10 09:19 lib drwxr-xr-x 2 root root 16384 2004-09-09 19:34 lost+found drwxr-xr-x 3 root root 4096 2004-09-09 19:35 media drwxr-xr-x 2 root root 4096 2004-07-27 03:27 mnt drwxr-xr-x 2 root root 4096 2004-09-09 19:38 opt drwxr-xr-x 2 root root 4096 2004-07-27 03:27 proc drwxr-xr-x 4 root root 4096 2004-09-16 16:05 ramfs drwxr-xr-x 4 root root 4096 2004-09-15 13:32 root drwxr-xr-x 2 root root 4096 2004-09-10 09:47 sbin drwxr-xr-x 2 root root 4096 2004-09-09 19:38 srv drwxr-xr-x 2 root root 4096 2004-05-26 03:40 sys lrwxrwxrwx 1 root root 9 2005-02-23 15:45 tmp -> ramfs/tmp drwxr-xr-x 12 root root 4096 2004-09-15 13:36 usr lrwxrwxrwx 1 root root 9 2005-02-23 16:05 var -> ramfs/var lrwxrwxrwx 1 root root 25 2005-02-23 16:05 vmlinuz -> boot/vmlinuz-2.4.25-1-386 root@ttyp1[sde1]# root@ttyp1[sde1]# e2label /dev/sde1 root@ttyp1[sde1]# e2label /dev/sde1 / root@ttyp1[sde1]# e2label /dev/sde1 / root@ttyp1[sde1]# root@ttyp1[sde1]# pwd /mnt/sde1 root@ttyp1[sde1]# ls sbin/grub sbin/grub root@ttyp1[sde1]# ./sbin/grub Probing devices to guess BIOS drives. This may take a long time. GNU GRUB version 0.95 (640K lower / 3072K upper memory) [ Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists the possible completions of a device/filename. ] grub> root (hd5,0) Filesystem type is ext2fs, partition type 0x83 grub> setup (hd5) Checking if "/boot/grub/stage1" exists... yes Checking if "/boot/grub/stage2" exists... yes Checking if "/boot/grub/e2fs_stage1_5" exists... yes Running "embed /boot/grub/e2fs_stage1_5 (hd5)"... 16 sectors are embedded. succeeded Running "install /boot/grub/stage1 (hd5) (hd5)1+16 p (hd5,0)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded Done. grub> quit root@ttyp1[sde1]# 注. "root (hd5,0)" および "setup (hd5)" のコマンドで指定するハードディス クの番号は、ユーザの使用環境によって変わる。 私の環境では、 内蔵IDEハードディスク :  /dev/hda hd0 外部SCSIディスク : /dev/sda hd1 外部SCSIディスク : /dev/sdb hd2 外部SCSIディスク : /dev/sdc hd3 外部SCSIディスク : /dev/sdd hd4 USB-コンパクトフラッシュR/Wアダプタ : /dev/sde hd5 となっている。 Linuxシステムの構築が完了したコンパクトフラッシュをアンマウントする。 root@ttyp1[sde1]# cd / root@ttyp1[sde1]# root@ttyp1[/]# df -k Filesystem 1K-ブロック 使用 使用可 使用% マウント位置 /dev/root 3471 1166 2305 34% / /dev/scd0 715302 715302 0 100% /cdrom /dev/cloop 1607184 1607184 0 100% /KNOPPIX /ramdisk 301592 7064 294528 3% /ramdisk /dev/sde1 985160 656764 278352 71% /mnt/sde1 root@ttyp1[/]# root@ttyp1[/]# umount /mnt/sde1 root@ttyp1[/]# root@ttyp1[/]# df -k Filesystem 1K-ブロック 使用 使用可 使用% マウント位置 /dev/root 3471 1166 2305 34% / /dev/scd0 715302 715302 0 100% /cdrom /dev/cloop 1607184 1607184 0 100% /KNOPPIX /ramdisk 301592 7064 294528 3% /ramdisk root@ttyp1[/]# USB コンパクトフラッシュ・アダプタからコンパクトフラッシュのメディアを 外す。 (3-2-3). 作成したコンパクトフラッシュを起動 上記の項目(3-2-2) で作成したコンパクトフラッシュのメディアを CC/NET に 装着して Linuxシステムを起動する。 onlsun4[33]% ssh toyo@onlsbc1 Password: Linux onlsbc1 2.4.25-1-386 #2 Wed Apr 14 19:38:08 EST 2004 i686 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. Last login: Fri Sep 17 14:42:03 2004 from onlsun4.kek.jp toyo@onlsbc1:~$ toyo@onlsbc1:~$ su Password: onlsbc1:/home/toyo# df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/hdc1 985160 656768 278348 71% / tmpfs 152828 0 152828 0% /dev/shm onlsbc1:/home/toyo# ここで再度リブートしてみる。 onlsbc1:/home/toyo# reboot Broadcast message from root (pts/0) (Thu Feb 24 09:31:26 2005): The system is going down for reboot NOW! : : onlsun4[35]% ssh toyo@onlsbc1 Password: Linux onlsbc1 2.4.25-1-386 #2 Wed Apr 14 19:38:08 EST 2004 i686 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. Last login: Fri Sep 17 14:42:03 2004 from onlsun4.kek.jp toyo@onlsbc1:~$ toyo@onlsbc1:~$ df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/hdc1 985160 656768 278348 71% / tmpfs 152828 0 152828 0% /dev/shm toyo@onlsbc1:~$ ok. 利用可能ディスクスペースに変化は見られない。 toyo@onlsbc1:~$ ls -l total 16 drwxr-xr-x 2 1003 toyo 4096 Sep 13 16:29 camac drwxr-xr-x 2 1003 toyo 4096 Aug 25 2003 check drwxr-xr-x 3 1003 toyo 4096 Sep 15 14:04 public_html drwxr-xr-x 2 1003 toyo 4096 Sep 13 16:41 remote-camac toyo@onlsbc1:~$ ls -l / total 97 drwxr-xr-x 2 root root 4096 Sep 9 20:00 bin drwxr-xr-x 3 root root 4096 Sep 21 10:41 boot drwxr-xr-x 11 root root 24576 Feb 24 09:36 dev drwxr-xr-x 52 root root 4096 Feb 24 09:36 etc drwxrwsr-x 3 root staff 4096 Sep 9 13:52 home drwxr-xr-x 2 root root 4096 Sep 9 19:38 initrd lrwxrwxrwx 1 root root 28 Feb 23 16:05 initrd.img -> boot/initrd.img-2.4.2 5-1-386 drwxr-xr-x 9 root root 4096 Sep 10 09:19 lib drwxr-xr-x 2 root root 16384 Sep 9 19:34 lost+found drwxr-xr-x 3 root root 4096 Sep 9 19:35 media drwxr-xr-x 2 root root 4096 Jul 27 2004 mnt drwxr-xr-x 2 root root 4096 Sep 9 19:38 opt dr-xr-xr-x 37 root root 0 Feb 24 2005 proc drwxr-xr-x 5 root root 1024 Feb 24 09:35 ramfs drwxr-xr-x 4 root root 4096 Sep 15 13:32 root drwxr-xr-x 2 root root 4096 Sep 10 09:47 sbin drwxr-xr-x 2 root root 4096 Sep 9 19:38 srv drwxr-xr-x 2 root root 4096 May 26 2004 sys lrwxrwxrwx 1 root root 9 Feb 23 15:45 tmp -> ramfs/tmp drwxr-xr-x 12 root root 4096 Sep 15 13:36 usr lrwxrwxrwx 1 root root 9 Feb 23 16:05 var -> ramfs/var lrwxrwxrwx 1 root root 25 Feb 23 16:05 vmlinuz -> boot/vmlinuz-2.4.25-1-38 6 toyo@onlsbc1:~$ ok. KNOPPIX CD から復旧したコンパクトフラッシュを装着したCC/NET上の Debian GNU/Linux システムは正常に立ち上がった。