Wednesday, March 23, 2016

setup software raid on linux

mdadm is used to manage MD devices aka Linux Software RAID.

1- installation
$ sudo apt-get install mdadm

2- create raid 1 from sdc and sdd, you also can create raid device from partition, it is not necessary use the whole disk.
$ sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdc /dev/sdd

3- create file system for the newly created raid device
$ sudo mkfs.ext4 /dev/md0
$ sudo mount /dev/md0 /mnt

4 verifying
- show disk information
$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            2.0G  4.0K  2.0G   1% /dev
tmpfs           394M  996K  394M   1% /run
/dev/sda1       196G  8.1G  178G   5% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            5.0M     0  5.0M   0% /run/lock
none            2.0G     0  2.0G   0% /run/shm
none            100M     0  100M   0% /run/user
/dev/md0         20G   44M   19G   1% /mnt



- show raid device information

$ sudo mdadm -D /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Wed Mar 23 10:38:48 2016
     Raid Level : raid1
     Array Size : 20955008 (19.98 GiB 21.46 GB)
  Used Dev Size : 20955008 (19.98 GiB 21.46 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Wed Mar 23 10:43:43 2016
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           Name : ubuntu:0  (local to host ubuntu)
           UUID : 76b4a696:681a79b5:4e6b7b65:626a5070
         Events : 19

    Number   Major   Minor   RaidDevice State
       0       8       32        0      active sync   /dev/sdc
       1       8       48        1      active sync   /dev/sdd

No comments:

Post a Comment