Enabling direct-lvm mode for devicemapper storage drivers.
This document (7018751) is provided subject to the disclaimer at the end of this document.
Environment
SUSE Linux Enterprise Server 12 Service Pack 1 (SLES 12 SP1)
Situation
The following error is generated when Docker is using "devicemapper" storage drivers with default configuration known as "loop-lvm" :
Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
Resolution
The "direct-lvm" mode uses block devices for creating the thin pool instead of loopback devices, to remove the WARNING message and set up the container to use a block device, perform the following steps :
(note: this procedure assumes that a spare block device is available, than substitute /dev/sdX):
- Stop Docker:
systemctl stop docker.service
- Install LVM2 package, when not installed already:
zypper in lvm2
- Create a physical volume :
pvcreate /dev/sdX
- Create a "docker" volume group :
vgcreate docker /dev/sdX
- Create a logical volume named thinpool and thinpoolmeta :
lvcreate --wipesignatures y -n thinpool docker -l 95%VG && lvcreate --wipesignatures y -n thinpoolmeta docker -l 1%VGNOTE: The data logical volume is adviced to be 95% of the volume group size to leave free space for auto expanding the data or metadata (in case the disk space runs low).
- Convert the pool to a thin pool :
lvconvert -y --zero n -c 512K --thinpool docker/thinpool --poolmetadata docker/thinpoolmeta
- Configure auto extension of thin pools via an lvm profile:
vi /etc/lvm/profile/docker-thinpool.profile
Insert the following lines:
activation {
thin_pool_autoextend_threshold=80
thin_pool_autoextend_percent=20
}
- Apply the lvm profile :
lvchange --metadataprofile docker-thinpool docker/thinpool
- Move the graph driver:
mkdir /var/lib/docker.bk && mv /var/lib/docker/* /var/lib/docker.bk
(Important note : Moving the graph driver also remove images, containers and volumes !!!)
- Configure the Docker option to use the newly created block device:
vi /etc/sysconfig/docker
Insert the following:
DOCKER_OPTS="-s devicemapper --storage-opt=dm.thinpooldev=/dev/mapper/docker-thinpool"
NOTE: Alternatively, you can specify the option "--storage-opt" when launching containers with "docker run".
- Reload systemd for applying the changes :
systemctl daemon-reload
- Start Docker:
systemctl start docker.service
- Verify that the WARNING has disappeared :
docker info
Cause
With "loop-lvm" mode, Docker is using a loopback device to build the thin pool used by image and container snapshots, this configuration is the default one for "devicemapper" storage drivers and it is strongly discouraged in a production environment.
Additional Information
Disclaimer
This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.
- Document ID:7018751
- Creation Date: 29-Mar-2017
- Modified Date:03-Mar-2020
-
- SUSE Linux Enterprise Server
For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com