Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm new to Linux device management, and filesystems generally, so the answer to this question might be "No, of course not. What were you thinking?" or "Yes, of course. Isn't it obvious?" All the same I'm hoping a little expertise might clear my confusion.

I recently found a legacy script that creates and attaches volumes to EC2 instances. Suppose I have four EBS volumes, sdf1, sdf2, sdf3, sdf4. The relevant portion looks something like this:

# Create a RAID0 array
pvcreate /dev/xvdf1 /dev/xvdf2 /dev/xvdf3 /dev/xvdf4
vgcreate myvg /dev/xvdf1 /dev/xvdf2 /dev/xvdf3 /dev/xvdf4
lvcreate --stripes 4 --stripesize 256 --extents 100%VG --name mylv myvg
mkfs.xfs /dev/myvg/mylv

That's the entirety of the filesystem creation. In contrast, every single tutorial I can find on the web (and these are but a sampling) uses mdadm first, then manipulates the resulting device, usually something like this:

mdadm --verbose --create /dev/md0 --level=0 --chunk=256 --raid-devices=4 /dev/sdf1 /dev/sdf2 /dev/sdf3 /dev/sdf4
mdadm --detail --scan >> /etc/mdadm/mdadm.conf

I sort of understand -- albeit loosely and without the ability to comprehend details -- that mdadm creates software RAIDs, and that these are distinguishable from hardware RAIDs, but I can't seem to figure out what, if anything, the above script snippet creates. Is it RAID? Is it not? Is it something else entirely?

share|improve this question
up vote 1 down vote accepted

"No, of course not. What were you thinking?"

The mdadm RAID 0 stripes data across all four volumes in small (here, 256KB) chunks, giving you the performance improvement you expect from RAID 0.

The LVM approach you listed here also does the same striping, making it functionally equivalent to RAID 0. (This is not the default behavior for LVM.)

You could use either approach, but the LVM approach actually limits you here since you won't be able to add volumes later without completely recreating the logical device.

share|improve this answer

Your first example is using the Logical Volume Manager to create a volume that is has properties somewhat like a RAID0. LVM supports stripping and mirroring.

share|improve this answer

For my part, I tend to use both in our cloud; essentially, I create the raid device /dev/md0 and then manage it with lvm. The advantage is I can use whatever raid level I need to suit my performance or data security (raid 0 for high speed IO operations, raid 10 if the data is extremely valuable.) I use LVM to give me the ability to easily add capacity to the file system and snapshot data (amazon's snapshot feature doesn't help so much if my data spans more than one drive.)

share|improve this answer

Your Answer


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.