You are on page 1of 2

Note: All of my tutorials are impromptu and performed while dodging between open

rooms and finding less noisy places to sit. I may say the wrong thing several t
imes during the tutorial, but hopefully it will still be helpful. :o)
Steps:
1) Make the blank dd disk images
2) losetup the disks
3) Create the RAID
4) Create the NEW partition
5) Format the new partition
6) Make the new directory Mount Point
7) Mount the partition
8) df -h (show your work)
Open a root Shell:
sudo -s
Change directory to /tmp
cd /tmp
ls -lh
Create the Fake
dd if=/dev/zero
dd if=/dev/zero
dd if=/dev/zero

Drives:
of=./disk0.img bs=1M count=100
of=./disk1.img bs=1M count=100
of=./disk2.img bs=1M count=100

Assign the Fake Drives to Devices:


losetup /dev/loop0 disk0.img
losetup /dev/loop1 disk1.img
losetup /dev/loop2 disk2.img
Create a RAID 5 Array:
# If needed: sudo apt-get install mdadm
mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/loop0 /dev/loo
p1 /dev/loop2
Shorter RAID 1 command: mdadm -C -v /dev/md0 -l 1 -n 2 /dev/loop0 /dev/loop1
View the Array:
mdadm --detail /dev/md0
Partition the Array:
fdisk /dev/md0
# 1 Partition, all space, active
fdisk -l /dev/md0
Format the Array:
# Notice the p1 after the md0 (p1 = partition 1)
mkfs.ext4 -L RAID5 /dev/md0p1
Create a mount point for the RAID Array
mkdir /mnt/database
ll /mnt/database/
Mount the Array:
mount /dev/md0p1 /mnt/database
View the "Disk Free" for the Array:

df -h
Create a log file on the Array:
mdadm --detail /dev/md0 | tee /mnt/database/1-RAID_Working.log
Fail a Drive:
mdadm /dev/md0 --fail /dev/loop0
Create a log file on the Array:
mdadm --detail /dev/md0 | tee /mnt/database/2-RAID_Fail_loop0.log
View the directory contents:
ls -lha /mnt/database
View the File Contents:
cat /mnt/database/*.log
Remove the Failed Drive:
mdadm /dev/md0 --remove /dev/loop0
Create a log file on the Array:
mdadm --detail /dev/md0 | tee /mnt/database/3-RAID_Remove_loop0.log
Re-Add the Failed Drive:
mdadm /dev/md0 -a /dev/loop0
Create a log file on the Array:
mdadm --detail /dev/md0 | tee /mnt/database/4-RAID_Re-add_loop0.log
Remove the Mount Point, Array, Devices, and Disk Files:
umount /mnt/database
rm -rf /mnt/database
df -h
mdadm
mdadm
mdadm
mdadm

--detail /dev/md0
--stop /dev/md0
--remove /dev/md0
--detail /dev/md0

losetup -d /dev/loop0
( -d deatached loop0)
losetup -d /dev/loop1
losetup -d /dev/loop2 ARCHIVE - This will be replaced by new videos in 2015.
rm -f disk*.img

You might also like