Difference between revisions of "Mdadm"
From Briki
(→Creating a RAID array) |
|||
Line 35: | Line 35: | ||
mdadm --assemble /dev/md0 /dev/sdX1 /dev/sdY1 /dev/sdZ1 | mdadm --assemble /dev/md0 /dev/sdX1 /dev/sdY1 /dev/sdZ1 | ||
</pre> | </pre> | ||
+ | |||
+ | * From this point, just treat the array (/dev/md0) as a normal physical disk. | ||
== Useful Commands == | == Useful Commands == |
Revision as of 13:20, 19 April 2016
Overview
Several physical disks (/dev/sdX) or partitions (/dev/sdX1) of equal size are joined into a single array.
Creating a RAID array
- (Recommended) Create a partition on each disk with the following attributes:
- Use the "GPT" partition table format (to handle disks > 2TB)
- Use optimal alignment for partition start (this will normally mean that the partition start will be at the 1MB boundary)
- End 100MB before the end of the disk (this is to allow for slight variances in exact size of similar disks)
- Set partition type to raid (0xFD00); this is optional, but may encourage some tools to avoid writing directly to the disk (and avoid corrupting the array)
parted -a optimal -- /dev/sdX mklabel gpt mkpart primary 0MB -100MB set 1 raid on
- Create a RAID 5 array over 3 partitions:
- Note, the default metadata version is now 1.2 for create commands
mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdX1 /dev/sdY1 /dev/sdZ1
- Wait (potentially several days) for the array to be built
- Once built, save the current raid setup to /etc, to allow for automounting on startup:
mdadm --detail --scan >> /etc/mdadm/mdadm.conf
- Update the initial boot image for all current kernel versions to include the new mdadm.conf:
update-initramfs -u -k all
- Start the array:
mdadm --assemble /dev/md0 /dev/sdX1 /dev/sdY1 /dev/sdZ1
- From this point, just treat the array (/dev/md0) as a normal physical disk.
Useful Commands
- cat /proc/mdstat
- Display a summary of current raid status
- mdadm --detail /dev/md0
- Display raid information on array md0
- mdadm --examine /dev/sdf
- Display raid information on device/partition sdf