关于mdadm的一些常见操作
更详细的请参考:参考: https://www.cnblogs.com/lpfuture/p/6385657.html?utm_source=itdadao&utm_medium=referral
查看raid信息
mdadm -D /dev/md0
cat /proc/mdstat
创建软raid
mdadm --create /dev/md0 --level=raid0 --raid-devices=12 /dev/sd[b-m]
停止raid
mdadm -S /dev/md0
停止后启动raid
mdadm -A /dev/md0 /dev/sd[b-m]
添加一块磁盘
mdadm --add /dev/md0 /dev/sdb
移除一块盘
mdadm -r /dev/md0 /dev/sdb
################ 一个制作软raid的脚本 ################
!/bin/bash
function mdadm_init ()
{
umount /dev/md0
mdadm -S /dev/md0
mdadm --zero-superblock /dev/sd[b-m]
}
function block_init ()
{
for i in {b..m};
do
echo "
d
n
t
ee
w
" |fdisk /dev/sd\(i && mkfs.xfs -f /dev/sd\){i}
done
}
function raid ()
{
mdadm --create /dev/md0 --level=raid0 --raid-devices=12 /dev/sd[b-m]
mkfs.xfs -f /dev/md0
echo '' > /etc/mdadm.conf
echo Device /dev/sd[b-m] >> /etc/mdadm.conf
mdadm -Ds >> /etc/mdadm.conf
echo MAILADD root@locahost >> /etc/mdadm.conf
sed -i '/Data2/d' /etc/fstab
echo '/dev/md0 /Data2 xfs defaults 0 0' >> /etc/fstab
mount -a
}
mdadm_init
block_init
raid