壊れかけのRAID (-。-) ボソッ

環境

Debian GNU/Linux lenny.


# uname -mrsv
Linux 2.6.26-2-amd64 #1 SMP Tue Jan 25 05:59:43 UTC 2011 x86_64

パソコンのスペック等
ヅラッシュ! - ドスパラ Prime A Lightning AM のスペックを Debian etch 上で確認

RAID1の設定レイアウト等
ヅラッシュ! - Debian GNU/Linux etch で RAID 1 ミラーリングしてみる

マウントポイント基本/論理容量ファイルシステムSCSIパーティションRAIDパーティション
/boot基本パーティション500MBext3sda1, sdb1md0
swap基本パーティション2.0GBswapsda2, sdb2md1
/基本パーティション317.6GBext3sda3, sdb3md2

主な復旧作業の流れ

  1. S.M.A.R.TによるHDD故障注意のお知らせがメールで届く
  2. 新しいHDDをPCに取り付け
  3. 新しいHDDをLinux ソフトウェアRAID1に組み込み (fdisk, mdadm -manage --add)
  4. まちがえて正常なHDDを壊れたことにしてしまった >_< [失敗]
  5. 正常なHDDを追加しなおし (mdadm -manage --add)
  6. 壊れそうなHDDを壊れたことにする (mdadm -manage --fail)
  7. 壊れそうなHDDを切り離す (mdadm -manage --remove)
  8. どのHDDからでもブートするようにする(起動に関するgrubの設定)

S.M.A.R.TによるHDD故障注意のお知らせがメールで届く

PC内メールシステムにてsmartmontoolsから警告メールが届いた。
ヅラッシュ! - smartmontool の smartctl を使ってみた (ハードディスクの調子が悪い、やばす…)

新しいHDDをPCに取り付け

HDD買ってきた。
HITACHI DESKSTAR HDS72105 500GB 7200RPM SATA2

HITACHI DESKSTAR HDS72105 500GB 7200RPM SATA2

ケーブルも購入。

ケーブル

ネジとドライバーセットも購入。ネジはHDDに付属してたのでいらんかった。。。

ネジとドライバーセット

まずはPCをシャットダウン。

PCを開けてみたら、CPUファンの通り道(紫色とオレンジ色)がじゃま。

CPUファンの通り道(紫色とオレンジ色)

CPUファンの通り道をはずしてみたけど、こんどはCPUファンがじゃま。

CPUファン

でも、これをはずすのは大変なので、ぐいぐいとHDD固定ケースひんまげてHDD突っ込んでなんとかはいった(;´Д`)

CPUファン

SATAケーブル。

SATAケーブル

SATAケーブル

電源を入れたら、fsck はじまった。

fsck

その後、ログインしたらS.M.A.R.T警告メールがまた来てたり。

Subject: SMART error (CurrentPendingSector) detected on host: hogehoge

The following warning/error was logged by the smartd daemon:

Device: /dev/sda, 643 Currently unreadable (pending) sectors

For details see host's SYSLOG (default: /var/log/syslog).

You can also use the smartctl utility for further investigation.
No additional email messages about this problem will be sent.

Subject: SMART error (OfflineUncorrectableSector) detected on host: hogehoge

The following warning/error was logged by the smartd daemon:

Device: /dev/sda, 643 Offline uncorrectable sectors

For details see host's SYSLOG (default: /var/log/syslog).

You can also use the smartctl utility for further investigation.
No additional email messages about this problem will be sent.

新旧ハードディスクドライブの情報を見る

いままで使っていたのは ST3320620AS で /dev/sda と /dev/sdb の2台。
追加したのは Hitachi HDS72105 で /dev/sdc の1台。


# cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: ATA      Model: ST3320620AS      Rev: 3.AA
  Type:   Direct-Access                    ANSI  SCSI revision: 05
Host: scsi1 Channel: 00 Id: 00 Lun: 00
  Vendor: ATA      Model: ST3320620AS      Rev: 3.AA
  Type:   Direct-Access                    ANSI  SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
  Vendor: HL-DT-ST Model: DVDRAM GSA-H62N  Rev: CL00
  Type:   CD-ROM                           ANSI  SCSI revision: 05
Host: scsi3 Channel: 00 Id: 00 Lun: 00
  Vendor: ATA      Model: Hitachi HDS72105 Rev: JP2O
  Type:   Direct-Access                    ANSI  SCSI revision: 05
 
# fdisk -l /dev/sda
 
Disk /dev/sda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0003bd97
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          61      489951   fd  Linux raid autodetect
/dev/sda2              62         304     1951897+  fd  Linux raid autodetect
/dev/sda3             305       38913   310126792+  fd  Linux raid autodetect
 
# fdisk -l /dev/sdb
 
Disk /dev/sdb: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00060339
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1          61      489951   fd  Linux raid autodetect
/dev/sdb2              62         304     1951897+  fd  Linux raid autodetect
/dev/sdb3             305       38913   310126792+  fd  Linux raid autodetect
 
# fdisk -l /dev/sdc
 
Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
 
Disk /dev/sdc doesn't contain a valid partition table

新しいHDDにパーティションを切る (fdisk)

RAID1の設定レイアウト。

マウントポイント基本/論理容量ファイルシステムSCSIパーティションRAIDパーティション
/boot基本パーティション500MBext3sda1, sdb1md0
swap基本パーティション2.0GBswapsda2, sdb2md1
/基本パーティション317.6GBext3sda3, sdb3md2

まずは fdisk でパーティション設定。
途中でまちがえてパーティションtypeをLinux swap(82)に設定したり。これは fd (Linux raid autodetect) を指定する。

あと、既存のRAIDに使ってるパーティションと容量がわずかにちがうけど、これはしょうがないよね。このへんの仕組みがよくわからない。まったく同じ容量にするのは難しいからこれでいいと思うんだけど。。。


# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xa1356b4c.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
 
 
The number of cylinders for this disk is set to 60801.
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)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
 
Command (m for help): p
 
Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xa1356b4c
 
   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
First cylinder (1-60801, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-60801, default 60801): +500M
 
Command (m for help): p
 
Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xa1356b4c
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1          62      497983+  83  Linux
 
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (63-60801, default 63):
Using default value 63
Last cylinder or +size or +sizeM or +sizeK (63-60801, default 60801): +2048M
 
Command (m for help): p
 
Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xa1356b4c
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1          62      497983+  83  Linux
/dev/sdc2              63         312     2008125   83  Linux
 
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): L
 
 0  Empty           1e  Hidden W95 FAT1 80  Old Minix       be  Solaris boot
 1  FAT12           24  NEC DOS         81  Minix / old Lin bf  Solaris
 2  XENIX root      39  Plan 9          82  Linux swap / So c1  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  83  Linux           c4  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 5  Extended        41  PPC PReP Boot   85  Linux extended  c7  Syrinx
 6  FAT16           42  SFS             86  NTFS volume set da  Non-FS data
 7  HPFS/NTFS       4d  QNX4.x          87  NTFS volume set db  CP/M / CTOS / .
 8  AIX             4e  QNX4.x 2nd part 88  Linux plaintext de  Dell Utility
 9  AIX bootable    4f  QNX4.x 3rd part 8e  Linux LVM       df  BootIt
 a  OS/2 Boot Manag 50  OnTrack DM      93  Amoeba          e1  DOS access
 b  W95 FAT32       51  OnTrack DM6 Aux 94  Amoeba BBT      e3  DOS R/O
 c  W95 FAT32 (LBA) 52  CP/M            9f  BSD/OS          e4  SpeedStor
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a0  IBM Thinkpad hi eb  BeOS fs
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a5  FreeBSD         ee  EFI GPT
10  OPUS            55  EZ-Drive        a6  OpenBSD         ef  EFI (FAT-12/16/
11  Hidden FAT12    56  Golden Bow      a7  NeXTSTEP        f0  Linux/PA-RISC b
12  Compaq diagnost 5c  Priam Edisk     a8  Darwin UFS      f1  SpeedStor
14  Hidden FAT16 <3 61  SpeedStor       a9  NetBSD          f4  SpeedStor
16  Hidden FAT16    63  GNU HURD or Sys ab  Darwin boot     f2  DOS secondary
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fd  Linux raid auto
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fe  LANstep
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid ff  BBT
1c  Hidden W95 FAT3 75  PC/IX
Hex code (type L to list codes): 82
Changed system type of partition 2 to 82 (Linux swap / Solaris)
 
Command (m for help): p
 
Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xa1356b4c
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1          62      497983+  83  Linux
/dev/sdc2              63         312     2008125   82  Linux swap / Solaris
 
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (313-60801, default 313):
Using default value 313
Last cylinder or +size or +sizeM or +sizeK (313-60801, default 60801): +324608M
 
Command (m for help): p
 
Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xa1356b4c
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1          62      497983+  83  Linux
/dev/sdc2              63         312     2008125   82  Linux swap / Solaris
/dev/sdc3             313       39778   317010645   83  Linux
 
Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)
 
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): fd
Changed system type of partition 2 to fd (Linux raid autodetect)
 
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): fd
Changed system type of partition 3 to fd (Linux raid autodetect)
 
Command (m for help): p
 
Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xa1356b4c
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1          62      497983+  fd  Linux raid autodetect
/dev/sdc2              63         312     2008125   fd  Linux raid autodetect
/dev/sdc3             313       39778   317010645   fd  Linux raid autodetect
 
Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)
 
Command (m for help): a
Partition number (1-4): 1
 
Command (m for help): p
 
Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xa1356b4c
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           1          62      497983+  fd  Linux raid autodetect
/dev/sdc2              63         312     2008125   fd  Linux raid autodetect
/dev/sdc3             313       39778   317010645   fd  Linux raid autodetect
 
Command (m for help): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.

設定完了。/dev/sdc のパーティション情報を見てみる。

/dev/sdc1 => /boot
/dev/sdc2 => Linux swap
/dev/sdc3 => /

にあてるつもり。


# fdisk -l /dev/sdc
 
Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xa1356b4c
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           1          62      497983+  fd  Linux raid autodetect
/dev/sdc2              63         312     2008125   fd  Linux raid autodetect
/dev/sdc3             313       39778   317010645   fd  Linux raid autodetect

Linux ソフトウェアRAID1に組み込み (mdadm -manage --add)

sda と sdb の2台でRAIDを組んでいるのを確認。


# cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 sda3[0] sdb3[1]
      310126720 blocks [2/2] [UU]
 
md1 : active raid1 sda2[0] sdb2[1]
      1951808 blocks [2/2] [UU]
 
md0 : active raid1 sda1[0] sdb1[1]
      489856 blocks [2/2] [UU]
 
unused devices: <none>

新しいHDDである sdc をスペアディスクとして追加。


# mdadm --manage /dev/md0 --add /dev/sdc1
mdadm: added /dev/sdc1
 
# mdadm --manage /dev/md1 --add /dev/sdc2
mdadm: added /dev/sdc2
 
# mdadm --manage /dev/md2 --add /dev/sdc3
mdadm: added /dev/sdc3

sda と sdb と sdc の3台がRAIDに設定された。
sdc はスペアディスクなので (S) が表記されてる。


# cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 sdc3[2](S) sda3[0] sdb3[1]
      310126720 blocks [2/2] [UU]
 
md1 : active raid1 sdc2[2](S) sda2[0] sdb2[1]
      1951808 blocks [2/2] [UU]
 
md0 : active raid1 sdc1[2](S) sda1[0] sdb1[1]
      489856 blocks [2/2] [UU]
 
unused devices: <none>

ここでまちがえて正常なHDDに「壊れますた」という設定をしてしまった orz

/dev/sdb は元気なのに、 mdadm --manage --fail なんて実行してしまった。。。
壊れかけてるのは /dev/sda ですよ!


# mdadm --manage /dev/md0 --fail /dev/sdb1
mdadm: set /dev/sdb1 faulty in /dev/md0
 
# mdadm --manage /dev/md1 --fail /dev/sdb2
mdadm: set /dev/sdb2 faulty in /dev/md1
 
# mdadm --manage /dev/md2 --fail /dev/sdb3
mdadm: set /dev/sdb3 faulty in /dev/md2

あーあ rebuild 発生しちゃった。。。
元気じゃない /dev/sda と 新しく追加した /dev/sdc でRAIDが構築されていく・・・


# cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 sdc3[2] sda3[0] sdb3[3](F)
      310126720 blocks [2/1] [U_]
        resync=DELAYED
 
md1 : active raid1 sdc2[2] sda2[0] sdb2[3](F)
      1951808 blocks [2/1] [U_]
      [===========>.........]  recovery = 58.7% (1148800/1951808) finish=0.1min speed=71800K/sec
 
md0 : active raid1 sdc1[1] sda1[0] sdb1[2](F)
      489856 blocks [2/2] [UU]
 
unused devices: <none>

300GB の rebuild に 214.7min (3時間以上かかる)とかおそろしい。。。


# cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 sdc3[2] sda3[0] sdb3[3](F)
      310126720 blocks [2/1] [U_]
      [>....................]  recovery =  1.1% (3643520/310126720) finish=214.7min speed=23783K/sec
 
md1 : active raid1 sdc2[1] sda2[0] sdb2[2](F)
      1951808 blocks [2/2] [UU]
 
md0 : active raid1 sdc1[1] sda1[0] sdb1[2](F)
      489856 blocks [2/2] [UU]

しょうがないので、待ち。

正常なHDDを追加しなおし (mdadm -manage --add)

元気な /dev/sdb に(F)フラグがついてしまったので remove して add する。


# mdadm --manage /dev/md0 --remove /dev/sdb1
mdadm: hot removed /dev/sdb1
 
# mdadm --manage /dev/md1 --remove /dev/sdb2
mdadm: hot removed /dev/sdb2
 
# mdadm --manage /dev/md2 --remove /dev/sdb3
mdadm: hot removed /dev/sdb3
 
# mdadm --manage /dev/md0 --add /dev/sdb1
mdadm: added /dev/sdb1
 
# mdadm --manage /dev/md1 --add /dev/sdb2
mdadm: added /dev/sdb2
 
# mdadm --manage /dev/md2 --add /dev/sdb3
mdadm: added /dev/sdb3
 
# cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 sdb3[2](S) sdc3[1] sda3[0]
      310126720 blocks [2/2] [UU]
 
md1 : active raid1 sdb2[2](S) sdc2[1] sda2[0]
      1951808 blocks [2/2] [UU]
 
md0 : active raid1 sdb1[2](S) sdc1[1] sda1[0]
      489856 blocks [2/2] [UU]
 
unused devices: 

/dev/sdb がスペアディスクとして追加された。

壊れそうなHDDを壊れたことにする (mdadm -manage --fail)

こんどこそ間違えずに /dev/sda を fail する。


# mdadm --manage /dev/md0 --fail /dev/sda1
mdadm: set /dev/sda1 faulty in /dev/md0
 
# mdadm --manage /dev/md1 --fail /dev/sda2
mdadm: set /dev/sda2 faulty in /dev/md1
 
# mdadm --manage /dev/md2 --fail /dev/sda3
mdadm: set /dev/sda3 faulty in /dev/md2
 
# cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 sdb3[2] sdc3[1] sda3[3](F)
      310126720 blocks [2/1] [_U]
      [>....................]  recovery =  0.1% (566272/310126720) finish=81.9min speed=62919K/sec
 
md1 : active raid1 sdb2[0] sdc2[1] sda2[2](F)
      1951808 blocks [2/2] [UU]
 
md0 : active raid1 sdb1[0] sdc1[1] sda1[2](F)
      489856 blocks [2/2] [UU]
 
unused devices: <none>

しばし待つ。

壊れそうなHDDを切り離す (mdadm -manage --remove)

こんな状態。


# cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 sdb3[0] sdc3[1] sda3[2](F)
      310126720 blocks [2/2] [UU]
 
md1 : active raid1 sdb2[0] sdc2[1] sda2[2](F)
      1951808 blocks [2/2] [UU]
 
md0 : active raid1 sdb1[0] sdc1[1] sda1[2](F)
      489856 blocks [2/2] [UU]
 
unused devices: 

mdadm --manage --remove で壊れかけの HDD /dev/sda を切り離す。


# mdadm --manage /dev/md0 --remove /dev/sda1
mdadm: hot removed /dev/sda1
 
# mdadm --manage /dev/md1 --remove /dev/sda2
mdadm: hot removed /dev/sda2
 
# mdadm --manage /dev/md2 --remove /dev/sda3
mdadm: hot removed /dev/sda3

RAIDの情報を表示。


# cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 sdb3[0] sdc3[1]
      310126720 blocks [2/2] [UU]
 
md1 : active raid1 sdb2[0] sdc2[1]
      1951808 blocks [2/2] [UU]
 
md0 : active raid1 sdb1[0] sdc1[1]
      489856 blocks [2/2] [UU]
 
unused devices: 
 
# mdadm --detail /dev/md0
/dev/md0:
        Version : 00.90
  Creation Time : Mon Sep 24 00:55:38 2007
     Raid Level : raid1
     Array Size : 489856 (478.46 MiB 501.61 MB)
  Used Dev Size : 489856 (478.46 MiB 501.61 MB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 0
    Persistence : Superblock is persistent
 
    Update Time : Thu Jun  2 06:44:13 2011
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0
 
           UUID : 8bba7643:fd066bd7:35faf0c2:7dc468f5
         Events : 0.262
 
    Number   Major   Minor   RaidDevice State
       0       8       17        0      active sync   /dev/sdb1
       1       8       33        1      active sync   /dev/sdc1
 
# mdadm --detail /dev/md1
/dev/md1:
        Version : 00.90
  Creation Time : Mon Sep 24 00:55:52 2007
     Raid Level : raid1
     Array Size : 1951808 (1906.38 MiB 1998.65 MB)
  Used Dev Size : 1951808 (1906.38 MiB 1998.65 MB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 1
    Persistence : Superblock is persistent
 
    Update Time : Thu Jun  2 06:44:25 2011
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0
 
           UUID : 142686ef:43298491:35faf0c2:7dc468f5
         Events : 0.152
 
    Number   Major   Minor   RaidDevice State
       0       8       18        0      active sync   /dev/sdb2
       1       8       34        1      active sync   /dev/sdc2
 
# mdadm --detail /dev/md2
/dev/md2:
        Version : 00.90
  Creation Time : Mon Sep 24 00:56:01 2007
     Raid Level : raid1
     Array Size : 310126720 (295.76 GiB 317.57 GB)
  Used Dev Size : 310126720 (295.76 GiB 317.57 GB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 2
    Persistence : Superblock is persistent
 
    Update Time : Thu Jun  2 06:45:02 2011
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0
 
           UUID : 9705e4d8:ff326a8a:35faf0c2:7dc468f5
         Events : 0.44426
 
    Number   Major   Minor   RaidDevice State
       0       8       19        0      active sync   /dev/sdb3
       1       8       35        1      active sync   /dev/sdc3

どのHDDからでもブートするようにする(起動に関するgrubの設定)

新しく追加したHDD /dev/sdc の MBR (マスターブートレコード) を grub コマンドにて設定する。

grubコマンドを起動して、こんな内容を入力した。
以前に設定した /dev/sdb とちがうところは、最初の "device (hd0) /dev/sdc" だけ。 /dev/sdb を /dev/sdc にしただけ。他のパラメータは変えなくてよさそう (しかしよくわかっていない…)。


# grub
device (hd0) /dev/sdc
root (hd0,0)
install /grub/stage1 (hd0) /grub/stage2 p /grub/menu.lst
quit

実際の作業ログ。


# grub
Probing devices to guess BIOS drives. This may take a long time.
 
 
    GNU GRUB  version 0.97  (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> device (hd0) /dev/sdc
device (hd0) /dev/sdc
grub> root (hd0,0)
root (hd0,0)
 Filesystem type is ext2fs, partition type 0xfd
grub> install /grub/stage1 (hd0) /grub/stage2 p /grub/menu.lst
install /grub/stage1 (hd0) /grub/stage2 p /grub/menu.lst
grub> quit
quit

mdadm.conf

設定ファイルを眺めてみたり (一部「XXXXXXXX」で伏字)。


# cat /etc/mdadm/mdadm.conf
# mdadm.conf
#
# Please refer to mdadm.conf(5) for information about this file.
#
 
# by default, scan all partitions (/proc/partitions) for MD superblocks.
# alternatively, specify devices to scan, using wildcards if desired.
DEVICE partitions
 
# auto-create devices with Debian standard permissions
CREATE owner=root group=disk mode=0660 auto=yes
 
# automatically tag new arrays as belonging to the local system
HOMEHOST <system>
 
# instruct the monitoring daemon where to send mail alerts
MAILADDR root
 
# definitions of existing MD arrays
ARRAY /dev/md0 level=raid1 num-devices=1 UUID=XXXXXXXX:XXXXXXXX:XXXXXXXX:XXXXXXXX
   spares=1
ARRAY /dev/md1 level=raid1 num-devices=1 UUID=XXXXXXXX:XXXXXXXX:XXXXXXXX:XXXXXXXX
   spares=1
ARRAY /dev/md2 level=raid1 num-devices=1 UUID=XXXXXXXX:XXXXXXXX:XXXXXXXX:XXXXXXXX
   spares=1
 
# This file was auto-generated on Sun, 23 Sep 2007 16:09:18 +0000
# by mkconf $Id: mkconf 261 2006-11-09 13:32:35Z madduck $

参考

今回も Amazon.co.jp: Linux RAID入門: 武田 保真 が非常にわかりやすく参考になった。第6章のHDDの入れ替え方法やmdadmの使い方を参考に。
それにしてもAmazonのレビューを見るとman読めとか英語の資料見ろとかLinuxカーネルソース読めとか・・・いや、それがわかりにくいからこういう本があるのに。入門書ですよ、この本は。。。

-mdadm(8) ver.1.5 man page [日本語]
-ヅラッシュ! - Debian GNU/Linux etch で RAID 1 ミラーリングしてみる

tags: debian linux raid hdd

Posted by NI-Lab. (@nilab)