分享

Useful Mdadm Commands | Excalibur Partners, LLC | IT Consulting

 豆芽爱尚阅 2016-01-09

Below is a collection of commands for mdadm that I have found useful. Use these at your own risk.

Create RAID

mdadm --create /dev/md0 --level=5 --raid-devices=4 /dev/sd[bcde]1
mkfs.ext3 /dev/md0

Remove disk from RAID

mdadm --fail /dev/md0 /dev/sda1
mdadm --remove /dev/md0 /dev/sda1

Copy the partition structure (when replacing a failed drive)

sfdisk -d /dev/sda | sfdisk /dev/sdb 
mdadm --zero-superblock /dev/sdb

Force the kernel to reread the partition table

partprobe

Add a disk to a RAID array (to replace a removed failed drive)

mdadm --add /dev/md0 /dev/sdf1

Check RAID status

cat /proc/mdstat
mdadm --detail /dev/md0

Reassemble a group of RAID disks

mdadm --assemble /dev/md0 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1

Steps to emulate mdrun (which has been depreciated)

mdadm --examine --scan --config=partitions > /tmp/mdadm.conf
mdadm --assemble --scan --config=/tmp/mdadm.conf

Convert a RAID 1 array to RAID 5 (follow the steps to add a disk after running this command)

mdadm --create /dev/md0 --level=5 -n 2 /dev/sda1 /dev/sdb1

Add a disk to an existing RAID and resize the filesystem

mdadm --add /dev/md0 /dev/sdg1
mdadm --grow /dev/md0 -n 5
fsck.ext3 -f /dev/md0
resize2fs /dev/md0

Stop and remove the RAID device

mdadm --stop /dev/md0
mdadm --remove /dev/md0

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多