Personal blog for expressing my experiences

Technology

Creating/Deleting Software RAID-1 using mdadm

`mdadm` – manage MD devices aka Linux Software Raid (directly from `man` pages)

1. Finding out the RAID arrays (md0, md1, etc..). In all the below examples I have taken `md0` as the RAID array.

[root@library-server ~]#fdisk -l

2. Querying the arrays to find the disks it holds,

[root@library-server ~]#mdadm – -detail /dev/md0

3. Shutting the desired array,

[root@library-server ~]# mdadm – -stop /dev/md0

4. Zeroing the superblock for each drive,

[root@library-server ~]# mdadm – -zero-superblock /dev/sdX (or hdX)

5. Creating the new array,

[root@library-server ~]#mdadm – -create /dev/md0 – -chunk=4 – -level=0 – -raid-devices=2 /dev/sda1 /dev/sdb1

where sda1 and sdb1 are the partitions. The above command will create a raid0 array /dev/md0 formed from /dev/sda1 and /dev/sdb1, with chunk size 4.

6. Create an ext3 filesystem on /dev/md0,

[root@library-server ~]#mkfs.ext3 /dev/md0

Mount this partition and you are ready to push in your data. This above method worked for me. Hope this helps.

Oops, forgot to include one line in /etc/mdadm/mdadm.conf,

ARRAY /dev/md0 devices=/dev/sda1,/dev/sdb1

where `md0` – array defined and `sda1`, `sdb1` are the hard disk partitions from where the array is created. Restart the `mdadm` service.

1 Comment

  1. Aswin M. Sahadevan

    kudos! for writing this, but I fear this procedure might get obsolete.. I took your advice and used Ubuntu server 8.04 and the Software RAID option during installation is plain awesome! Ubuntu server FTW!

Leave a Reply

  +  16  =  23