10

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:

I also found these resources:

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.

2
  • In order to use disks > 2TB you just need to make sure you create the initial partition table in GUID format (GPT) rather than the old MS-DOS (MBR) format. You can do that using the parted command line program (using mklabel gpt) or from gparted using the 'Select new partition table type' drop down menu. Sep 26, 2013 at 11:52
  • @steeldriver - Yes, GPT seems to be the trick. Sep 26, 2013 at 16:52

1 Answer 1

17

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .