mdadm: linux metadevice administration (RAID)
setting up raid
- create/choose partition for raid usage; partitions should have the same sizes!
- create partition type 0xfd (Linux raid autodetect) using ''fdisk''
- create the linux raid metadevice (exaple raid-5 using 3 partitions):
- mdadm --create /dev/md0 --level=5 --raid-devices=2 /dev/sda1 /dev/sdb1 /dev/sdc1
- create filesystems on new metadevice:
- check:
- update filesystem tab ''/etc/fstab'':
- ...
- /dev/md0 /path/to/mountpoint ext4 auto,users,noexec 0 0
- ---OR---
- to get the disk UUID of raid device md0 enter:
- UUID=... /path/to/mountpoint ext4 auto,users,noexec,relatime 0 0
- create ''/etc/mdadm/mdadm.conf'':
- cd /etc/mdadm
- echo 'DEVICE /dev/hd*[0-9] /dev/sd*[0-9]' > mdadm.conf
- mdadm --detail --scan >> mdadm.conf
Internal Bitmap
To increase mdraid recovery percormance, enable internal bitmap (only possible when array is synced):
- mdadm -G /dev/md0 --bitmap=internal
Error Recovery
If a disk partition is faulty, you should be able to determine the device using diagnosis commands:
- cat /proc/mdstat
- mdadm --detail /dev/md0
Replace a faulty partition:
- mdadm -r /dev/md0 /dev/sd''XY''
- mdadm -a /dev/md0 /dev/sd''YZ''
- cat /proc/mdstat
# Output example (this one is raid1!):
# Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
# md0 : active raid1 sdb1[1] sda1[0]
# 976759936 blocks [2/1] [_U]
# [==============>......] recovery = 74.2% (725034560/976759936) finish=107.6min speed=38979K/sec
Grow RAID5 volume example
- mdadm --add /dev/md1 /dev/sdf1
- mdadm --grow /dev/md1 --raid-devices=4
Mounting raid from ubuntu live cd
- boot ubuntu desktop live cd
- install mdadm:
- sudo apt-get install mdadm
- detect raid volumes:
- sudo mdadm --assemble --scan
- now, the raid devices can be mounted like every block device:
Links