How can I create a RAID array with >2TB disks?

I would like to know the correct way to set up a software RAID array on an existing server. I have two brand new 3TB disks to use for the array.

Specifically, I want to set up a 3TB RAID 1 array, formatted to ext4, not using LVM. But a more general answer might help others with instructions from start to finish.

I have tried a number of guides:

  • How to implement RAID 1? - only covers part of the process
  • Setup of two additional SSD drives in RAID 1 - ends up with an array of 2TB rather than 3TB
  • Add two new HDD in Raid 1 - only uses 1TB drives

I also found these resources:

  • http://richard.blog.kraya.co.uk/tag/mdadm/ - for CentOS and does not cover updating mdadm.conf and other steps
  • http://www.technotes.se/?p=1732 - comprehensive but complicated and not specifically written for Ubuntu

The initial partitioning of the drives appears to be key; the last link above mentions this in detail, but the previous link seems to achieve the same result and is simpler.


Solution 1:

This answer assumes that you are creating a new RAID 1 array using two identical new drives. The file system will be ext4 on a single partition taking up the whole drive, not using LVM.

Firstly, identify the device names for your new hard drives by running sudo fdisk -l. In my case, the new drives were /dev/sdc and /dev/sdd.

Then create the partition on each drive. The partition table needs to be GPT to allow more than 2TB to be used, so you cannot use fdisk.

  1. Run parted /dev/sdc.

  2. At the (parted) prompt, create the partition table by typing mklabel gpt.

  3. Check the free space on the drive by typing print free. In my case, this shows 3001GB.

  4. Create the partition by typing mkpart primary 1M 3001GB. This starts the partition a 1M offset giving a 4096 byte alignment. This may or may not be necessary, but won't hurt if its not.

  5. Check your partition is set up by typing p. Then type q to quit.

Repeat steps 1 to 5 for /dev/sdd.

Now create the array using the mdadm command:

sudo mdadm --verbose --create /dev/md0 --level=raid1 --raid-devices=2 /dev/sd[cd]1

Create the file system:

sudo mkfs.ext4 /dev/md0

Finally, mount your array somewhere and add it to /etc/fstab if you want it to be mounted permanently. I did this:

  1. Create a location to mount the array at by running sudo mkdir /mnt/md0.

  2. Edit /etc/fstab and add the following line:

    /dev/md0 /mnt/md0 auto defaults 0 0
    
  3. Mount by running sudo mount /mnt/md0.

Now you can start using your array. Bear in mind, however, that before it is fully operation it will need to complete its initial sync. You can track its progress by running sudo mdadm --detail /dev/md0.