[linux-lvm] Difference between Debian and some other distributions with thin provisioning

Jan Tulak jtulak at redhat.com
Fri Sep 29 16:42:49 UTC 2017

Hi guys,
I found out this difference and I'm not sure what is the cause. A
command for creating a thin LV, which works on Archlinux, Centos and
Fedora, fails on Debian and Ubuntu:

lvm lvcreate FOOvg1 \
    -T \
    -l 100%PVS \
    -n FOOvg1_thin001 \
    /dev/loop0 /dev/loop1 /dev/loop2

When it is created, lvs shows attributes "twi-a-tz--". But Debian and
Ubuntu complain that  "--name may only be given when creating a new
thin Logical volume or snapshot," even though the command states it
should be thin with -T. A script that tests this issue is at the end
of this email

Do you know if there is a reason for this different behaviour?
Versions seem to be close enough for it not to be a change in LVM
behaviour, so I suspect some downstream or configuration changes. All
tested distributions were run in their current stable versions, up to
date. For example:

# cat /etc/debian_version
# lvm version
  LVM version:     2.02.111(2) (2014-09-01)
  Library version: 1.02.90 (2014-09-01)
  Driver version:  4.27.0

# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
# lvm version
  LVM version:     2.02.171(2)-RHEL7 (2017-05-03)
  Library version: 1.02.140-RHEL7 (2017-05-03)
  Driver version:  4.35.0



#!/usr/bin/env bash

# Test how the current distribution behaves when creating a thin LV.
# Centos, Fedora and Archlinux pass the test,
# but Debian and Ubuntu do not.

if [ $(whoami) != "root" ]; then
    echo "Need to be root!"
    exit 1

if [ $(losetup -a |wc -l) -ne 0 ]; then
    echo "Some loopback devices are already there."
    echo "I don't want to screw up anything and it is not worth of making"
    echo "any autodetection, so I will just stop now."
    exit 1

echo "setting up"

# create files for loop devices
dd if=/dev/zero bs=1M count=150 of=/tmp/0 &>/dev/null
dd if=/dev/zero bs=1M count=150 of=/tmp/1 &>/dev/null
dd if=/dev/zero bs=1M count=150 of=/tmp/2 &>/dev/null

# create loop devices
losetup -f /tmp/0 >/dev/null
losetup -f /tmp/1 >/dev/null
losetup -f /tmp/2 >/dev/null

# create PVs
pvcreate /dev/loop0 >/dev/null
pvcreate /dev/loop1 >/dev/null
pvcreate /dev/loop2 >/dev/null

# create VG
vgcreate FOOvg1 /dev/loop0 /dev/loop1 /dev/loop2 >/dev/null

# create thin lv
echo "running the test:"
echo "lvm lvcreate FOOvg1 \\
    -T \\
    -l 100%PVS \\
    -n FOOvg1_thin001 \\
    /dev/loop0 /dev/loop1 /dev/loop2"
echo ""


lvm lvcreate FOOvg1 \
    -T \
    -l 100%PVS \
    -n FOOvg1_thin001 \
    /dev/loop0 /dev/loop1 /dev/loop2

# test if it worked - if yes, lvs will see the LV with thin attr
echo ""
if [ $(lvs | grep "FOOvg1_thin001" | grep -c "twi-a-tz--") -eq 1 ]; then
    echo "result: it works"
    echo "result: it doesn't work"

# ---
# just cleanup

echo "Cleaning up..."

yes | lvremove  FOOvg1/FOOvg1_thin001 &>/dev/null
vgremove FOOvg1 >/dev/null
pvremove /dev/loop0 >/dev/null
pvremove /dev/loop1 >/dev/null
pvremove /dev/loop2 >/dev/null

losetup -d /dev/loop0 >/dev/null
losetup -d /dev/loop1 >/dev/null
losetup -d /dev/loop2 >/dev/null

More information about the linux-lvm mailing list