Child pages
  • Multiple devices (md, software RAID)

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

 

RAID 1

Create a RAID 1 system of 2 disks and 2 partitions

In the following examples we are going to use sdb and sdc for the disc to use in the RAID. Adapt it to your situation.

Create the partitions

Code Block
fdisk /dev/sdb
  • p check the partition table
  • n create partition (ex +128M)
  • t filesystem
  • a bootflag
  • w write 

Set the RAID1 system on the 2 partitions

Code Block
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1
mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sdb2 /dev/sdc2

Check the RAID-DEVICES

Code Block
cat /proc/mdstat

Make the file system

Code Block
mkfs.ext3 /dev/md0
mkfs.ext4 /dev/md1

Mount the disks

Code Block
mkdir /mnt/md0
mkdir /mnt/md1
mount /dev/md0 /mnt/md0/
mount /dev/md1 /mnt/md1/

Copy the data of Home

Code Block
cd /home
tar c * | tar x -C /mnt/md1

Find the UUID of the 1st partition

Code Block
blkid
/dev/md1: UUID="3968404e-6571-4671-a157-9113a9f2fcba" TYPE="ext4"

Make md1 be the home directory

Code Block
emacs /etc/fstab
# /home was on /dev/sda9 during installation
UUID=3968404e-6571-4671-a157-9113a9f2fcba /home ext3 defaults 0 2 

 

Add new Hard drive

Connect the new hard disk and boot a system.

This will create on the new drive a partition table identical to the one of the existing working drive (this will also copy GRUB).

(Assuming that /dev/sda is the existing working drive and /dev/sdb is the newly added drive)

Code Block
dd if=/dev/sda of=mbr.bin bs=512 count=1
dd if=mbr.bin of=/dev/sdb bs=512 count=1

Check the status of the RAID devices to see the device numbers

Code Block
cat /proc/mdstat

Add the appropriate partition of the new drive to the RAID devices, repeat for each RAID device.

Code Block
mdadm --manage --add /dev/md0 /dev/sdb1

 

Common to all RAID

Start the arrays at once

Some linux system integrated an mdadm tool called mdadm-startall. You can install it if not already done.

It doesn't require any argument and will assemble all the md drives found.

Code Block
mdadm-startall