I am making a huge RAID10 device (8 TB) for storage on CentOS. I have created the 4 partitions on my 4 physical hard disks and have created the raid device /dev/md2 out of those 4 partitions.
Now it's time to put a filesystem on it. I am wondering whether I should do just:
mkfs.ext4 /dev/md2
which totally works (I tried it), or I should first create a single partition on that device (with fdisk, gdisk or parted?), that takes up all the space, and then do the mkfs stuff on that partition.
Googling the Web, I found another person asking the very same question here: http://ubuntuforums.org/showthread.php?t=2174067 but, although a responder said:
Partitions go on the array members.
Filesystem goes on the array.
they didn't give him a definitive, non-ambiguous answer or an explanation when one approach should be preferred over the other.
The only method I have ever used was to partition the physical disks, then combine the partitions into a RAID, and put file system (or swap) directly on the
md
device.As far as I know partitioning the md device is a feature, which was added later, but never became widely used.
I would recommend against attempting to create a RAID directly on a physical device without partitioning that device first. Lot of software expects hard disks to be partitioned, and the partition table contains a type field for each partition, which will tell software reading the partition table that this partition is part of a RAID.
Whether to use a partition table on top of the
md
device may be a matter of taste. It might be entirely due to historical reasons, that it is usually not done. The tiny amount of additional disk space consumed by the extra layer of partition table is certainly not a reason to avoid it, and just as at the lower layer, the partition table on top of the md device would indicate what to expect to find inside.However the flexibility gained by being able to partition the
md
device, I consider to be negligible, because you can create multiple partitions on the physical device instead and create multiplemd
devices.Multiple
md
devices which are not partitioned give you more flexibility than onemd
device which is partitioned. You have additional freedom when time comes to replace one of the underlying media, and you can configure the differentmd
devices with different RAID levels.For example if you have six disks, you could make
/boot
be RAID-1 with a copy on every disk./
could be a RAID-1 with copies on three disks and a RAID-1 with copies on the other three disks could be used for swap. Remaining space could be a large RAID-6 across all six disks.As others have said, normal practice with md-RAID metadevices is to put the file system directly on it. The metadevice should already only be made up of partitions (putting RAID devices on top of whole-disc devices is a practice that I find involves shooting yourself in the foot more often than not), so you're not violating the advice you received.
But an option that's not already been mentioned is that if you want to partition the RAID device, you can assign it to LVM then use LVM to divide up the device into partitions. In addition, you get the handy advantages of LVM when it comes to resizing partitions, allocating extra space, and so on.
Here's an example from one of my boxes:
As you can see, there's a single RAID metadevice, on which four separate partitions exist. They correspond to swap,
/
, a big data partition, and a little extra space in case it's needed anywhere.