Skip to content

Instantly share code, notes, and snippets.

@muse-sisay
Last active August 31, 2021 18:40
Show Gist options
  • Save muse-sisay/33498666d73b959eefea6d99e9fa28ff to your computer and use it in GitHub Desktop.
Save muse-sisay/33498666d73b959eefea6d99e9fa28ff to your computer and use it in GitHub Desktop.
LFCS objective: Create and manage RAID devices

RAID

Redundant Array of Independent Disks

  • A glance at what RAID is. /RAID is not a backup
  • Overview of mdadm command
  • Creating RAID 0 and RAID 5 Array
  • Automounting RAID array at boot

Additional

  • We will look at adding and removing disk from array
  • Removing RAID Array
LEVEL 0 1 5 6
. striping mirroring parity striping double parity
Min. disk required 2 2 3 4
  • RAID 5 supports a single disk failure.
  • RAID 6 supports upto 2 disk failures.

PAGE 2

yum install mdadm

General structure of mdadm command,

mdadm [mode] <raiddevice> [options] <component-devices>

if no mode is specified it will default to --manage. Note that the RAID device comes before component devices.


PAGE 3

(I will be referring to the RAID array as /dev/md0. All commands are run as root user)

  • Create level 0 RAID with 2 active devices and 1 spare
mdadm --create /dev/md0 --level=0 --raid-devices=2 \
      /dev/sdb1 /dev/sdb2 --spare=1 /dev/sdb3

Note : we explicitly specify the number of disks that are going to be used in our array

  • View information on RAID array
mdadm --detail /dev/md0
cat /proc/mdstat
  • Mark a disk faulty
madam /dev/md0 --fail /dev/sdb1
  • Remove disk from array ( should not be active)
mdadm /dev/md0 --remove /dev/sdb1
  • Add spare to array
mdadm /dev/md0 --add /dev/sdb2
  • Save configuration
mdadm --detail --scan >> /etc/mdadm.conf
  • Add RAID array from configuration
mdadm --assemble --scan
  • Remove a RAID array: make sure the drive is unmounted first.
mdam --stop /dev/md0

Then remove the entry from /etc/mdadm.conf

  • Grow RAID ARRAY:
mdadm --add /dev/md0 /dev/sdb2
mdadm --grow /dev/md0 --raid-devices=4  

PAGE 4

Shortcut discussed

Vim shortcut we discussed :

  • : set nu or : set number to show line number
  • LINE + G or : LINE to jump to LINE
  • $ to move to end of line
  • gg to move to the end of a file
  • G to move to the start of a file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment