CH-J Server Managerserver management over SSH
Menu
All guides and articles →

LVM or a standard partition: which should you choose for a server?

What LVM adds over a plain partition, what it costs, and how to decide for a small VPS or a server with several disks.

The difference in brief

A partition is a fixed range of one disk, with a file system directly on it. LVM adds a layer: physical volumes are pooled into a volume group, and logical volumes are carved out of it. A file system then sits on a logical volume that can be resized and moved independently of where the data physically lies.

See what the server uses now

Start by reading the current layout. The TYPE and FSTYPE columns show partitions, LVM, encryption and RAID. The LVM commands show how much free space the volume group still has, because free space there is not visible in df.

lsblk -f
sudo pvs
sudo vgs
sudo lvs

When a standard partition is enough

For a small VPS with one virtual disk, a partition is simpler and has fewer things to go wrong. When the provider enlarges the disk, you grow the last partition with growpart and then the file system. The limit is that a partition can only grow into free space directly behind it, so a swap partition or another partition in that position gets in the way.

When LVM pays off

LVM is useful when you do not know how the space will be divided later, when a volume needs to span several disks, or when you want to move data to a new disk with pvmove while it is in use. It can also take snapshots, for which you must reserve space. A snapshot on the same disks is not a backup, and a full classic snapshot becomes invalid.

Create an LVM volume

These commands use an empty disk and destroy anything on it, so check the device name twice with lsblk. Leave some space in the volume group unallocated: growing a volume later is easy, while shrinking is harder. XFS cannot be shrunk at all, and ext4 can only be shrunk unmounted.

sudo pvcreate /dev/sdX
sudo vgcreate data /dev/sdX
sudo lvcreate -L 20G -n app data
sudo mkfs.ext4 /dev/data/app

Changing your mind later

A partition with data generally cannot be turned into LVM in place with standard tools. The usual route is to add a new disk, create LVM on it, copy the data and switch over, which also requires changes to fstab and possibly to the boot configuration. Make that plan with a verified backup and console access. Fine details of booting vary by distribution, which is why many installers keep /boot outside LVM.

Disks in CH-J Server Manager

Disk Manager in Alpha 0.1.1 shows disks with their layers, including LUKS, LVM, RAID and ZFS. Without root the inventory is read-only and incomplete, and it can be loaded again with sudo. Changes are first queued as a plan to review, and the job stops without changing anything if the layout changed since the plan was created. Steps that can lose data carry a warning to make a separate backup first. It covers Linux block devices only.

Detailed documentation

man: lvm →

man: lvcreate →

Biometric unlock and security →