Software Raid

Create raid:

Raid levels can be changed with: --level=1 // --level=0 // --level=5

Raid 1

mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdX /dev/sdX

Raid 5

mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sdX /dev/sdX /dev/sdX

Raid 6

mdadm --create --verbose /dev/md0 --level=6 --raid-devices=4 /dev/sda /dev/sdX /dev/sdX /dev/sdX

Raid 10

mdadm --create --verbose /dev/md0 --level=10 --layout=o3 --raid-devices=4 /dev/sdX /dev/sdX /dev/sdX /dev/sdX

Stop raid:

mdadm --stop /dev/md0

Assemble raid:

mdadm -A /dev/mdX /dev/sdaX --run
Adding a drive in a failed raid:
mdadm --manage /dev/md0 --add /dev/sdb1
Resize drives after a HDD swap to something larger
resize2fs `mount | grep "on / " | cut -d " " -f 1` && exit

Then check with "watch df -h" and watch it go up

Cloning a partition table


X = Source (old drive), Y = Destination (new drive)

sfdisk -d /dev/sdX | sfdisk /dev/sdY --force

Install gdisk 

The first command copies the partition table of sdX to sdY

sgdisk -R /dev/sdY /dev/sdX
sgdisk -G /dev/sdY