The LVM Datastore 4.0

Overview

The LVM datastore driver provides OpenNebula with the possibility of using LVM volumes instead of plain files to hold the Virtual Images.

It is assumed that the OpenNebula hosts using this datastore will be configured with CLVM, therefore modifying the OpenNebula Volume Group in one host will reflect in the others. There is a special host ($HOST) which belongs to the LVM cluster, that will be the one the OpenNebula uses to speak to when doing LVM operations.

Requirements

OpenNebula Front-end

  • Password-less ssh access to an OpenNebula LVM-enabled host.

OpenNebula LVM Hosts

LVM must be available in the Hosts. The oneadmin user should be able to execute several LVM related commands with sudo passwordlessly.

  • Password-less sudo permission for: lvremove, lvcreate, lvs and dd.
  • LVM2
  • oneadmin needs to belong to the disk group (for KVM).

Configuration

Configuring the System Datastore

To use LVM drivers, the system datastore will work both with shared or as ssh. This sytem datastore will hold only the symbolic links to the block devices, so it will not take much space. See more details on the System Datastore Guide

It will also be used to hold context images and Disks created on the fly, they will be created as regular files.

Configuring LVM Datastores

The first step to create a LVM datastore is to set up a template file for it. In the following table you can see the supported configuration attributes. The datastore type is set by its drivers, in this case be sure to add DS_MAD=lvm and TM_MAD=lvm for the transfer mechanism, see below.

Attribute Description
NAME The name of the datastore
DS_MAD The DS type, use lvm for the LVM datastore
TM_MAD Transfer drivers for the datastore, use lvm, see below
DISK_TYPE Type for the VM disks using images from this datastore. Supported values are: block, file
HOST Any LVM server host (any of them since it assumes they have CLVM). Defaults to localhost
VG_NAME The LVM volume group name. Defaults to vg-one
RESTRICTED_DIRS Paths that can not be used to register images. A space separated list of paths. :!:
SAFE_DIRS If you need to un-block a directory under one of the RESTRICTED_DIRS. A space separated list of paths.
NO_DECOMPRESS Do not try to untar or decompress the file to be registered. Useful for specialized Transfer Managers
LIMIT_TRANSFER_BW Specify the maximum transfer rate in bytes/second when downloading images from a http/https URL. Suffixes K, M or G can be used.

:!: This will prevent users registering important files as VM images and accessing them through their VMs. OpenNebula will automatically add its configuration directories: /var/lib/one, /etc/one and oneadmin's home. If users try to register an image from a restricted directory, they will get the following error message: “Not allowed to copy image file”.

For example, the following examples illustrates the creation of an LVM datastore using a configuration file. In this case we will use the host host01 as one of our OpenNebula LVM-enabled hosts.

<xterm>

cat ds.conf

NAME = production DS_MAD = lvm TM_MAD = lvm VG_NAME = vg-one HOST = host01

onedatastore create ds.conf

ID: 100

onedatastore list
ID NAME            CLUSTER  IMAGES TYPE   TM    
 0 system          none     0      fs     shared
 1 default         none     3      fs     shared

100 production none 0 lvm shared

</xterm>

You can check more details of the datastore by issuing the onedatastore show command.

:!: Note that datastores are not associated to any cluster by default, and they are supposed to be accessible by every single host. If you need to configure datastores for just a subset of the hosts take a look to the Cluster guide.

Using the LVM transfer driver

Host Configuration

The hosts must have LVM2 and have the Volume-Group used in the VG_NAME attributed of the datastore template. CLVM must also be installed and active accross all the hosts that use this datastore.

It's also required to have password-less sudo permission for: lvremove, lvcreate, lvs and dd.

Snapshot size

The default snapshot size is 512Mb. However this can be changed globally in: /var/lib/one/remotes/datastore/lvm/lvm.conf or in a per-vm basis by adding a SIZE attribute inside the disk section of a VM template:

<xterm> … DISK = [ IMAGE_ID = 6, SIZE = 2048 ] … </xterm>

The above code will create a new snapshot of size 2048M.

Tuning & Extending

System administrators and integrators are encouraged to modify these drivers in order to integrate them with their datacenter:

Under /var/lib/one/remotes/:

  • datastore/lvm/lvm.conf: Default values for LVM parameters
    • HOST: Default LVM target host
    • VG_NAME: Default volume group
  • datastore/lvm/cp: Registers a new image. Creates a new logical volume in LVM.
  • datastore/lvm/mkfs: Makes a new empty image. Creates a new logical volume in LVM.
  • datastore/lvm/rm: Removes the LVM logical volume.
  • tm/lvm/ln: Links to the LVM logical volume.
  • tm/lvm/clone: Clones the image by creating a snapshot.
  • tm/lvm/mvds: Saves the image in a new LV for SAVE_AS.