Show Menu

Linux RAID with mdadm Cheat Sheet by

redundant array of independent disks
linux     server     sysadmin     data     cs     datascience     disk     raid     mdadm     hdd

RAID Levels

RAID 0
Stri­pes data evenly across two or more disks.
RAID 1
Mirr­ors data on two or more disks.
RAID 2
Rarely used, Bit-level striping with Hamming code for error correc­tion.
RAID 3
Rarely used, byte-level striping with a dedicated parity.
RAID 4
Block-­level striping with dedi­cated parity.
RAID 5
Block-­level striping with dist­ributed parity.
RAID 6
Block-­level striping with double distri­buted parity.

Nested RAID Levels

Number
Desc­rip­tion
Efficiency
RAID 01
Block-­level striping, and mirroring without parity
1/stripes
RAID 10
Mirroring without parity, and block-­level striping
stripes/n
RAID 50
Block-­level striping with distri­buted parity, and block-­level striping
(1-str­ipes)/n
RAID 60
Block-­level striping with double distri­buted parity, and block-­level striping
(1-2*s­tri­pes)/n
 

Formatting Disks for Use with mdadm

DISC­LAIMER: PROCEED WITH CAUTION.
MAKE SURE YOU KNOW WHAT DISK YOU ARE OPERATING ON. IT IS VERY EASY TO DO IRREVO­CABLE DAMAGE TO YOUR SYSTEM IF YOU DON'T.
0. Figure out disk location in the file system:
lsblk -o name,s­ize­,fs­typ­e,t­ype­,mo­unt­point
1. Formatting with fdisk
sudo fdisk /dev/sdx
2. Navigatng fdisk: just press the following keys when promted to create new linux RAID type primary partition
n, p, 1, Enter, Enter, t, fd, w
3. Repeat steps 1 and 2 for each disk that will be included in new array
sudo fdisk /dev/sdy
n, p, 1, Enter, Enter, t, fd, w

Creating RAID arrays

Create a mirrored array
mdadm --create /dev/md0 --level=1 /dev/sdx1 /dev/sdy1

Assembling RAID arrays

Assemble an existing array
mdadm --assemble /dev/md0 /dev/sdx1 /dev/sdy1
mdadm --scan --assemble --uuid=<UUID>

Resetting Existing RAID Devices

Find the active arrays
cat /proc/­mdstat
Unmount the array
sudo umount /dev/md0
Stop and remove the array
mdadm --stop /dev/md0
mdadm --remove /dev/md0
Find the devices used to build the array
lsblk -o name,f­sty­pe,­mou­ntp­oint
Zero out the respective superb­locks
sudo mdadm --zero­-su­per­block /dev/sdx
sudo mdadm --zero­-su­per­block /dev/sdy
Remove persistent references to the array
sudo nano /etc/f­stab
Comment out or remove the reference to the array.
# /dev/md0 /mnt/md0 ext4 defaults,nofail,discard 0 0
In /etc/­mda­dm/­mda­dm.c­onf comment out or remove the array reference
sudo nano /etc/m­dad­m/m­dad­m.conf
Comment out the reference
# ARRAY /dev/md0 metada­ta=1.2 name=m­dad­mwr­ite:0 UUID=xxxx

Download the Linux RAID with mdadm Cheat Sheet

1 Page
//media.cheatography.com/storage/thumb/drapja_linux-raid-with-mdadm.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Linux Command Line Cheat Sheet
          mod_rewrite Cheat Sheet
          Selenium WebDriver Cheat Sheet Cheat Sheet

          More Cheat Sheets by drapja