For dedicated servers that were purchased as part of a server deal or before 20 October 2021

This article explains how the Logical Volume Manager (LVM) works and what benefits it offers.

On cloud servers, the Logical Volume Manager (LVM) is used to manage the storage space, and it puts a logical layer between the file system and the partitions of the data stores in use. This makes it possible to create a file system that spans multiple partitions and/or volumes. In this way, the storage space of several partitions or data carriers can be combined, for example.

Other Uses of the Logical Volume Manager

The Logical Volume Manager offers the following additional advantages:

  • Logical volumes can be created, enlarged or reduced in size during operation. Formatting the volumes is not necessary. However, the size of the logical volume must be adjusted manually afterwards.

  • Data can be rearranged during operation.

  • Data can be distributed across multiple volumes. This can significantly increase data throughput.

  • Data can be easily mirrored.

  • Snapshots can be created during operation.

Important Terms

The storage space is managed by the Logical Volume Manager on three levels:

Physical Volume: The physical volume represents the lowest level of an LVM. It is a block device that is managed by the Logical Volume Manager. The block device can consist of a datastore (e.g. an SSD) or a partition.

Volume Group: Physical volumes can be grouped into one or more Volume Groups. Volume Groups represent a kind of storage pool that can be extended if necessary.

Logical Volume: Volume Groups are divided into one or more Logical Volumes. Logical Volumes can be used like a normal partition. They can be formatted with any file system and they can be mounted.

When using the Logical Volume Manager, classic partitions are initialised as Physical Volumes (PV), which are assigned to a Volume Group (VG). Logical Volumes (LV) can then be created within this Volume Group and formatted with any file system. The Logical Volume Manager thus enables the simple management of dynamically changeable partitions whose size can be changed without data loss.

LVM: Basic Configuration of the Cloud Server

On Linux Cloud Servers, the Logical Volume Manager (LVM) is used to manage storage space. These Cloud Server are configured so that the system and user data are located together on a single logical volume. This logical volume is mounted under /.

LVM: Basic Configuration of Dedicated Servers

On Linux Dedicated Servers, the Logical Volume Manager (LVM) is used to manage storage space. When you create a Dedicated Server with an IONOS image, not all of the disk space is partitioned when that server ships. This allows you to partition the disk space individually.

When you install an IONOS image with Plesk on the server, approximately 90% of the available disk space is partitioned.

Getting Information About Devices without a Valid Partition Table

You can also use the lsblk command to display information about devices that have a valid partition table created. For example, after you enter the command, you see the following information:

Cloud Servers

[root@localhost ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   80G  0 disk
├─sda1            8:1    0  512M  0 part /boot
└─sda2            8:2    0 79.5G  0 part
  ├─centos-root 253:0    0 77.5G  0 lvm  /
  └─centos-swap 253:1    0    2G  0 lvm  [SWAP]
sr0              11:0    1 1024M  0 rom


Dedicated Servers with Hardware RAID

root@FB84A0:~# lsblk
NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda             8:0    0  1.8T  0 disk
├─sda1          8:1    0    2M  0 part
├─sda2          8:2    0   28G  0 part /
├─sda3          8:3    0  9.3G  0 part [SWAP]
└─sda4          8:4    0  1.8T  0 part
  ├─vg00-usr  253:0    0   20G  0 lvm  /usr
  ├─vg00-var  253:1    0  1.6T  0 lvm  /var
  ├─vg00-home 253:2    0   15G  0 lvm  /home
  └─vg00-opt  253:3    0   20G  0 lvm  /opt
root@FB84A0:~#

Getting Information About a Physical Volume

The pvs command returns information about a physical volume in a configurable form. Here, one line is displayed per physical volume. Example:

Cloud Server

[root@localhost ~]# pvs
  PV         VG     Fmt  Attr PSize   PFree
  /dev/sda2  centos lvm2 a--  <79.47g    0


Dedicated Server mit Hardware-Raid

root@FB84A0:~# pvs
  PV         VG   Fmt  Attr PSize PFree
  /dev/sda4  vg00 lvm2 a--  1.78t 176.02g


Use the pvdisplay command to get extensive information about each physical disk.

Example:

 [root@localhost ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               centos
  PV Size               <79.50 GiB / not usable 30.00 MiB
  Allocatable           yes (but full)
  PE Size               32.00 MiB
  Total PE              2543
  Free PE               0
  Allocated PE          2543
  PV UUID               1ZuY22-LgCo-vvMJ-1RsZ-1WNb-Cl3F-s0xR5t


The pvscan command scans all supported LVM block devices in the system for physical disks. Example:

Cloud Servers

[root@localhost ~]# pvscan
  PV /dev/sda2   VG centos          lvm2 [<79.47 GiB / 0    free]
  Total: 1 [<79.47 GiB] / in use: 1 [<79.47 GiB] / in no VG: 0 [0   ]


Dedicated Servers

root@FB84A0:~# pvscan
  PV /dev/sda4   VG vg00            lvm2 [1.78 TiB / 176.02 GiB free]
  Total: 1 [1.78 TiB] / in use: 1 [1.78 TiB] / in no VG: 0 [0   ]

Viewing Information About Volume Groups

To display volume group information, enter the vgs command. Example:

[root@localhost ~]# vgs
  VG     #PV #LV #SN Attr   VSize   VFree
  centos   1   2   0 wz--n- <79.47g    0


Use the vgdisplay command to get extensive information about each physical disk. Example:

[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name               centos
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <79.47 GiB
  PE Size               32.00 MiB
  Total PE              2543
  Alloc PE / Size       2543 / <79.47 GiB
  Free  PE / Size       0 / 0
  VG UUID               2rnjKm-69u5-xEfb-zWj7-6fxI-9SnN-WzCGK2

Getting Information About Logical Volumes

To query information about logical volumes, enter the lvs command. Example:

[root@localhost ~]# lvs
  LV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root centos -wi-ao---- <77.47g                                                
  swap centos -wi-ao----   2.00g 

Use the vgdisplay command to obtain detailed information about each Logical Volume.
Example:

[root@localhost ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                76LG6l-7eYC-M4ok-bGd2-tfeh-cLdV-WlHcdB
  LV Write Access        read/write
  LV Creation host, time localhost, 2019-09-27 10:58:11 +0000
  LV Status              available
  # open                 2
  LV Size                2.00 GiB
  Current LE             64
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1

  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                w9pndm-91CQ-M1Xs-UYWc-KXoB-zJiC-FbfZEe
  LV Write Access        read/write
  LV Creation host, time localhost, 2019-09-27 10:58:12 +0000
  LV Status              available
  # open                 1
  LV Size                <77.47 GiB
  Current LE             2479
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0

Listing File Systems

To list the file systems and identify the file system, enter the command df -h. The abbreviation df stands for disk free. The -h parameter can be used to display the number of occupied blocks in machine-readable form in giga-, mega-, or kilobytes.

Typically, the disk allocation is divided as follows:

CentOS 7

[root@localhost ~]# df -h

Filesystem                Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   78G  2.2G   76G   3%  /
devtmpfs                  898M     0  898M   0% /dev
tmpfs                     910M     0  910M   0% /dev/shm
tmpfs                     910M  101M  810M  12% /run
tmpfs                     910M     0  910M   0% /sys/fs/cgroup
/dev/sda1                 509M  170M  340M  34% /boot
tmpfs                     182M     0  182M   0% /run/user/0

Ubuntu 18.04

root@localhost:~# df -h

Filesystem             Size  Used Avail Use% Mounted on
udev                   963M     0  963M   0% /dev
tmpfs                  198M  784K  197M   1% /run
/dev/mapper/vg00-lv01   77G  2.5G   71G   4% /
tmpfs                  986M     0  986M   0% /dev/shm
tmpfs                  5.0M     0  5.0M   0% /run/lock
tmpfs                  986M     0  986M   0% /sys/fs/cgroup
/dev/sda1              464M   60M  377M  14% /boot
tmpfs                  197M     0  197M   0% /run/user/0

/dev/mapper/centos-root or /dev/mapper/vg00-lv01 denote the logical volume mounted under / in the above examples. This contains almost the entire memory space. tmpfs is a RAM disk. This is mounted under /dev/shm. /dev/sda1 is the boot partition. This is mounted under /boot.

Listing Hard Disks and Partitions

To list the existing hard disks and partitions, enter the command fdisk -l /dev/sda. fdisk is a command line program for partitioning hard disks. With this program, you can view, create, or delete partitions. After entering this command, the partitioning of the hard disk is displayed:

CentOS 7

[root@localhost ~]# fdisk -l

Disk /dev/sda: 80 GiB, 85899345920 bytes, 167772160 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xe68dc2ef

Device     Boot  Start       End   Sectors  Size Id Type
/dev/sda1  *      2048    999423    997376  487M 83 Linux
/dev/sda2       999424 167772159 166772736 79.5G 8e Linux LVM

Disk /dev/mapper/vg00-lv01: 77.6 GiB, 83336626176 bytes, 162766848 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/vg00-lv00: 1.9 GiB, 2046820352 bytes, 3997696 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Ubuntu 18.04

root@localhost:~# fdisk -l

Disk /dev/sda: 80 GiB, 85899345920 bytes, 167772160 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xe68dc2ef

Device     Boot  Start       End   Sectors  Size Id Type
/dev/sda1  *      2048    999423    997376  487M 83 Linux
/dev/sda2       999424 167772159 166772736 79.5G 8e Linux LVM

Disk /dev/mapper/vg00-lv01: 77.6 GiB, 83336626176 bytes, 162766848 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/vg00-lv00: 1.9 GiB, 2046820352 bytes, 3997696 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Creating a New Logical Volume on the Server

To create a new logical volume, the following steps are required:

  • To display volume group information, enter the vgdisplay command.

  • Make a note of the volume group you want to use.

  • To create a logical volume, enter the following command:

    lvcreate -L 20G -n VOL GROUP

    The following example creates the volume group vg00 with a size of 20 GB.

    root@localhost:~# lvcreate -L 20G -n lv00 vg00

  • To use the space, you must create the file system on the logical volume. Examples:

    mkfs.xfs

    mkfs.ext

For more information, see the following information:

Cloud Servers:

Adjusting Logical Volumes After Increasing an SSD Size

Dedicated Servers:

Adjusting Logical Volumes

Dedicated Server - For servers managed in the Control Panel:

Increasing the Size of an Existing Volume on the Server