The primary method for using lvm thin provisioning:
1. Create ThinDataLV
Create an LV that will hold thin pool data.
lvcreate -n ThinDataLV -L LargeSize VG
Example
# lvcreate -n pool0 -L 10G vg
2. Create ThinMetaLV
Create an LV that will hold thin pool metadata.
lvcreate -n ThinMetaLV -L SmallSize VG
Example
# lvcreate -n pool0meta -L 1G vg
# lvs
LV VG Attr LSize
pool0 vg -wi-a----- 10.00g
pool0meta vg -wi-a----- 1.00g
3. Create ThinPoolLV
Combine the data and metadata LVs into a thin pool LV.
ThinDataLV is renamed to hidden ThinPoolLV_tdata.
ThinMetaLV is renamed to hidden ThinPoolLV_tmeta.
The new ThinPoolLV takes the previous name of ThinDataLV.
lvconvert --type thin-pool --poolmetadata VG/ThinMetaLV
VG/ThinDataLV
Example
# lvconvert --type thin-pool --poolmetadata vg/pool0meta vg/pool0
# lvs vg/pool0
LV VG Attr LSize Pool Origin Data% Meta%
pool0 vg twi-a-tz-- 10.00g 0.00 0.00
# lvs -a
LV VG Attr LSize
pool0 vg twi-a-tz-- 10.00g
[pool0_tdata] vg Twi-ao---- 10.00g
[pool0_tmeta] vg ewi-ao---- 1.00g
4. Create ThinLV
Create a new thin LV from the thin pool LV.
The thin LV is created with a virtual size.
Multiple new thin LVs may be created in the thin pool.
Thin LV names must be unique in the VG.
The '--type thin' option is inferred from the virtual size option.
The --thinpool argument specifies which thin pool will
contain the ThinLV.
lvcreate -n ThinLV -V VirtualSize --thinpool ThinPoolLV VG
Example
Create a thin LV in a thin pool:
# lvcreate -n thin1 -V 1T --thinpool pool0 vg
Create another thin LV in the same thin pool:
# lvcreate -n thin2 -V 1T --thinpool pool0 vg
# lvs vg/thin1 vg/thin2
LV VG Attr LSize Pool Origin Data%
thin1 vg Vwi-a-tz-- 1.00t pool0 0.00
thin2 vg Vwi-a-tz-- 1.00t pool0 0.00
5. Create SnapLV
Create snapshots of an existing ThinLV or SnapLV.
Do not specify -L
, --size
when creating a thin snapshot.
A size argument will cause an old COW snapshot to be created.
lvcreate -n SnapLV --snapshot VG/ThinLV
lvcreate -n SnapLV --snapshot VG/PrevSnapLV
Example
Create first snapshot of an existing ThinLV:
# lvcreate -n thin1s1 -s vg/thin1
Create second snapshot of the same ThinLV:
# lvcreate -n thin1s2 -s vg/thin1
Create a snapshot of the first snapshot:
# lvcreate -n thin1s1s1 -s vg/thin1s1
# lvs vg/thin1s1 vg/thin1s2 vg/thin1s1s1
LV VG Attr LSize Pool Origin
thin1s1 vg Vwi---tz-k 1.00t pool0 thin1
thin1s2 vg Vwi---tz-k 1.00t pool0 thin1
thin1s1s1 vg Vwi---tz-k 1.00t pool0 thin1s1
6. Activate SnapLV
Thin snapshots are created with the persistent "activation skip"
flag, indicated by the "k" attribute. Use -K with lvchange or
vgchange to activate thin snapshots with the "k" attribute.
lvchange -ay -K VG/SnapLV
Example
# lvchange -ay -K vg/thin1s1
# lvs vg/thin1s1
LV VG Attr LSize Pool Origin
thin1s1 vg Vwi-a-tz-k 1.00t pool0 thin1