Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
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. –  steeldriver Sep 26 '13 at 11:52
    
@steeldriver - Yes, GPT seems to be the trick. –  David Edwards Sep 26 '13 at 16:52

2 Answers 2

LHN seems to have an excellent resource on the topic.

share|improve this answer
    
Aside from just being a link rather than an answer to the question, the instructions in your LHN link are largely the same as the 2nd link in my question, and will not work for drives larger than 2TB. –  David Edwards Sep 26 '13 at 16:49
up vote 0 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.