Linux software RAID – quick howto.

Linux software RAID – quick howto.

Basic steps:

1) create partitions using cfdisk or fdisk (set them to MSDOS type with parted beforehand if required)
2) Change partition type to Linux Raid autodetect
3) Create RAID
4) Format RAID devices

Show partitions with ‘fdisk -l’

Device    Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          63      257039      128488+  fd  Linux raid autodetect
/dev/sdb2          257040    11968424     5855692+  fd  Linux raid autodetect
/dev/sdb3        11968425    19776014     3903795   fd  Linux raid autodetect
/dev/sdb4        19776015  1953525167   966874576+   5  Extended
/dev/sdb5        19776078  1953525167   966874545   fd  Linux raid autodetect

Duplicate partitions /dev/sdb[x] -> /dev/sda[x]

sfdisk -d /dev/sdb | sfdisk /dev/sda

Create RAID devices: 


mdadm --create /dev/md0 --level=1 --metadata=0.90 --raid-devices=2 /dev/sd[ab]1
mdadm --create /dev/md1 --level=1 --metadata=0.90 --raid-devices=2 /dev/sd[ab]2
mdadm --create /dev/md2 --level=1 --metadata=0.90 --raid-devices=2 /dev/sd[ab]3
mdadm --create /dev/md3 --level=1 --metadata=0.90 --raid-devices=2 /dev/sd[ab]5

Result:

root@sysresccd /root % fdisk -l

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000dea8b

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *          63      257039      128488+  fd  Linux raid autodetect
/dev/sda2          257040    11968424     5855692+  fd  Linux raid autodetect
/dev/sda3        11968425    19776014     3903795   fd  Linux raid autodetect
/dev/sda4        19776015  1953525167   966874576+   5  Extended
/dev/sda5        19776078  1953525167   966874545   fd  Linux raid autodetect

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00013729

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          63      257039      128488+  fd  Linux raid autodetect
/dev/sdb2          257040    11968424     5855692+  fd  Linux raid autodetect
/dev/sdb3        11968425    19776014     3903795   fd  Linux raid autodetect
/dev/sdb4        19776015  1953525167   966874576+   5  Extended
/dev/sdb5        19776078  1953525167   966874545   fd  Linux raid autodetect

Disk /dev/md0: 131 MB, 131465216 bytes
2 heads, 4 sectors/track, 32096 cylinders, total 256768 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/md1: 5996 MB, 5996150784 bytes
2 heads, 4 sectors/track, 1463904 cylinders, total 11711232 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/md2: 3997 MB, 3997368320 bytes
2 heads, 4 sectors/track, 975920 cylinders, total 7807360 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/md3: 990.1 GB, 990079418368 bytes
2 heads, 4 sectors/track, 241718608 cylinders, total 1933748864 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

root@sysresccd /root %

So your partitions now map to RAID devices as follows:


/dev/sda1 -> /dev/md0
/dev/sda2 -> /dev/md1
/dev/sda3 -> /dev/md2
/dev/sda4 -> /dev/md3

Show output of RAID build progress


cat /proc/mdstat

admin has written 88 articles