Differences between revisions 6 and 7
Revision 6 as of 2016-02-26 14:22:30
Size: 1098
Comment:
Revision 7 as of 2016-02-26 14:40:25
Size: 2328
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
The example below shows how to create a software RAID1 array on Debian systems. Disk partitions /dev/hda1 and /dev/hdc1 will be used as the member of the RAID arrays. The example below shows how to create a software RAID1 array on Debian systems. Disk partitions '''/dev/hda1''' and '''/dev/hdc1''' will be used as the members of the RAID array '''md0''', which will be mounted on the '''/home''' partition.  
Line 3: Line 3:
== Install the `mdadm` package == == Install the mdadm package ==
Line 9: Line 9:
Create disk partitions with type `0xfd`. Create disk partitions with type `0xfd`. Afterwards, do:
Line 12: Line 12:
root@localhost:~# mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/hd["ac"]1 root@localhost:~# mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/hda1 /dev/hdc1
Line 14: Line 14:

{{{#!wiki note
'''Note'''

If you have the two entire disks available, you can skip the partitioning. Just add the disk devices to the raid array (i.e. /dev/hda, /dev/hdc).
}}}
Line 18: Line 25:
== Add entry to `/etc/fstab`: == == Add entry to /etc/fstab: ==
Line 22: Line 29:
== Create mdadm config file: == == Create the mdadm config file: ==
Line 29: Line 36:
Note that the array is actually started in /etc/rc0.d/S50mdadm (via mdadm -A -s) or mdrun command Note that the array is actually started by the `mdadm-raid` service or (either via `mdadm -A -s` or the `mdrun` commands).

== Query the RAID array ==

{{{#!highlight Bash numbers=disable
root@localhost:~# mdadm --query --detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Wed Feb 24 14:29:34 2016
     Raid Level : raid1
     Array Size : 285092864 (271.89 GiB 291.94 GB)
  Used Dev Size : 285092864 (271.89 GiB 291.94 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

  Intent Bitmap : Internal

    Update Time : Fri Feb 26 15:30:42 2016
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           Name : localhost:0 (local to host localhost)
           UUID : bc3c058d:56029657:fa438017:c0f2acf4
         Events : 2126

    Number Major Minor RaidDevice State
       0 8 2 0 active sync /dev/sda1
       1 8 18 1 active sync /dev/sdc1
}}}

The example below shows how to create a software RAID1 array on Debian systems. Disk partitions /dev/hda1 and /dev/hdc1 will be used as the members of the RAID array md0, which will be mounted on the /home partition.

Install the mdadm package

root@localhost:~# apt-get install mdadm

Create the RAID1 array

Create disk partitions with type 0xfd. Afterwards, do:

root@localhost:~# mdadm --zero-superblock /dev/hda /dev/hdc
root@localhost:~# mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/hda1 /dev/hdc1

Note

If you have the two entire disks available, you can skip the partitioning. Just add the disk devices to the raid array (i.e. /dev/hda, /dev/hdc).

Create filesystem (i.e. ext3) on RAID1 block device (md0)

root@localhost:~# mkfs.ext3 /dev/md0

Add entry to /etc/fstab:

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

Create the mdadm config file:

root@localhost:~# mdadm --detail --scan /dev/md0 >> /etc/mdadm/mdadm.conf
DEVICE /dev/hda1 /dev/hdc1
ARRAY /dev/md0 devices=/dev/hda1,/dev/hdc1 level=1 num-devices=2 auto=yes

Note that the array is actually started by the mdadm-raid service or (either via mdadm -A -s or the mdrun commands).

Query the RAID array

root@localhost:~# mdadm --query --detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Wed Feb 24 14:29:34 2016
     Raid Level : raid1
     Array Size : 285092864 (271.89 GiB 291.94 GB)
  Used Dev Size : 285092864 (271.89 GiB 291.94 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

  Intent Bitmap : Internal

    Update Time : Fri Feb 26 15:30:42 2016
          State : clean 
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           Name : localhost:0  (local to host localhost)
           UUID : bc3c058d:56029657:fa438017:c0f2acf4
         Events : 2126

    Number   Major   Minor   RaidDevice State
       0       8        2        0      active sync   /dev/sda1
       1       8       18        1      active sync   /dev/sdc1