Logical Volume Manager (LVM) and Redundant Array of Independent Disks (RAID) are advanced storage technologies used in Linux systems to provide flexibility, performance, and reliability. While basic disk partitioning works for simple setups, LVM and RAID are essential for managing large-scale storage systems, servers, or any environment where data growth, uptime, and redundancy are important.
LVM allows you to manage physical disks as a single pool of storage. With it, you can create logical volumes that behave like partitions but are more flexible. You can resize them, move them, and even take snapshots. RAID, on the other hand, focuses on redundancy and performance. It combines multiple physical disks into one logical unit and spreads or mirrors data across them, depending on the RAID level you choose.
Understanding how LVM and RAID work gives you better control over your storage environment. It is especially useful when working with Linux servers, virtual machines, or custom hardware setups.
If you are not yet familiar with basic partitioning and filesystem setup, you should first read the article Disk Partitioning and Filesystem Management in Linux, where we covered how to format drives, mount them, and configure /etc/fstab
.
What Is LVM and Why Use It?
LVM stands for Logical Volume Manager. It is a method of managing disk storage in a more flexible and powerful way than traditional partitions.
In a normal setup, partitions are fixed in size. If you run out of space on one partition, you cannot easily extend it without reformatting or moving data. LVM solves this problem by creating an abstraction layer between physical storage and logical partitions.
With LVM, physical disks (or partitions) are grouped into Physical Volumes (PVs). These PVs are combined into Volume Groups (VGs), and from these groups you can create Logical Volumes (LVs), which act like flexible partitions. You can resize LVs at any time, and even span a single LV across multiple disks.
LVM is especially useful in environments where storage needs change often, such as in testing, development, or container-based systems. It also supports snapshots, which allow you to take a frozen copy of a volume before making risky changes.
How to Set Up LVM in Linux
To set up LVM, you first need to install the LVM tools. Most distributions, including Linux Mint and Ubuntu, come with them preinstalled. If not, you can install them using your package manager.
The first step is to create physical volumes from existing partitions or disks.
sudo pvcreate /dev/sda1 /dev/sdb1

Next, combine the physical volumes into a volume group:
sudo vgcreate my_vg /dev/sdb1 /dev/sdc1

Then, create a logical volume from the volume group. You can specify the size or use the entire space.
sudo lvcreate -L 20G -n my_lv my_vg
After creating the logical volume, format it with a filesystem such as ext4:
sudo mkfs.ext4 /dev/my_vg/my_lv
Finally, mount the logical volume:
sudo mkdir /mnt/mydata
sudo mount /dev/my_vg/my_lv /mnt/mydata

You can now use /mnt/mydata
like any other directory. The main difference is that you can later grow or shrink the logical volume without starting over.
What Is RAID and How It Works
RAID, which stands for Redundant Array of Independent Disks, is a method of combining multiple physical drives into one logical unit to improve data redundancy, performance, or both.
There are several levels of RAID, and each one serves a different purpose.
- RAID 0 splits data across two or more disks for speed, but offers no redundancy.
- RAID 1 mirrors data across two disks, providing fault tolerance.
- RAID 5 uses block-level striping with parity, requiring at least three disks and allowing one to fail.
- RAID 6 is like RAID 5 but can handle two disks failing.
- RAID 10 (1+0) combines mirroring and striping for both speed and redundancy.
RAID can be implemented in two ways: hardware RAID (through a RAID controller) or software RAID (through the operating system). Linux supports software RAID through a tool called mdadm
.
How to Set Up Software RAID in Linux
To set up a simple software RAID in Linux, you need at least two disks. First, install the mdadm
package if it is not already installed (on Debian and Ubuntu based systems):
sudo apt install mdadm
To create a mirrored RAID 1 array with two disks, use:
sudo mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdc
Linux will now build the array. You can check its progress using:
cat /proc/mdstat
Once the array is ready, you can format it with a filesystem:
sudo mkfs.ext4 /dev/md0
Then mount it as usual:
sudo mkdir /mnt/raid
sudo mount /dev/md0 /mnt/raid
To make the RAID array load automatically on boot, you can add it to /etc/mdadm/mdadm.conf
and then update your /etc/fstab
file, just like you would with a normal partition.
LVM vs RAID: When to Use Each
LVM and RAID solve different problems. LVM focuses on flexibility. It lets you resize, move, and manage storage dynamically. RAID focuses on performance and redundancy, allowing you to mirror or stripe data across disks.
You can also use both together. For example, you can create a RAID array for redundancy, and then place LVM on top of it to manage logical volumes. This gives you the benefits of both technologies.
On servers, it is common to see LVM used for application volumes, while RAID is used to protect critical data or system partitions. On desktops, LVM is useful for testing and dual-boot setups where resizing partitions is common.
Summary
LVM and RAID are essential tools for managing storage in Linux beyond basic partitions. LVM allows you to group physical disks and create flexible volumes that can be resized and moved. It is ideal for dynamic environments where storage needs change frequently. RAID provides data redundancy and performance improvements by combining multiple disks into one logical unit.
While LVM is more focused on ease of management, RAID focuses on protecting data and ensuring system uptime. Both can be used together to build powerful storage systems that are reliable and easy to grow.
The next step in managing a Linux system is managing Users and Groups on Linux. It is essential to know how to create new users, add them to specific groups etc for a system administrator.