User Tools

Site Tools


public:iscsi:lvm

LVM devices

The Logical Volume Manager (LVM) is used to create logical partitions on top of local hard disks or iSCSI disks. The use of LVM offers the following advantages:

  • Isolated partitions for hard disk images and user data can be created on common storage devices.
  • LVM partitons allow the creation of snapshots.
  • LVM partitions are easier to resize than physical partitions.
  • Access to LVM devices on distributed file systems is limited to one client only by LVM.

The use of LVM always involves the following devices:

  • LVM physical volumes: the underlying hard disks or block devices
  • LVM volume groups: they can combine physical volumes to one bigger device
  • LVM logical volumes: they are created inside volume groups and are used as block devices

LVM devices on KVM hosts

Information to LVM devices can be displayed with the short commands pws, vgs and lvs - a short command for each type of LVM device:

root@kvm55:~# pvs
  PV         VG           Fmt  Attr PSize   PFree
  /dev/dm-2  vg3_nas      lvm2 a-   499.98g    0 
  /dev/dm-4  vg3_dbserver lvm2 a-     4.98g    0 
  /dev/sda4  vg           lvm2 a-     1.79t 1.58t
root@kvm55:~# vgs
  VG           #PV #LV #SN Attr   VSize   VFree
  vg             1   2   0 wz--n-   1.79t 1.58t
  vg3_dbserver   1   1   0 wz--n-   4.98g    0 
  vg3_nas        1   1   0 wz--n- 499.98g    0 
root@kvm55:~# lvs
  LV              VG           Attr   LSize   Origin …
  images          vg           -wi-ao 200.00g
  lv_dbslave5501  vg           -wi-a-  20.00g
  lv_dbserver5501 vg3_dbserver -wi-ao   4.98g
  lv_nas5501      vg3_nas      -wi-ao 499.98g

Some information are especially important and are related to information displayed also by other tools:

499.98g, 4.98g
The device sizes are almost identical with the sizes displayed by multipath.

dm-2, dm-4
These DM devices are used to access the iSCSI storage. They have to be identical to the DM devices displayed by multipath.

-wi-ao, -wi-a-
The attributes of the logical volumes provide information about the state of the volumes. A complete overview over the attributes is delivered by the man page of lvs. The most important information give the flags 'a' for 'active' and 'o' for 'in use' (open).

If in doubt about the state of devices the scan commands can be used. They are also helpful to activate LVM devices created on other hosts like e.g. LVM partitions on iSCSI devices:

root@kvm55:~# pvscan 
  PV /dev/dm-4   VG vg3_dbserver   lvm2 [4.98 GiB / 0    free]
  PV /dev/sda4   VG vg             lvm2 [1.79 TiB / 1.58 TiB free]
  PV /dev/dm-2   VG vg3_nas        lvm2 [499.98 GiB / 0    free]
  Total: 3 [2.28 TiB] / in use: 3 [2.28 TiB] / in no VG: 0 [0   ]
root@kvm55:~# vgscan 
  Reading all physical volumes.  This may take a while...
  Found volume group "vg3_dbserver" using metadata type lvm2
  Found volume group "vg" using metadata type lvm2
  Found volume group "vg3_nas" using metadata type lvm2
root@kvm55:~# lvscan 
  ACTIVE         '/dev/vg3_dbserver/lv_dbserver5501' [4.98 GiB] inherit
  ACTIVE         '/dev/vg/images' [200.00 GiB] inherit
  ACTIVE         '/dev/vg/lv_dbslave5501' [20.00 GiB] inherit
  ACTIVE         '/dev/vg3_nas/lv_nas5501' [499.98 GiB] inherit

The LVM configuration currently active in the kernel can be got with the following command:

root@kvm55:~# lvm dumpconfig

In case the LVM configuration file '/etc/lvm/lvm.conf' is missing, the current configuration can be written to this file and afterwards serve as base for own adjustments:

root@kvm55:~# lvm dumpconfig >/etc/lvm/lvm.conf

It is important, to adapt the configuration file before the first LVM devices are created in order to prevent problems with the mapping of LVM devices to multipath devices.

LVM devices on virtual host

Normally DM devices are exclusively managed on KVM hosts. LVM partitions or partition images stored on LVM partitions are then used inside the virtual hosts.

But sometimes it is also necessary, to create further LVM partitions inside virtual hosts. The additional use of LVM inside virtual hosts is no problem. It has only to be noted, that LVM partitions defined inside virtual hosts could also be visible from the KVM host. The commands pws, vgs, and lvs mentioned above then also display LVM partitions created not directly on the KVM host. These partitions can be recognized by the fact that they are related to LVM groups not defined on the KVM host.

It should be avoided to operate on LVM devices defined inside virtual hosts from the KVM host. The virtual host is often not able to recognize status changes of his LVM devices caused from the outside. Prevent outside access reliably if necessary.

previous chapter | contents | next chapter

public/iscsi/lvm.txt · Last modified: 2024/06/07 07:55 by Thomas Kornack