Linux Software RAID 1 Array How to Manual Setup
Scenario / Question:
Setup a RAID 1 Array in an existing system using two new hard drives.
Solution / Answer:
Check the Partition Table on the new drives and create a RAID partition.
Create a new RAID 1 Array using the newly created partitions
Create mdadm.conf configuration file for the RAID Array
Display all drives and partition tables
fdisk -lu Disk /dev/sdc: 73.4 GB, 73407868928 bytes 255 heads, 63 sectors/track, 8924 cylinders, total 143374744 sectors Units = sectors of 1 * 512 = 512 bytes Disk /dev/sdc doesn't contain a valid partition table Disk /dev/sdd: 73.4 GB, 73407868928 bytes 255 heads, 63 sectors/track, 8924 cylinders, total 143374744 sectors Units = sectors of 1 * 512 = 512 bytes Disk /dev/sdd doesn't contain a valid partition table
The new installed hard drives are /dev/sdc and /dev/sdd
Partition the hard drives
n — to create a new partition
p — to create primary partition
1 — to create first partition
t — to change partition type
fd — for Linux raid auto partition type
w — write partition changes to partition table and exit
fdisk /dev/sdc The number of cylinders for this disk is set to 8924. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) Command (m for help): Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-8924, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-8924, default 8924): Using default value 8924 Command (m for help): t Selected partition 1 Hex code (type L to list codes): fd Changed system type of partition 1 to fd (Linux raid autodetect) Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
Check Partitions have been read by kernel. Alternative to rebooting is to issue the command “partprobe” which can force the kernel to re-read the partition table from disk.
# partprobe
Check that the Kernel has recognized the Partitions
# cat /proc/partitions
Now that our hard drives are partitioned properly we can begin creating the new RAID 1 Array
The command to create,setup,and control RAID arrays is “mdadm”
–create option to create the RAID array
–level option to specify the RAID level (in this case RAID 1)
–raid-devices option to list the partitions that will be used to create this RAID Array
# mdadm --create --verbose /dev/md3 --level=1 --raid-devices=2 /dev/sdc1 /dev/sdd1 mdadm: size set to 71681920K mdadm: array /dev/md3 started.
Format the new RAID 1 array
# mkfs.ext3 /dev/md3 mke2fs 1.35 (28-Feb-2004) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 8962048 inodes, 17920480 blocks 896024 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=20971520 547 block groups 32768 blocks per group, 32768 fragments per group 16384 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424 Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done Save Configuration Information
Create mdadm config file. Unfortunately mdadm doesn’t automatically remember all the partitions of your RAID sets. We can manually add This information to mdadm.conf
# mdadm --detail --scan --verbose /etc/mdadm.conf


