Contents
- What problem are you trying to solve?
- How do partitions and LVM layers differ?
- How do you identify the layout already in use?
- When should you choose each layout?
- How do you create a separate LVM data volume safely?
- How do you grow an existing logical volume?
- How do you verify the result?
- What should you avoid when shrinking or migrating?
- How do you keep capacity changes predictable?
- How does CH-J Tools help with disk layouts?
- Frequently asked questions
What problem are you trying to solve?
A server has plenty of disk space overall, but the file system holding application data is nearly full. Another server has just received a larger virtual disk and still reports the old capacity in df. Choosing LVM or a standard partition affects how you resolve these situations, but neither choice automatically makes a file system larger.
For a small VPS with one data file system, a standard partition is often sufficient. LVM becomes useful when several file systems need different amounts of space over time, or when you expect to replace or add disks. Start with those operational needs rather than choosing by disk count alone.
The commands below target Linux with LVM2 and ordinary local block devices, using a separate ext4 data volume as the worked example. They are not a root-disk conversion procedure. Windows storage tools use different concepts and commands; do not apply this sequence to Windows disks.
How do partitions and LVM layers differ?
A partition describes a range of sectors on one disk. A file system such as ext4 can live directly on that partition. LVM inserts an allocation layer between the storage device and the file system. A physical volume can occupy either a whole disk or a partition, so partitions and LVM are not mutually exclusive.
- A physical volume, or PV, is a device initialized for use by LVM.
- A volume group, or VG, pools capacity from one or more physical volumes.
- A logical volume, or LV, receives space from that group and appears as a block device on which you create a file system.
Capacity is therefore measured at several layers. Free blocks inside ext4 belong to that file system; unallocated extents in a VG are available to extend an LV. A larger LV still needs a file system resize. LVM adds metadata and administrative steps, so the team maintaining recovery procedures must understand the extra layer.
How do you identify the layout already in use?
Before changing anything, map the affected directory to its mounted file system, then trace its backing devices. These inspection commands do not resize or format storage. Run them on the server itself. LVM commands require the lvm2 package on Ubuntu and Debian or RHEL; a missing command does not prove that the disk has no LVM metadata.
findmnt -T /var -o SOURCE,FSTYPE,TARGET
df -hT /var
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS
sudo pvs
sudo vgs
sudo lvs -o lv_name,vg_name,lv_size,segtype,devicesIn lsblk, TYPE identifies disk, part or lvm, while FSTYPE identifies formats such as ext4, xfs or LVM2_member. Follow the tree through any encryption or RAID layer instead of treating every row as an independent disk. The devices column in lvs helps locate the physical volumes backing an LV.
For example, a VG may have this layout. This is illustrative output, not a capacity target for your server:
VG #PV #LV #SN Attr VSize VFree
data 1 1 0 wz--n- 40.00g 20.00gHere 20 GiB remains unallocated in the VG. It will not appear as available space in df until it is assigned to an LV and the file system is grown. If the group is full, extending the LV alone cannot create capacity.
When should you choose each layout?
- Choose a standard partition when one VPS disk and a predictable file system layout meet your needs. Fewer layers make inspection and rescue simpler.
- Choose LVM when you want to reserve capacity and assign it later to separate application, database or log volumes without moving adjacent partitions.
- Consider LVM when replacing storage: pvmove can relocate allocated extents to another PV while volumes remain in use, provided suitable destination capacity exists.
- Treat redundancy as a separate design decision. A normal linear LV spanning disks has no redundant copy; losing a contributing disk can make its file system unusable.
A plain partition can also grow after a provider enlarges its disk, provided free sectors follow it directly. Another partition behind it can block that extension. LVM avoids requiring adjacent space for an LV, but a partition containing a PV still has its own boundary. Prefer the layout your monitoring, backup and rescue process can reliably support.
How do you create a separate LVM data volume safely?
This example uses an additional empty disk larger than 25 GiB, leaving a reserve after creating a 20 GiB LV. The name /dev/sdX is a placeholder. Replace it only after matching the device size, serial number and provider inventory. The VG name data must not already exist. Run each command separately and stop at any unexpected result.
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS,MODEL,SERIAL
sudo wipefs -n /dev/sdX
sudo pvs
sudo vgs
swapon --showConfirm that the target has no partitions, mounted children, swap use or membership in an existing storage stack. wipefs -n only inspects signatures; an empty result does not prove that valuable data is absent. Confirm ownership and intended disposal of any old contents separately.
The next commands write LVM metadata and create a new file system. Selecting the wrong disk or formatting an existing LV can destroy data. Continue only with the verified empty target and a separate, tested backup of any data you need to retain. Do not add force options to bypass a refusal.
sudo pvcreate /dev/sdX
sudo vgcreate data /dev/sdX
sudo lvcreate -L 20G -n app data
sudo lvs -o lv_path,lv_size,devices data
sudo mkfs.ext4 /dev/data/appBefore mkfs.ext4, confirm that lvs shows the newly created app LV on the checked disk. Mount it at a new, unused directory. If mkdir reports that the directory already exists, stop and inspect it rather than mounting over existing files.
sudo mkdir /mnt/lvm-app
sudo mount /dev/data/app /mnt/lvm-app
findmnt --mountpoint /mnt/lvm-app
df -hT /mnt/lvm-appThis mount lasts only for the current boot. For permanent use, obtain the file system UUID with blkid, prepare the intended mount directory and add a suitable entry to /etc/fstab. Check that configuration before scheduling a reboot. Application ownership and permissions also need to match the service account.
How do you grow an existing logical volume?
For the ext4 example above, first repeat vgs, lvs and findmnt and confirm at least 5 GiB of free space in data. Verify the backup before resizing production storage. Extend the LV once, then grow ext4 to fill it. The plus sign means add 5 GiB; omitting it requests a final size instead.
sudo lvextend -L +5G /dev/data/app
sudo resize2fs /dev/data/appHealthy mounted ext4 file systems on contemporary Linux support online growth. Run resize2fs only after lvextend succeeds. If file system growth fails, inspect the error and current sizes; do not repeat lvextend blindly because it would add another 5 GiB. Never use mkfs to make an existing file system see extra space.
For an existing XFS volume, grow the LV first and use xfs_growfs on its mount point instead of resize2fs. Do not run both file system tools. If the VG has no free space, investigate the lower layers: an enlarged virtual disk may require partition growth and pvresize, or a separately checked new PV can be added with vgextend. Encryption and RAID add their own resizing steps.
How do you verify the result?
Check both the block-device size and the mounted file system. For this example the LV should now be 25 GiB, while df reports somewhat less usable file system capacity because of metadata and accounting. A successful lvextend message alone is not proof that the application gained space.
sudo lvs -o lv_path,lv_size,segtype,devices data
sudo vgs data
findmnt --mountpoint /mnt/lvm-app -o SOURCE,FSTYPE,TARGET
df -hT /mnt/lvm-appConfirm that the intended device is mounted at the intended directory, and check application reads and writes through its normal account. If df still shows the old size, inspect the file system resize result and mount source. If the mount is absent, an application may write into the underlying directory on the root file system instead. Resolve that before returning the service to normal operation.
What should you avoid when shrinking or migrating?
Reducing an LV before safely shrinking its file system can cut off live data. ext4 shrinking requires an unmounted file system and an appropriate check. For XFS, plan a migration to a smaller new file system rather than assuming your installed distribution supports shrinking. Do not experiment on a production root volume.
Creating a PV over an existing ext4 partition is not an in-place conversion. For ordinary administration, migrate to separate storage instead. Keep the source intact until the destination has been checked and a rollback remains possible.
- Prepare the new file system and a verified backup, and arrange console access for changes that may affect booting.
- Copy data with a method that preserves the ownership, permissions, ACLs and extended attributes your application uses.
- Stop writers or use an application-supported consistency procedure before the final copy. A live database directory is not automatically a valid backup.
- Update mount configuration and application paths, test the service and retain the old storage until you have verified recovery.
Moving the root file system also involves the initramfs and boot loader. Details depend on the distribution and boot mode; use its documented recovery procedure. A separate /boot is common in some layouts, but it does not mean that Linux cannot boot with its root file system on LVM.
How do you keep capacity changes predictable?
- Leave a deliberate reserve in the VG and monitor both file system usage and VG free space. Assigning all free space immediately removes flexibility.
- Keep backups on independent storage and test restoration. A snapshot on the same disks cannot protect against their loss.
- Size and monitor classic snapshots for changed blocks; exhausting their allocated space invalidates them. Coordinate snapshots with the application for consistent recovery.
- Treat thin provisioning as a separate design. Thin pools need monitoring of both data and metadata usage; a large virtual LV size does not guarantee physical capacity.
Record the device map and mount configuration after changes. Keep a copy of LVM metadata with vgcfgbackup and include /etc/lvm in your recovery documentation. This records volume definitions, not the files inside them, and cannot replace a data backup.
How does CH-J Tools help with disk layouts?
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; it can be loaded again with sudo. It covers Linux block devices only.
In Alpha 0.1.1, changes are first queued as a plan for review. If the layout has changed since the plan was created, the job stops without changing anything. Steps that can lose data warn you to make a separate backup first.
Frequently asked questions
Does LVM make a server faster?
LVM is primarily a storage management choice. Performance depends on the backing devices, workload and LV type. Do not choose a linear LV expecting an automatic speed increase; measure the application on the intended storage.
Can I use LVM on one disk?
Yes. One PV can form a VG containing several LVs. You gain flexible allocation of reserved capacity, but no protection against that disk failing.
Why is df full when vgs shows free space?
df describes a mounted file system; vgs describes unallocated VG capacity. Check the mount source, extend the correct LV and then grow its file system with the appropriate tool.
Is LVM the same as RAID?
No. LVM can create RAID logical volumes, but a default linear volume has no redundancy. Check the segment type with lvs and verify the underlying storage design.
Can I return from LVM to a plain partition?
Usually by creating a file system on separate storage, copying data consistently and switching mounts. Plan additional boot configuration work for a root file system and keep a tested rollback path.