LVM is storage distributed across several physical disks, which tempts people into thinking it has the same benefits as RAID. But in some ways LVM and RAID are opposites!
In Learning Tree’s Linux server administration course we teach you about LVM, but we don’t try to convince you that it’s either great or dangerous. It is what it is. Once you understand what it is and how it works you must decide for yourself if it’s a useful part of your storage design. RAID has a two advantages not included in LVM, let’s take a look:
Let’s say you buy a model of disk that has a 2% chance of failure within a year. You have enough data that you need 4 disks to hold it all.
Not to turn this into a tutorial on probability but… We are saying that each of these disks has a 2% chance of failing during the coming year. So for one disk, the probability of failure is 0.02 and that of success is 0.98.
The disks are independent of each other, the failure or success of one of them has no effect on the likelihood of another failing. So the probability of four randomly selected disks all surviving for a year is the product of their individual probabilities of success:
0.984 = 0.9224
So, we estimate that there is a probability of 0.0776 (or a 7.76% chance) that at least one disk will fail. Most likely just one, but possibly (and with decreasing likelihood) two, three, or even all four.
LVM is like RAID-0, there is no redundancy. With the data striped across all four disks, there is a 7.76% chance of one disk crashing and all data being lost.
Conclusion: LVM does not have redundancy, neither does RAID-0, and backups are extremely important. Also, don’t forget to test your recovery process!
I mentioned striping earlier. If you dig into the LVM manual pages you can see how to query and even control striping. But…
This is not striping for performance.
Let’s say you get that four-disk LAM nearly full so you add a fifth disk. That’s all that happens, you add a disk. LVM does not rebuild the disk array as a RAID controller can. Practically all of the new files go onto that new disk and so they aren’t striped. As for whether this makes directory fragmentation (or file scattering) worse or better, it depends on where you putting the new files within the file system tree.
If you need RAID, use actual RAID. Rely on RAID for whatever performance and reliability you need. LVM doesn’t provide those, it’s a mechanism to make it easier to add storage.
If you are using LVM on non-RAID disks, when you add a disk it will help your performance if you back up, recreate the LVM architecture, and then restore. I recently explained why this is the case. Pick some reasonably convenient downtime for this lengthy project. And again, only proceed after you have verified your backup and recovery procedures.
Exactly. The Btrfs file system I described recently incorporates features of both software RAID and LVM, making both redundant. We’re headed toward Btrfs, but until it gets here, be careful with your LVM storage!