Monday, 5 December 2011

setup RAID1

1. Install mdadm

Type the following command under RHEL / CentOS / Fedora Linux:
root@server:~# yum install mdadm

Type the following command under Debian / Ubuntu Linux:
root@server:~# apt-get update && apt-get install mdadm

2. root@server:~# fdisk /dev/sda

3. root@server:~# fdisk /dev/sdb

4. If the device contains a valid md superblock, the block is overwritten with zeros:

root@server:~# mdadm --zero-superblock /dev/sda /dev/sdb

5. Create RAID1 using /dev/sda1 and /dev/sdb1

root@server:~# mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1

6. Format /dev/md0 as ext4:

root@server:~# mkfs.ext4 /dev/md0

7. Mount /dev/md0

root@server:~# mkdir /raid1
root@server:~# mount /dev/md0 /raid1
root@server:~# df -H

8. Edit /etc/fstab

Make sure RAID1 get mounted automatically. Edit /etc/fstab and append the following line:

/dev/md0 /raid1 ext3 noatime,rw 0 0

Save and close the file.

9. How Do I See RAID Array Building Progress and Current Status?

Type the following command:
root@server:~# watch -n 2 cat /proc/mdstat


root@server:~# tail -f /proc/mdstat

10. How Do I Get Information On Existing Array?

Type the following command
root@server:~# mdadm --query /dev/md0

11. How to get the raid details?

root@server:~# mdadm --detail /dev/md0
root@server:~# mdadm -D /dev/md0

12. How to remove a raid drive?

First fail the drive and then remove the raid drive
root@server:~# mdadm --manage /dev/md0 --fail /dev/sdb1
root@server:~# mdadm --manage /dev/md0 --remove /dev/sdb1

13. How to add a raid drive?
root@server:~# mdadm --manage /dev/md0 --add /dev/sdb1

No comments:

Post a Comment