YANO's digital garage

Copyright ©YANO All rights reserved. https://www.bravotouring.com/~yano/

Last-modified: 2021-07-08 (木)


[一語一絵/IT系]

mdadmとRAID5 / 2017-07-18 (火)

先週書いたIntel NUCのNICが落ちてしまう件。

懸案だった記憶域プール/スペースの問題はUSB3.0ハブで解消したのだが、結局Intel NUCにサーバ運用は荷が重過ぎると判断し、4SATA HDD はい~るKit Super Turbo 3は素直にgt110bのUSB接続に戻す事に。

折角3TB×4構成なのでmdadmでRaid構築を再確認。まずは普通にpartedで各ドライブに区画を切る。形式は最近のお約束xfsにしておこう。

root@GT110b:~# mdadm --zero-superblock /dev/sde
root@GT110b:~# parted /dev/sde
GNU Parted 2.3
Using /dev/sde
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
Warning: The existing disk label on /dev/sde will be destroyed and all data on this disk will be lost. Do you want to
continue?
Yes/No? yes
(parted) p
Model: JMicron Generic DISK00 (scsi)
Disk /dev/sde: 3001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt

Number  Start  End  Size  File system  Name  Flags

(parted) unit GB
(parted) mkpart DISK00 xfs 1 -1
(parted) set 1 raid on
(parted) unit s
(parted) p
Model: JMicron Generic DISK00 (scsi)
Disk /dev/sde: 5860533168s
Sector size (logical/physical): 512B/4096B
Partition Table: gpt

Number  Start  End          Size         File system  Name    Flags
1      2048s  5860532223s  5860530176s  xfs          DISK00  raid

(parted) q
Information: You may need to update /etc/fstab.

root@GT110b:~# mkfs.xfs -f /dev/sde1
meta-data=/dev/sde1              isize=256    agcount=32, agsize=22892696 blks
         =                       sectsz=4096  attr=2, projid32bit=0
data     =                       bsize=4096   blocks=732566272, imaxpct=5
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0
log      =internal log           bsize=4096   blocks=357698, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
root@GT110b:~#
/dev/sdf~sdhに対しても同じくmdadmpartedmkfs.xfsを実施。

Raid5の/dev/md0を作成。

root@GT110b:~# mdadm --create /dev/md0 --level=5 --raid-devices=4 /dev/sde /dev/sdf /dev/sdg /dev/sdh
mdadm: /dev/sde appears to be part of a raid array:
    level=raid0 devices=0 ctime=Thu Jan  1 09:00:00 1970
mdadm: partition table exists on /dev/sde but will be lost or
       meaningless after creating array
mdadm: /dev/sdf appears to be part of a raid array:
    level=raid0 devices=0 ctime=Thu Jan  1 09:00:00 1970
mdadm: partition table exists on /dev/sdf but will be lost or
       meaningless after creating array
mdadm: /dev/sdg appears to be part of a raid array:
    level=raid0 devices=0 ctime=Thu Jan  1 09:00:00 1970
mdadm: partition table exists on /dev/sdg but will be lost or
       meaningless after creating array
mdadm: /dev/sdh appears to be part of a raid array:
    level=raid0 devices=0 ctime=Thu Jan  1 09:00:00 1970
mdadm: partition table exists on /dev/sdh but will be lost or
       meaningless after creating array
Continue creating array? yes
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
root@GT110b:~#
で…
root@GT110b:~# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md0 : active raid5 sdh[4] sdg[2] sdf[1] sde[0]
      8790405120 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/3] [UUU_]
      [>....................]  recovery =  0.0% (363264/2930135040) finish=672.0min speed=72652K/sec

unused devices: <none>
root@GT110b:~#
となれば、ひと安心。あとは672分後に無事recovery動作が終るのを祈るだけだ。

再起動時のケアは

root@GT110b:~# mdadm --detail --scan >> /etc/mdadm/mdadm.conf
root@GT110b:~# update-initramfs -u
update-initramfs: Generating /boot/initrd.img-3.13.0-125-generic
root@GT110b:~#
でいいはずなのだが、再起動すると /dev/md0 ではなく /dev/md127 になってしまうトラップ発生。

結局、/etc/mdadm/mdadm.confに含まれるname指定を削除する、が正解。

# ARRAY /dev/md0 metadata=1.2 spares=1 name=GT110b:0 UUID=81328295:5f1fa0c2:b3535462:79680794
ARRAY /dev/md0 metadata=1.2 spares=1 UUID=81328295:5f1fa0c2:b3535462:79680794

【参照】
●株式会社ノバック http://www.novac.co.jp/
4SATA HDD はい~るKit Super Turbo 3
●Wikipedia https://ja.wikipedia.org/wiki/
RAID
論理ボリュームマネージャ