前提
- 既に /dev/hdb 側で RAID1 が構成されており、/dev/md0, /dev/md1, /dev/md2 が動作していること。
- root 権限で操作できること。
7 /dev/hda の準備
まず df -h で /dev/md0 と /dev/md2 が存在することを確認します。
df -h
[root@server1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/md2 4.4G 757M 3.4G 18% /
/dev/md0 167M 9.0M 150M 6% /boot
[root@server1 ~]#
/ proc/mdstat の内容も確認します。
cat /proc/mdstat
[root@server1 ~]# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 hdb5[1]
417536 blocks [2/1] [_U]
md0 : active raid1 hdb1[1]
176576 blocks [2/1] [_U]
md2 : active raid1 hdb6[1]
4642688 blocks [2/1] [_U]
unused devices:
[root@server1 ~]#
次に /dev/hda 上の該当パーティション(1,5,6)のタイプを Linux raid autodetect に変更します。
fdisk /dev/hda
[root@server1 ~]# fdisk /dev/hda
Command (m for help): <-- t
Partition number (1-6): <-- 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-6): <-- 5
Hex code (type L to list codes): <-- fd
Changed system type of partition 5 to fd (Linux raid autodetect)
Command (m for help): <-- t
Partition number (1-6): <-- 6
Hex code (type L to list codes): <-- fd
Changed system type of partition 6 to fd (Linux raid autodetect)
Command (m for help): <-- w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@server1 ~]#
パーティションタイプを変更したら、各パーティションを対応する RAID アレイに追加します。
mdadm --add /dev/md0 /dev/hda1
mdadm --add /dev/md1 /dev/hda5
mdadm --add /dev/md2 /dev/hda6
追加後、/proc/mdstat を監視して同期の進行を確認します。
cat /proc/mdstat
同期中の一例:
[root@server1 ~]# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 hda5[2] hdb5[1]
417536 blocks [2/1] [_U]
resync=DELAYED
md0 : active raid1 hda1[0] hdb1[1]
176576 blocks [2/2] [UU]
md2 : active raid1 hda6[2] hdb6[1]
4642688 blocks [2/1] [_U]
[======>..............] recovery = 34.4% (1597504/4642688) finish=1.0min speed=50349K/sec
unused devices:
[root@server1 ~]#
継続的に表示するには watch を使います。終了するには CTRL+C を押します。
watch cat /proc/mdstat
同期が完了すると以下のようになります。
[root@server1 ~]# cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 hda5[0] hdb5[1]
417536 blocks [2/2] [UU]
md0 : active raid1 hda1[0] hdb1[1]
176576 blocks [2/2] [UU]
md2 : active raid1 hda6[0] hdb6[1]
4642688 blocks [2/2] [UU]
unused devices:
[root@server1 ~]#
同期完了後、mdadm の設定ファイルを現状に合わせて更新します。
cp -f /etc/mdadm.conf_orig /etc/mdadm.conf
mdadm --examine --scan >> /etc/mdadm.conf
/ etc/mdadm.conf の例(コメントや説明を含む完全内容):
# mdadm configuration file
#
# mdadm will function properly without the use of a configuration file,
# but this file is useful for keeping track of arrays and member disks.
# In general, a mdadm.conf file is created, and updated, after arrays
# are created. This is the opposite behavior of /etc/raidtab which is
# created prior to array construction.
#
#
# the config file takes two types of lines:
#
# DEVICE lines specify a list of devices of where to look for
# potential member disks
#
# ARRAY lines specify information about how to identify arrays so
# so that they can be activated
#
# You can have more than one device line and use wild cards. The first
# example includes SCSI the first partition of SCSI disks /dev/sdb,
# /dev/sdc, /dev/sdd, /dev/sdj, /dev/sdk, and /dev/sdl. The second
# line looks for array slices on IDE disks.
#
#DEVICE /dev/sd[bcdjkl]1
#DEVICE /dev/hda1 /dev/hdb1
#
# If you mount devfs on /dev, then a suitable way to list all devices is:
#DEVICE /dev/discs/*/*
#
#
#
# ARRAY lines specify an array to assemble and a method of identification.
# Arrays can currently be identified by using a UUID, superblock minor number,
# or a listing of devices.
#
# super-minor is usually the minor number of the metadevice
# UUID is the Universally Unique Identifier for the array
# Each can be obtained using
#
# mdadm -D
#
#ARRAY /dev/md0 UUID=3aaa0122:29827cfa:5331ad66:ca767371
#ARRAY /dev/md1 super-minor=1
#ARRAY /dev/md2 devices=/dev/hda1,/dev/hdb1
#
# ARRAY lines can also specify a "spare-group" for each array. mdadm --monitor
# will then move a spare between arrays in a spare-group if one array has a failed
# drive but no spare
#ARRAY /dev/md4 uuid=b23f3c6d:aec43a9f:fd65db85:369432df spare-group=group1
#ARRAY /dev/md5 uuid=19464854:03f71b1b:e0df2edd:246cc977 spare-group=group1
#
# When used in --follow (aka --monitor) mode, mdadm needs a
# mail address and/or a program. This can be given with "mailaddr"
# and "program" lines to that monitoring can be started using
# mdadm --follow --scan & echo $! > /var/run/mdadm
# If the lines are not found, mdadm will exit quietly
#MAILADDR [email protected]
#PROGRAM /usr/sbin/handle-mdadm-events
ARRAY /dev/md0 level=raid1 num-devices=2 UUID=6b4f013f:6fe18719:5904a9bd:70e9cee6
ARRAY /dev/md1 level=raid1 num-devices=2 UUID=63194e2e:c656857a:3237a906:0616f49e
ARRAY /dev/md2 level=raid1 num-devices=2 UUID=edec7105:62700dc0:643e9917:176563a7
8 GRUB の準備(パート2)
システムが /dev/hdb 側から起動する設定 (hd1,0) になっている場合、/dev/hda(hd0)からも起動できるよう GRUB の最初の kernel スタンザをコピーして hd1 を hd0 に置き換え、他の不要なスタンザはコメントアウトします。
vi /boot/grub/menu.lst
menu.lst の例:
timeout 10
color black/cyan yellow/cyan
default 0
fallback 1
title linux
kernel (hd1,0)/vmlinuz BOOT_IMAGE=linux root=/dev/md2 resume=/dev/md1
initrd (hd1,0)/initrd.img
title linux
kernel (hd0,0)/vmlinuz BOOT_IMAGE=linux root=/dev/md2 resume=/dev/md1
initrd (hd0,0)/initrd.img
#title linux
#kernel (hd0,0)/vmlinuz BOOT_IMAGE=linux root=/dev/hda6 resume=/dev/hda5
#initrd (hd0,0)/initrd.img
#title failsafe
#kernel (hd0,0)/vmlinuz BOOT_IMAGE=failsafe root=/dev/hda6 failsafe
#initrd (hd0,0)/initrd.img
編集後、ramdisk を更新してから再起動します。
mv /boot/initrd-`uname -r`.img /boot/initrd-`uname -r`.img_orig2
mkinitrd /boot/initrd-`uname -r`.img `uname -r`
reboot
再起動後、問題なく起動すれば完了です。これで稼働中の Mandriva 2008.0 システムでソフトウェア RAID1 を正常に移行できました。
受け入れ基準
- /proc/mdstat に md0/md1/md2 が [UU] で表示されること。
- /etc/mdadm.conf に現在の配列情報が含まれていること。
- GRUB が hd0 でも起動するエントリを持ち、システムが再起動して正しくブートすること。
役割別チェックリスト
- システム管理者:
- /proc/mdstat の確認、fdisk でパーティションタイプ変更、mdadm で追加、mdadm.conf 更新。
- 運用担当:
- 再起動時間の調整、監視アラート設定(mdadm –monitor)、障害ロールバック手順の確認。
- テスト担当:
- GRUB 設定を検証し、片方のディスクを一時的に外して起動確認を実施。
コマンドチートシート
- 状態確認: df -h; cat /proc/mdstat
- パーティション編集: fdisk /dev/hda
- RAID 追加: mdadm –add /dev/mdX /dev/hdaY
- 設定保存: mdadm –examine –scan >> /etc/mdadm.conf
- initrd 再作成: mkinitrd /boot/initrd-
uname -r
.imguname -r
よくあるトラブルと対処(いつ失敗するか)
- 同期が進まない: ケーブルやデバイス認識を確認。dmesg をチェックし、ディスク I/O エラーがないか確認する。
- fdisk の変更が反映されない: パーティションテーブル再読み込み時にプロセスがブロックしている可能性。システムを再起動して反映を確認するか、partprobe を試す。
- GRUB が hd0 で起動しない: menu.lst のパスとデバイス指定が正しいか、/boot のファイルが hda に存在するか確認する。
- mdadm.conf に古い UUID が残る: 既存の設定をバックアップしてから再生成し、不要行を手動で削除する。
用語集(1行)
- mdadm: Linux のソフトウェア RAID 管理ツール。md デバイスの作成・管理を行う。
- initrd: カーネル起動時に使用される初期 RAM ディスク。
要約
- /dev/hda のパーティションタイプを fd に設定し、mdadm で配列に追加する。同期完了を待つ。
- /etc/mdadm.conf を更新して配列情報を保存する。
- GRUB を hd0 でも起動できるように編集し、initrd を再生成して再起動する。
重要: 実稼働で操作する前に必ず設定ファイルのバックアップを取り、メンテナンス時間内に作業してください。
著者
編集