Mdadm
Jump to navigation
Jump to search
Notes on mdadm
DISK_DIR=/var/tmp/disks mkdir -p ${DISK_DIR} for i in $( seq 1 9 ); do dd if=/dev/zero of=${DISK_DIR}/disk${i} bs=100M count=1 [ ! -f /dev/loop${i} ] && mknod -m 660 /dev/loop${i} b 7 ${i} losetup /dev/loop${i} ${DISK_DIR}/disk${i} done
Create raid0 device
# mdadm --create /dev/md0 --level raid0 -n 2 /dev/loop[1-2]
Create raid1 with one spare
# mdadm --create /dev/md1 --level raid1 -n 2 -x 1 /dev/loop[3-5]
Create raid5 with one spare
# mdadm --create /dev/md5 --level raid5 -n 3 -x 1 /dev/loop[6-9]
Check the status
# cat /proc/mdstat Personalities : [raid6] [raid5] [raid4] [raid0] [raid1] md5 : active raid5 loop8[2] loop9[3](S) loop7[1] loop6[0] 204672 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU] md0 : active raid0 loop2[1] loop1[0] 204672 blocks 64k chunks md1 : active raid1 loop5[2](S) loop4[1] loop3[0] 102336 blocks [2/2] [UU] unused devices: <none>