## make equal partitions on two different hard disks with parted
NOTE: don't put a filesystem on these drives
## create raid 0 - just as lvm it will combine drives
mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/sdb5 /dev/sdc5
mke2fs -t ext4 -j /dev/md0
mkdir /raid0 && mount /dev/md0 /raid0
## create raid 1 (data mirroring) half of storage
mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sdb6 /dev/sdc6
mke2fs -t ext4 -j /dev/md1
mkdir /raid1 && mount /dev/md1 /raid1 && echo $?
## create raid 5 (data striping with parity) sacrifice of 1 disk or partition space
mdadm --create /dev/md2 --level=5 --raid-devices=4 /dev/sdb7 /dev/sdb8 /dev/sdc7 /dev/sdc8
mke2fs -t ext4 -j /dev/md2
mkdir /raid5 && mount /dev/md2 /raid5 && echo $?
##raid entries in /etc/fstab
/dev/md0 /raid0 ext4 defaults,usrquota,grpquota 1 2
/dev/md1 /raid1 ext4 defaults,usrquota,grpquota 1 2
/dev/md2 /raid5 ext4 defaults,usrquota,grpquota 1 2
## Raid Management
/etc/mdadm.conf
cat /proc/mdstat
mdadm --query /dev/md0 | /dev/md[0-2]
## to make raid read only
umount /dev/md0
mdadm -v -w /dev/md0 - write
mdadm -v -o /dev/md0 - read only
mount /dev/md0 /raid0
mount
## to stop raid for management
umount /dev/raid0
mdadm --manage --stop /dev/md0
## multiple ways to reassemble it again
1. command level reassembling
mdadm -A /dev/md0 /dev/sdb5 /dev/sdc5
mount /dev/md0 /raid0
2. /etc/mdadm.conf level reassembling
nano /etc/mdadm.conf
##add below lines
DEVICE /dev/sdb[5-8] /dev/sdc[5678]
ARRAY /dev/md0 devices=/dev/sdb5,/dev/sdc5
##run command below
mdadm -A /dev/md0
## to check details about raid
mdadm -D /dev/md0
mdadm -E /dev/sd[bc][78]
NOTE: don't put a filesystem on these drives
## create raid 0 - just as lvm it will combine drives
mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/sdb5 /dev/sdc5
mke2fs -t ext4 -j /dev/md0
mkdir /raid0 && mount /dev/md0 /raid0
## create raid 1 (data mirroring) half of storage
mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sdb6 /dev/sdc6
mke2fs -t ext4 -j /dev/md1
mkdir /raid1 && mount /dev/md1 /raid1 && echo $?
## create raid 5 (data striping with parity) sacrifice of 1 disk or partition space
mdadm --create /dev/md2 --level=5 --raid-devices=4 /dev/sdb7 /dev/sdb8 /dev/sdc7 /dev/sdc8
mke2fs -t ext4 -j /dev/md2
mkdir /raid5 && mount /dev/md2 /raid5 && echo $?
##raid entries in /etc/fstab
/dev/md0 /raid0 ext4 defaults,usrquota,grpquota 1 2
/dev/md1 /raid1 ext4 defaults,usrquota,grpquota 1 2
/dev/md2 /raid5 ext4 defaults,usrquota,grpquota 1 2
## Raid Management
/etc/mdadm.conf
cat /proc/mdstat
mdadm --query /dev/md0 | /dev/md[0-2]
## to make raid read only
umount /dev/md0
mdadm -v -w /dev/md0 - write
mdadm -v -o /dev/md0 - read only
mount /dev/md0 /raid0
mount
## to stop raid for management
umount /dev/raid0
mdadm --manage --stop /dev/md0
## multiple ways to reassemble it again
1. command level reassembling
mdadm -A /dev/md0 /dev/sdb5 /dev/sdc5
mount /dev/md0 /raid0
2. /etc/mdadm.conf level reassembling
nano /etc/mdadm.conf
##add below lines
DEVICE /dev/sdb[5-8] /dev/sdc[5678]
ARRAY /dev/md0 devices=/dev/sdb5,/dev/sdc5
##run command below
mdadm -A /dev/md0
## to check details about raid
mdadm -D /dev/md0
mdadm -E /dev/sd[bc][78]
No comments:
Post a Comment