Installing RAID 0 mirror on an existing Ubuntu Server install

Here’s a quick howto on installing a RAID1 mirror in an existing Ubuntu Server install for use as additional storage.

List installed drives:

sudo fdisk -l

I’ll assume here the two drives being used for the mirror are sdb and sdc (drive references WILL differ depending on your setup).

Create partition(s) and mark as ‘fd’ Linux raid autodetect:

sudo fdisk /dev/sdb

Repeat the process for the second drive (sdc).

sudo fdisk /dev/sdc

Install mdadm:

sudo apt-get install mdadm

Create the RAID array:

sudo mdadm --create --verbose --auto=yes /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1

The above command creates the RAID 1 array. If this is your first array then use /dev/md0. Count up for any additional arrays you’re adding to the system (md1, md2 etc).

Watch and wait for the disks to sync. This can take quite some time:

watch cat /proc/mdstat

Reboot the machine when the sync is complete then format the RAID array to your preferred file system:

sudo mkfs -t ext3 /dev/md0

Create a mount point for the new mirror:

sudo mkdir /mnt/data

Mount the array:

sudo mount /dev/md0 /mnt/data

View the mounted file systems. If all went well the new mirror should now be mounted and ready to use.

df

In order to have the mirror mounted on boot you’ll need to add this line to /etc/fstab:

/dev/md0 /mnt/data auto defaults 0 0

Viola :)

0 Responses to “Installing RAID 0 mirror on an existing Ubuntu Server install”


  1. No Comments

Leave a Reply