I'm currently working on a project that requires me to write a script to identify a set of drives added for the purpose of storage and install them as a RAID array. I'm having trouble finding information on the actual creation process though beyond the commands necessary.

  1. Do the drives I create the RAID from need to be formatted and partitioned first? Or does mdadm --create do this for you?

  2. I'm told that the project will support a variable number of drives. My boss suggested using RAID level 5, but unless I'm misunderstanding RAID levels, RAID level 5 requires at least 3 drives, where I think we're targeting using 2 to start. Do specific RAID levels have a minimum drive count?

  3. To add the RAID array to my fstab file, do I just assemble it? Or do I also need to mount it before/after it's assembled?

I've found a few tutorials on the setup process, but beyond that, I haven't really been able to dig up this information.

  • Don't use RAID-5, it's outdated, but what is your goal ? to pre-deploy a solution ? As often vendor now use vm appliance for such task, the hardware layer behind become a non-issue – yagmoth555 Mar 15 at 16:54
  • The goal is to mount the drives (my boss has been vague on how many, so I'm assuming it's variable, maybe 2-4) as a RAID array to store files created by our application. It's as simple as that. It's enough data that we'd be able to fill 2 TB in a couple days. I only mention RAID-5 because that's what he suggested. – Darin Beaudreau Mar 15 at 17:00
  • As of now, we already have one drive we keep mounted to store these files, but for testing purposes, we want to be able to temporarily mount these drives and switch the storage location, then a few days later once they're full, uninstall them and switch back. – Darin Beaudreau Mar 15 at 17:01
  • Why you dont just make the RAID volume ? I don't follow why you need to create a script for that, as the disk will remember it's part of a RAID, you intend to dump/clear them after the uninstall ? – yagmoth555 Mar 15 at 17:10
  • Because the installation will be done by technicians who don't know anything about Linux. All they will be responsible for is running the script. It needs to be an automated process. – Darin Beaudreau Mar 15 at 17:11
  1. If the disks have existing filesystems, you should remove them so you can start with disks without filesystems. First you create the array using mdadm, then you create the filesystem.
  2. RAID level 1 is 'mirroring' and you can create one with only 2 drives. RAID 5 requires a minimum of 3 drives as you have already stated, and RAID level 10 requires 4. RAID levels 0 and 1 only require a minimum of 2 drives.
  3. To add the array to /etc/fstab, just add a line like this: /dev/md0 /mnt/md0 ext4 defaults,nofail,discard 0 0
  • Do I need to ensure that the partitions on the drives are the same size? Also, for the fstab, I don't need to assemble the md0 drive first? – Darin Beaudreau Mar 15 at 17:15
  • @DarinBeaudreau The drives don't need to be the same size, but the smallest drive will determine the size of the RAID mirror. And the drives will not mount if you don't have the array created first. There's nothing you need to do other than the fstab entry once you've created the array. – Bert Mar 15 at 18:03
  • I only ask because I came across an article suggesting you need to use mdadm --assemble in the fstab file to detect the array and start it. – Darin Beaudreau Mar 15 at 18:09
  • As long as you have an entry in /etc/mdadm/mdadm.conf for your array, it will auto-assemble (generate the entry from mdadm --examine --scan ). You shouldn't have to manually assemble it unless you manually stop the array and have to re-start it. – Bert Mar 15 at 18:59
  • I'm assuming mdadm --create doesn't automatically add it to the mdadm.conf file? – Darin Beaudreau Mar 15 at 19:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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