Linux stores data on partitions, and how you manage them affects how easily you can grow, move, and back up your storage later. This article covers two approaches on a Kamatera VPS: standard partitioning and LVM. We explain how partition management works, then walk through each method, including its main commands, advantages, and disadvantages. Next, we compare the two side by side and help you decide which to use, why, and when.
Understanding partition management
From a user’s perspective, Linux stores all data in a single unified directory tree. In reality, the operating system can handle anything from a single disk drive to a large array of storage devices. To organize that storage, Linux divides disks into smaller units called partitions. A partition is a section of a physical or logical device. Each partition is formatted with a file system, which organizes data into files and the directories that contain them. Linux accesses a partition’s file system through a directory called a mount point.
Standard partitioning
Standard partitioning manages storage directly on a disk, or on a virtual disk on a VPS. It divides the disk into fixed sections with a partition table and uses a small set of simple commands. The table below lists the main ones.
| Command | Description | Syntax | Example | Notes |
|---|---|---|---|---|
mkfs |
Creates a file system, such as ext4, on a partition | mkfs.<type> <partition> |
mkfs.ext4 /dev/sdb1 |
Create the partition first with fdisk or parted. |
mount |
Attaches a partition’s file system to a mount point | mount <partition> <mount point> |
mkdir /mnt/my-datamount /dev/sdb1 /mnt/my-data |
Create the mount point directory before you run mount. |
umount |
Detaches a file system from its mount point | umount <partition> |
umount /dev/sdb1 |
Close any open files on the partition first. |
growpart |
Expands a partition into the free space that follows it | growpart <disk> <partition number> |
growpart /dev/sda 3 |
Expands only into free space directly after the partition. Does not resize the file system. |
resize2fs |
Expands an ext2, ext3, or ext4 file system to fill its partition | resize2fs <partition> |
resize2fs /dev/sda3 |
Run it after growpart. |
Next, we look at the advantages and disadvantages of standard partitioning.
Advantages of standard partitioning
| Feature | Details |
|---|---|
| Availability | Built into every major Linux distribution, including Debian and Ubuntu |
| Simplicity | Uses a small set of simple commands |
| Low overhead | Adds no extra mapping layer, so it needs no additional metadata or memory beyond the partition table |
| Compatibility | Broad support across bootloaders, kernels, and backup tools |
| Data resilience | File system corruption on one partition is typically contained to that partition |
Disadvantages of standard partitioning
| Feature | Details |
|---|---|
| Contiguous space required | A partition can only grow into free space directly after it |
| Single disk boundary | A partition cannot span multiple disks, so you cannot pool separate drives into one larger partition |
| Limited resizing | Shrinking a partition requires unmounting it, and moving partition boundaries risks data loss |
| Wasted disk space | Fixed sizes push admins to over-provision, which can leave free space locked in one partition where others can’t use it |
LVM
LVM is a flexible Linux disk management system. Instead of tying a file system directly to a partition, it manages storage as a pool that you divide into logical volumes. This makes it easy to create, expand, move, and snapshot volumes without losing your data.
LVM is built on three concepts:
- Physical volumes (PVs): Disks or partitions that you initialize for use with LVM.
- Volume groups (VGs): Pools of storage made from one or more physical volumes.
- Logical volumes (LVs): Flexible, partition-like volumes that you create from a volume group, then format and mount.
The table below lists the main LVM commands.
| Command | Description | Syntax | Example | Notes |
|---|---|---|---|---|
pvcreate |
Initializes a disk or partition as an LVM physical volume | pvcreate <device path> |
pvcreate /dev/sdc |
You can use a whole disk or a partition. To use a partition, create it first with fdisk or parted. |
pvs |
Displays physical volume information | pvs |
pvs |
|
vgcreate |
Creates a volume group from one or more physical volumes | vgcreate <volume group name> <physical volume path> |
vgcreate vg_data /dev/sdc |
The physical volume must already exist. |
vgs |
Displays volume group information | vgs |
vgs |
|
lvcreate |
Creates a logical volume in a volume group | lvcreate --name <logical volume name> --size <size> <volume group name> |
lvcreate --name lv_data --size 5G vg_data |
Format the new logical volume with mkfs and mount it before you use it. |
lvs |
Displays logical volume information | lvs |
lvs |
|
lvextend |
Expands a logical volume and, with –resizefs, its file system | lvextend --resizefs --size +<size> <logical volume path> |
lvextend --resizefs --size +10G /dev/vg_data/lv_data |
The volume group needs enough free space. Check with vgs. |
pvmove |
Moves data from one physical volume to another in the same volume group | pvmove --name <logical volume name> <source physical volume> <destination physical volume> |
pvmove --name lv_data /dev/sdb /dev/sdc |
The destination must be in the same volume group and have enough free space. |
lvcreate --snapshot |
Creates a snapshot of a logical volume | lvcreate --snapshot --name <snapshot name> --size <size> <logical volume path> |
lvcreate --snapshot --name lv_snapshot --size 5G /dev/vg_data/lv_data |
The size is the space reserved for changes made after the snapshot. If it fills up, the snapshot becomes invalid. |
Let’s now move on to LVM’s advantages and disadvantages.
Advantages of LVM
| Feature | Details |
|---|---|
| Online resizing | Grow logical volumes and their file systems without unmounting or rebooting |
| Storage pooling | Combine multiple physical disks into a single volume group |
| Flexible allocation | Keep unallocated space in the volume group for future volumes and snapshots |
| Snapshot support | Capture a point-in-time copy of a volume to back it up or test changes without taking services offline |
Disadvantages of LVM
| Feature | Details |
|---|---|
| Higher complexity | Requires understanding physical volumes, volume groups, logical volumes, and their commands |
| Harder recovery | After a system failure, you may need to boot a rescue environment and activate the volume groups before you can access your data |
| Risky shrinking | Reducing a logical volume risks data loss, and some file systems, such as XFS, cannot be shrunk |
| Multi-disk failure risk | A volume group that spans multiple disks without RAID can lose data if one of those disks fails |
| Minor performance overhead | The mapping layer between logical volumes and physical storage adds a small amount of I/O overhead |
Side-by-side comparison
After looking at each partitioning method on its own, let’s compare standard partitioning and LVM.
| Feature | Standard | LVM |
|---|---|---|
| Resizing | Growing needs free space directly after the partition. Shrinking requires unmounting and risks data loss. | Growing can be done online, using free space anywhere in the volume group. Shrinking carries a higher risk of data loss. |
| Disk spanning and pooling | Limited to a single disk | Volumes can span multiple disks through volume groups |
| Snapshots | Not supported | Supported |
| Complexity | Low. A straightforward layout defined by the partition table. | Higher. Requires physical volumes, volume groups, and logical volumes. |
| Recovery | Simpler. Partitions can be mounted directly from a rescue environment. | More involved. You may need to scan and activate volume groups first. |
| I/O performance overhead | None from an extra mapping layer | Small, from the mapping layer |
Which should you use, why, and when
Here are our recommendations on when you should consider using standard or LVM partitioning.
Consider standard partitioning if:
- You run a small server that hosts a single application.
- Your storage needs are small and unlikely to change.
- You don’t need to combine multiple disks into one volume.
- You want fewer layers to understand and troubleshoot.
- Your cloud provider offers automated disk backups.
Consider LVM if:
- You run a larger server that hosts multiple applications, each with its own storage requirements.
- Your storage needs are large and hard to predict, and you want to grow volumes without downtime.
- You want to pool multiple disks into a single usable volume.
- You need flexibility and the ability to make changes while the server is live.
- You want to take snapshots frequently, for example before making changes or running tests.
Conclusion
Standard partitioning and LVM each suit different storage needs. Standard partitioning is simple, has minimal overhead, and is easy to recover, which makes it a good fit when your storage needs are stable and you want low maintenance. LVM is the better fit when your storage needs are likely to change. If you expect to grow your storage, pool multiple disks, or resize volumes while the server is running, setting up LVM from the start is easier than converting later.
