Mdadm
From TheBeard Science Project Wiki
mdadm: PREPARE DRIVES: fdisk /dev/sdb n - new p - primary partition w - write (repeat for each drive) LARGER THAN 2TB PARTITIONS: parted /dev/sdb mklabel gpt - create GPT partition table instead of msdos unit tb - make default units in TB mkpart primary 0 3 - create the partition on whole disk (0 3 is 'start' and 'end' in TB) print - print partition info CREATE RAID: mdadm --create --verbose /dev/md0 --level=0 --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1 - creates raid-0 on /dev/md0 from the 3 devices mdadm -C -v /dev/md0 -l 0 -n 3 /dev/sdb1 /dev/sdc1 /dev/sdd1 - short version PARAMETERS: --name <name> - give the array a name. --force - force the operation. can be used to create a raid with a single drive to recover data. SAVE CONFIGURATION: mdadm --detail --scan >> /etc/mdadm/mdadm.conf (ubuntu) mdadm --detail --scan >> /etc/mdadm.conf (other distributions) update-initramfs -u - saves md config to init. (this allows the correct dev name to be used instead of md127) CHECKING: cat /proc/mdstat mdadm --detail /dev/md0 - show details of raid. shows progress of data being rebuilt mdadm --monitor --mail=admin@example.com --delay=1800 /dev/md0 - email status (delay in seconds) mdadm --examine /dev/sdb1 - examine details of drive MANAGING: mdadm --stop /dev/md0 mdadm --assemble /dev/md0 /dev/sdb1 /dev/sdc1 - start raid with these devices mdadm --assemble --scan - start all stopped raid REMOVE RAID: umount /dev/md0 mdadm --stop /dev/md0 mdadm --zero-superblock /dev/sdb1 mdadm --zero-superblock /dev/sdc1 (remember to remove line from fstab) REMOVE DRIVE: umount /dev/md0 mdadm /dev/md0 --fail /dev/sdc1 mdadm /dev/md0 --remove /dev/sdc1 REBUILD: mdadm /dev/md0 --add /dev/sdd1 - add drive to array. drive must be partitioned just like the original. Data will then be rebuilt. mkfs: mkfs -t ext4 -L LABEL /dev/md0 - creates filesystem on raid device