2014-03-14 01:19:05 +04:00
.TH "LVMTHIN" "7" "LVM TOOLS #VERSION#" "Red Hat, Inc" "\""
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.SH NAME
2021-04-13 16:26:54 +03:00
.
2014-06-11 13:06:30 +04:00
lvmthin \(em LVM thin provisioning
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.SH DESCRIPTION
2021-04-13 16:26:54 +03:00
.
2017-05-03 00:47:02 +03:00
Blocks in a standard \fBlvm\fP(8) Logical Volume (LV) are allocated when
the LV is created, but blocks in a thin provisioned LV are allocated as
they are written. Because of this, a thin provisioned LV is given a
virtual size, and can then be much larger than physically available
storage. The amount of physical storage provided for thin provisioned LVs
can be increased later as the need arises.
2021-04-13 16:26:54 +03:00
.P
2017-05-03 00:47:02 +03:00
Blocks in a standard LV are allocated (during creation) from the Volume
Group (VG), but blocks in a thin LV are allocated (during use) from a
special "thin pool LV". The thin pool LV contains blocks of physical
storage, and blocks in thin LVs just reference blocks in the thin pool LV.
2021-04-13 16:26:54 +03:00
.P
2014-04-04 01:20:15 +04:00
A thin pool LV must be created before thin LVs can be created within it.
A thin pool LV is created by combining two standard LVs: a large data LV
2014-03-14 01:19:05 +04:00
that will hold blocks for thin LVs, and a metadata LV that will hold
metadata. The metadata tracks which data blocks belong to each thin LV.
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
Snapshots of thin LVs are efficient because the data blocks common to a
2014-05-14 18:44:09 +04:00
thin LV and any of its snapshots are shared. Snapshots may be taken of
thin LVs or of other thin snapshots. Blocks common to recursive snapshots
are also shared in the thin pool. There is no limit to or degradation
from sequences of snapshots.
2021-04-13 16:26:54 +03:00
.P
2014-04-04 01:20:15 +04:00
As thin LVs or snapshot LVs are written to, they consume data blocks in
2014-03-14 01:19:05 +04:00
the thin pool. As free data blocks in the pool decrease, more free blocks
may need to be supplied. This is done by extending the thin pool data LV
with additional physical space from the VG. Removing thin LVs or
snapshots from the thin pool can also free blocks in the thin pool.
However, removing LVs is not always an effective way of freeing space in a
thin pool because the amount is limited to the number of blocks not shared
with other LVs in the pool.
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
Incremental block allocation from thin pools can cause thin LVs to become
fragmented. Standard LVs generally avoid this problem by allocating all
the blocks at once during creation.
2021-04-13 16:26:54 +03:00
.
.SH THIN TERMS
.
2014-03-14 01:19:05 +04:00
.TP
ThinDataLV
.br
thin data LV
.br
large LV created in a VG
.br
used by thin pool to store ThinLV blocks
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.TP
ThinMetaLV
.br
thin metadata LV
.br
small LV created in a VG
.br
used by thin pool to track data block usage
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.TP
ThinPoolLV
.br
thin pool LV
.br
combination of ThinDataLV and ThinMetaLV
.br
contains ThinLVs and SnapLVs
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.TP
ThinLV
.br
thin LV
.br
created from ThinPoolLV
.br
appears blank after creation
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.TP
SnapLV
.br
snapshot LV
.br
created from ThinPoolLV
.br
appears as a snapshot of another LV after creation
2024-02-27 19:16:55 +03:00
.TP
ExternalOriginLV
.br
external origin LV
.br
read-only LV used for unprovisioned blocks of a thin LV
.br
2021-04-13 16:26:54 +03:00
.
.SH THIN USAGE
.
2014-03-14 01:19:05 +04:00
The primary method for using lvm thin provisioning:
2021-04-13 16:26:54 +03:00
.nr step 1 1
.
.SS \n[step]. Create ThinDataLV
.
2014-06-11 01:58:45 +04:00
Create an LV that will hold thin pool data.
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
.B lvcreate -n ThinDataLV -L LargeSize VG
2021-04-13 16:26:54 +03:00
.P
2014-06-11 01:58:45 +04:00
.I Example
.br
2017-03-27 17:45:48 +03:00
# lvcreate -n pool0 -L 10G vg
2021-04-13 16:26:54 +03:00
.
.SS \n+[step]. Create ThinMetaLV
.
2014-06-11 01:58:45 +04:00
Create an LV that will hold thin pool metadata.
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
.B lvcreate -n ThinMetaLV -L SmallSize VG
2021-04-13 16:26:54 +03:00
.P
2014-06-11 01:58:45 +04:00
.I Example
.br
2017-03-27 17:45:48 +03:00
# lvcreate -n pool0meta -L 1G vg
2021-04-13 16:26:54 +03:00
.P
2014-06-11 01:58:45 +04:00
# lvs
LV VG Attr LSize
2017-03-27 17:45:48 +03:00
pool0 vg -wi-a----- 10.00g
pool0meta vg -wi-a----- 1.00g
2021-04-13 16:26:54 +03:00
.
.SS \n+[step]. Create ThinPoolLV
.
2014-06-18 23:28:50 +04:00
.nf
2014-06-11 01:58:45 +04:00
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.
2014-06-18 23:28:50 +04:00
.fi
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
.B lvconvert --type thin-pool --poolmetadata VG/ThinMetaLV VG/ThinDataLV
2021-04-13 16:26:54 +03:00
.P
2014-06-11 01:58:45 +04:00
.I Example
.br
2017-03-27 17:45:48 +03:00
# lvconvert --type thin-pool --poolmetadata vg/pool0meta vg/pool0
2021-04-13 16:26:54 +03:00
.P
2014-06-11 01:58:45 +04:00
# lvs vg/pool0
LV VG Attr LSize Pool Origin Data% Meta%
2017-03-27 17:45:48 +03:00
pool0 vg twi-a-tz-- 10.00g 0.00 0.00
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
# lvs -a
2014-06-11 01:58:45 +04:00
LV VG Attr LSize
2017-03-27 17:45:48 +03:00
pool0 vg twi-a-tz-- 10.00g
[pool0_tdata] vg Twi-ao---- 10.00g
[pool0_tmeta] vg ewi-ao---- 1.00g
2021-04-13 16:26:54 +03:00
.
.SS \n+[step]. Create ThinLV
.
2014-06-18 23:28:50 +04:00
.nf
2014-06-11 01:58:45 +04:00
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.
2017-03-27 17:45:48 +03:00
The '--type thin' option is inferred from the virtual size option.
The --thinpool argument specifies which thin pool will
2014-06-11 01:58:45 +04:00
contain the ThinLV.
2014-06-18 23:28:50 +04:00
.fi
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
.B lvcreate -n ThinLV -V VirtualSize --thinpool ThinPoolLV VG
2021-04-13 16:26:54 +03:00
.P
2014-06-11 01:58:45 +04:00
.I Example
.br
Create a thin LV in a thin pool:
.br
2017-03-27 17:45:48 +03:00
# lvcreate -n thin1 -V 1T --thinpool pool0 vg
2021-04-13 16:26:54 +03:00
.P
2014-06-11 01:58:45 +04:00
Create another thin LV in the same thin pool:
.br
2017-03-27 17:45:48 +03:00
# lvcreate -n thin2 -V 1T --thinpool pool0 vg
2021-04-13 16:26:54 +03:00
.P
2014-06-11 01:58:45 +04:00
# lvs vg/thin1 vg/thin2
LV VG Attr LSize Pool Origin Data%
2017-03-27 17:45:48 +03:00
thin1 vg Vwi-a-tz-- 1.00t pool0 0.00
thin2 vg Vwi-a-tz-- 1.00t pool0 0.00
2021-04-13 16:26:54 +03:00
.
.SS \n+[step]. Create SnapLV
.
2014-06-11 01:58:45 +04:00
Create snapshots of an existing ThinLV or SnapLV.
2014-06-18 23:28:50 +04:00
.br
Do not specify
2017-03-27 17:45:48 +03:00
.BR -L ", " --size
2014-06-18 23:28:50 +04:00
when creating a thin snapshot.
.br
A size argument will cause an old COW snapshot to be created.
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
.B lvcreate -n SnapLV --snapshot VG/ThinLV
2014-06-11 01:58:45 +04:00
.br
2017-03-27 17:45:48 +03:00
.B lvcreate -n SnapLV --snapshot VG/PrevSnapLV
2021-04-13 16:26:54 +03:00
.P
2014-06-11 01:58:45 +04:00
.I Example
.br
Create first snapshot of an existing ThinLV:
.br
2017-03-27 17:45:48 +03:00
# lvcreate -n thin1s1 -s vg/thin1
2021-04-13 16:26:54 +03:00
.P
2014-06-11 01:58:45 +04:00
Create second snapshot of the same ThinLV:
.br
2017-03-27 17:45:48 +03:00
# lvcreate -n thin1s2 -s vg/thin1
2021-04-13 16:26:54 +03:00
.P
2014-06-11 01:58:45 +04:00
Create a snapshot of the first snapshot:
.br
2017-03-27 17:45:48 +03:00
# lvcreate -n thin1s1s1 -s vg/thin1s1
2021-04-13 16:26:54 +03:00
.P
2014-06-11 01:58:45 +04:00
# lvs vg/thin1s1 vg/thin1s2 vg/thin1s1s1
LV VG Attr LSize Pool Origin
2017-03-27 17:45:48 +03:00
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
2021-04-13 16:26:54 +03:00
.
2023-07-04 22:34:37 +03:00
.SS \n+[step]. Create ThinLV with ThinPoolLV
.
Create a new thin LV together with thin pool LV and let lvm2
to allocate data and metadata volume.
.P
.B lvcreate -T -n ThinLV -V VirtualSize -L PoolSize VG/ThinPoolLV
.P
.I Example
.br
Create a 50MiB thin LV and 10MiB thin pool:
.br
# lvcreate -T -n thin -V 52M -L 12M vg/pool
.P
# lvs -a vg
LV VG Attr LSize Pool Origin Data% Meta%
[lvol0_pmspare] vg ewi------- 4,00m
pool vg twi-aotz-- 12,00m 0,00 10,94
[pool_tdata] vg Twi-ao---- 12,00m
[pool_tmeta] vg ewi-ao---- 4,00m
thin vg Vwi-a-tz-- 52,00m pool 0,00
.
2021-04-13 16:26:54 +03:00
.SS \n+[step]. Activate SnapLV
.
2014-06-11 01:58:45 +04:00
Thin snapshots are created with the persistent "activation skip"
2017-03-27 17:45:48 +03:00
flag, indicated by the "k" attribute. Use -K with lvchange
2014-06-11 01:58:45 +04:00
or vgchange to activate thin snapshots with the "k" attribute.
2023-07-04 22:34:37 +03:00
User can preset default behavior with
.BR lvm.conf (5)
.BR auto_set_activation_skip .
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
.B lvchange -ay -K VG/SnapLV
2021-04-13 16:26:54 +03:00
.P
2014-06-11 01:58:45 +04:00
.I Example
.br
2017-03-27 17:45:48 +03:00
# lvchange -ay -K vg/thin1s1
2021-04-13 16:26:54 +03:00
.P
2014-06-11 01:58:45 +04:00
# lvs vg/thin1s1
LV VG Attr LSize Pool Origin
2017-03-27 17:45:48 +03:00
thin1s1 vg Vwi-a-tz-k 1.00t pool0 thin1
2021-04-13 16:26:54 +03:00
.
2023-07-04 22:34:37 +03:00
.SS \n+[step]. Convert thick LV to thin LV
.
Convert existing thick LV (linear, stripe,...) to thin LV with move of
existing data to thin pool and using thin LV from such thin pool.
Once the volume is converted, user is using it like ordinary thin-pool.
2024-02-27 19:16:55 +03:00
Note: Conversion cannot be reverted and the thin volume cannot be reverted
back to the thick LV type.
2023-07-04 22:34:37 +03:00
.P
.B lvconvert --type thin VG/ThickLV
.P
.I Example
.br
Create thick 12MiB LV.
.br
# lvcreate -L 12M -n thick vg
.P
Convert LV to a thin pool with chunk size 256KiB.
.br
# lvconvert --thin --chunksize 256K vg/thick
.P
# lvs -o+chunksize vg
LV VG Attr LSize Pool Origin Data% Meta% Chunk
thick vg Vwi-a-tz-- 12,00m thick_tpool0 100,00 0
thick_tpool0 vg twi---tz-- 12,00m 100,00 10,94 256,00k
.
2024-02-27 19:16:55 +03:00
.SS \n+[step]. Create thin pool with compression and deduplication
2023-12-15 01:21:11 +03:00
.
2024-02-27 19:16:55 +03:00
Create a new thin pool with the use of VDO layer for compression and
2023-12-15 01:21:11 +03:00
deduplication of stored data.
.P
.B lvcreate --type thin-pool --pooldatavdo y VG/PoolLV
.P
.I Example
.br
2024-02-27 19:16:55 +03:00
Create a 10G CompressedPool thin pool with VDO data volume whose
2023-12-15 01:21:11 +03:00
VDO slab size is 4096 MiB.
.br
.nf
# lvcreate --type thin-pool -L10G --pooldatavdo y \\
--vdosettings 'slab_size_mb=4096' VG/CompressedPool
.fi
.
2024-02-27 19:16:55 +03:00
.SS \n+[step]. Convert an LV into a compressed deduplicated thin pool
2023-12-15 01:21:11 +03:00
.
2024-02-27 19:16:55 +03:00
Convert an existing LV (linear, stripe,...) to the thin pool whose
2023-12-15 01:21:11 +03:00
data volume is using VDO layer for compression and deduplication.
.P
.B lvconvert --type thin-pool --pooldatavdo y VG/LV
.P
.I Example
.br
2024-02-27 19:16:55 +03:00
Convert existing BigVolume LV into a compressed thin pool.
2023-12-15 01:21:11 +03:00
.br
# lvconvert --type thin-pool --pooldatavdo y VG/BigVolume
.
2021-04-13 16:26:54 +03:00
.SH THIN TOPICS
.
2014-10-01 19:29:30 +04:00
.B Automatic pool metadata LV
.br
2014-06-11 01:58:45 +04:00
.B Specify devices for data and metadata LVs
2014-03-14 01:19:05 +04:00
.br
2014-06-11 01:58:45 +04:00
.B Tolerate device failures using raid
2014-03-14 01:19:05 +04:00
.br
2014-06-11 01:58:45 +04:00
.B Spare metadata LV
2014-03-14 01:19:05 +04:00
.br
2014-06-11 01:58:45 +04:00
.B Metadata check and repair
2014-03-14 01:19:05 +04:00
.br
2014-06-11 01:58:45 +04:00
.B Activation of thin snapshots
2014-03-14 01:19:05 +04:00
.br
2014-06-11 01:58:45 +04:00
.B Removing thin pool LVs, thin LVs and snapshots
2014-03-14 01:19:05 +04:00
.br
2014-06-11 01:58:45 +04:00
.B Manually manage free data space of thin pool LV
2014-03-14 01:19:05 +04:00
.br
2014-06-11 01:58:45 +04:00
.B Manually manage free metadata space of a thin pool LV
2014-03-14 01:19:05 +04:00
.br
2014-06-11 01:58:45 +04:00
.B Using fstrim to increase free space in a thin pool LV
2014-03-14 01:19:05 +04:00
.br
2014-06-11 01:58:45 +04:00
.B Automatically extend thin pool LV
2014-03-14 01:19:05 +04:00
.br
2014-06-11 01:58:45 +04:00
.B Data space exhaustion
2014-04-04 01:20:15 +04:00
.br
2014-06-11 01:58:45 +04:00
.B Metadata space exhaustion
2014-04-04 01:20:15 +04:00
.br
2015-04-29 18:00:38 +03:00
.B Automatic extend settings
.br
2014-06-11 01:58:45 +04:00
.B Zeroing
2014-03-14 01:19:05 +04:00
.br
2014-06-11 01:58:45 +04:00
.B Discard
2014-03-14 01:19:05 +04:00
.br
2014-06-11 01:58:45 +04:00
.B Chunk size
2014-03-14 01:19:05 +04:00
.br
2014-06-11 01:58:45 +04:00
.B Size of pool metadata LV
2014-03-14 01:19:05 +04:00
.br
2014-06-11 01:58:45 +04:00
.B Create a thin snapshot of an external, read only LV
2014-03-14 01:19:05 +04:00
.br
2014-06-11 01:58:45 +04:00
.B Convert a standard LV to a thin LV with an external origin
2014-03-14 01:19:05 +04:00
.br
2014-06-11 01:58:45 +04:00
.B Single step thin pool LV creation
2014-03-14 01:19:05 +04:00
.br
2014-06-11 01:58:45 +04:00
.B Single step thin pool LV and thin LV creation
2014-03-14 01:19:05 +04:00
.br
2014-06-11 01:58:45 +04:00
.B Merge thin snapshots
2014-05-14 23:05:21 +04:00
.br
2014-06-11 01:58:45 +04:00
.B XFS on snapshots
2021-04-13 16:26:54 +03:00
.
2014-10-01 19:29:30 +04:00
.SS Automatic pool metadata LV
2021-04-13 16:26:54 +03:00
.
2014-10-01 19:29:30 +04:00
A thin data LV can be converted to a thin pool LV without specifying a
thin pool metadata LV. LVM automatically creates a metadata LV from the
same VG.
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
.B lvcreate -n ThinDataLV -L LargeSize VG
2014-10-01 19:29:30 +04:00
.br
2017-03-27 17:45:48 +03:00
.B lvconvert --type thin-pool VG/ThinDataLV
2021-04-13 16:26:54 +03:00
.P
2014-10-01 19:29:30 +04:00
.I Example
.br
.nf
2017-03-27 17:45:48 +03:00
# lvcreate -n pool0 -L 10G vg
# lvconvert --type thin-pool vg/pool0
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
# lvs -a
pool0 vg twi-a-tz-- 10.00g
[pool0_tdata] vg Twi-ao---- 10.00g
[pool0_tmeta] vg ewi-ao---- 16.00m
2014-10-01 19:29:30 +04:00
.fi
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.SS Specify devices for data and metadata LVs
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
The data and metadata LVs in a thin pool are best created on
separate physical devices. To do that, specify the device name(s)
at the end of the lvcreate line. It can be especially helpful
to use fast devices for the metadata LV.
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
.B lvcreate -n ThinDataLV -L LargeSize VG LargePV
2014-06-11 01:58:45 +04:00
.br
2023-07-04 22:34:37 +03:00
.B lvcreate -n ThinMetaLV -L SmallSize VG FastPV
2014-06-11 01:58:45 +04:00
.br
2017-03-27 17:45:48 +03:00
.B lvconvert --type thin-pool --poolmetadata VG/ThinMetaLV VG/ThinDataLV
2021-04-13 16:26:54 +03:00
.P
2014-06-11 01:58:45 +04:00
.I Example
2014-06-18 23:28:50 +04:00
.nf
2017-03-27 17:45:48 +03:00
# lvcreate -n pool0 -L 10G vg /dev/sdA
# lvcreate -n pool0meta -L 1G vg /dev/sdB
# lvconvert --type thin-pool --poolmetadata vg/pool0meta vg/pool0
2014-06-18 23:28:50 +04:00
.fi
2021-04-13 16:26:54 +03:00
.P
2014-04-04 18:50:17 +04:00
.BR lvm.conf (5)
.B thin_pool_metadata_require_separate_pvs
.br
controls the default PV usage for thin pool creation.
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.SS Tolerate device failures using raid
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
To tolerate device failures, use raid for the pool data LV and
pool metadata LV. This is especially recommended for pool metadata LVs.
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
.B lvcreate --type raid1 -m 1 -n ThinMetaLV -L SmallSize VG PVA PVB
2014-06-11 01:58:45 +04:00
.br
2017-03-27 17:45:48 +03:00
.B lvcreate --type raid1 -m 1 -n ThinDataLV -L LargeSize VG PVC PVD
2014-06-11 01:58:45 +04:00
.br
2017-03-27 17:45:48 +03:00
.B lvconvert --type thin-pool --poolmetadata VG/ThinMetaLV VG/ThinDataLV
2021-04-13 16:26:54 +03:00
.P
2014-06-11 01:58:45 +04:00
.I Example
2014-06-18 23:28:50 +04:00
.nf
2017-03-27 17:45:48 +03:00
# lvcreate --type raid1 -m 1 -n pool0 -L 10G vg /dev/sdA /dev/sdB
# lvcreate --type raid1 -m 1 -n pool0meta -L 1G vg /dev/sdC /dev/sdD
# lvconvert --type thin-pool --poolmetadata vg/pool0meta vg/pool0
2014-06-18 23:28:50 +04:00
.fi
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.SS Spare metadata LV
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
The first time a thin pool LV is created, lvm will create a spare
metadata LV in the VG. This behavior can be controlled with the
2017-03-27 17:45:48 +03:00
option --poolmetadataspare y|n. (Future thin pool creations will
2014-03-14 01:19:05 +04:00
also attempt to create the pmspare LV if none exists.)
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
To create the pmspare ("pool metadata spare") LV, lvm first creates
an LV with a default name, e.g. lvol0, and then converts this LV to
a hidden LV with the _pmspare suffix, e.g. lvol0_pmspare.
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
One pmspare LV is kept in a VG to be used for any thin pool.
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
The pmspare LV cannot be created explicitly, but may be removed
explicitly.
2021-04-13 16:26:54 +03:00
.P
2014-06-18 23:28:50 +04:00
.I Example
2014-03-14 01:19:05 +04:00
.nf
2017-03-27 17:45:48 +03:00
# lvcreate -n pool0 -L 10G vg
# lvcreate -n pool0meta -L 1G vg
# lvconvert --type thin-pool --poolmetadata vg/pool0meta vg/pool0
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
# lvs -a
[lvol0_pmspare] vg ewi-------
pool0 vg twi---tz--
[pool0_tdata] vg Twi-------
[pool0_tmeta] vg ewi-------
2014-03-14 01:19:05 +04:00
.fi
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
The "Metadata check and repair" section describes the use of
the pmspare LV.
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.SS Metadata check and repair
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
If thin pool metadata is damaged, it may be repairable.
2021-01-23 02:40:52 +03:00
Checking and repairing thin pool metadata is analogous to
2017-08-24 18:25:01 +03:00
running fsck/repair on a file system.
2021-04-13 16:26:54 +03:00
.P
2023-07-04 22:34:37 +03:00
When a thin pool LV is activated, lvm runs the
.BR thin_check (8)
command to check the correctness of the metadata on the pool metadata LV.
2021-04-13 16:26:54 +03:00
.P
2014-04-04 18:50:17 +04:00
.BR lvm.conf (5)
.B thin_check_executable
.br
2023-07-04 22:34:37 +03:00
can be set to an empty string ("") to disable the
.BR thin_check (8)
step. This is not recommended.
2021-04-13 16:26:54 +03:00
.P
2014-04-04 18:50:17 +04:00
.BR lvm.conf (5)
.B thin_check_options
.br
2023-07-04 22:34:37 +03:00
controls the command options used for the
.BR thin_check (8)
command.
2021-04-13 16:26:54 +03:00
.P
2023-07-04 22:34:37 +03:00
If the
.BR thin_check (8)
command finds a problem with the metadata,
2015-02-06 13:24:30 +03:00
the thin pool LV is not activated, and the thin pool metadata needs
to be repaired.
2021-04-13 16:26:54 +03:00
.P
2015-02-06 13:24:30 +03:00
Simple repair commands are not always successful. Advanced repair may
require editing thin pool metadata and lvm metadata. Newer versions of
the kernel and lvm tools may be more successful at repair. Report the
details of damaged thin metadata to get the best advice on recovery.
2021-04-13 16:26:54 +03:00
.P
2014-04-04 01:20:15 +04:00
Command to repair a thin pool:
2014-06-18 23:28:50 +04:00
.br
2017-03-27 17:45:48 +03:00
.B lvconvert --repair VG/ThinPoolLV
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
Repair performs the following steps:
2021-04-13 16:26:54 +03:00
.P
.nr step 1 1
.IP \n[step] 3
Creates a new, repaired copy of the metadata.
2014-03-14 01:19:05 +04:00
.br
2023-07-04 22:34:37 +03:00
lvconvert runs the
.BR thin_repair (8)
command to read damaged metadata
2014-03-14 01:19:05 +04:00
from the existing pool metadata LV, and writes a new repaired
copy to the VG's pmspare LV.
2021-04-13 16:26:54 +03:00
.IP \n+[step] 3
Replaces the thin pool metadata LV.
2014-03-14 01:19:05 +04:00
.br
If step 1 is successful, the thin pool metadata LV is replaced
with the pmspare LV containing the corrected metadata.
The previous thin pool metadata LV, containing the damaged metadata,
2021-01-23 02:40:52 +03:00
becomes visible with the new name ThinPoolLV_metaN (where N is 0,1,...).
2021-04-13 16:26:54 +03:00
.P
2021-01-23 02:40:52 +03:00
If the repair works, the thin pool LV and its thin LVs can be activated.
User should manually check if repaired thin pool kernel metadata
has all data for all lvm2 known LVs by individual activation of
every thin LV. When all works, user should continue with fsck of
2021-03-05 14:49:54 +03:00
all filesystems present on these volumes.
2021-01-23 02:40:52 +03:00
Once the thin pool is considered fully functional user may remove ThinPoolLV_metaN
(the LV containing the damaged thin pool metadata) for possible
space reuse.
For a better performance it may be useful to pvmove the new repaired metadata LV
2021-03-05 14:49:54 +03:00
(written to previous pmspare volume) to a faster PV, e.g. SSD.
2021-04-13 16:26:54 +03:00
.P
2021-01-23 02:40:52 +03:00
If the repair operation fails, the thin pool LV and its thin LVs
are not accessible and it may be necessary to restore their content
from a backup. In such case the content of unmodified original damaged
ThinPoolLV_metaN volume can be used by your support for more
advanced recovery methods.
2021-04-13 16:26:54 +03:00
.P
2023-07-04 22:34:37 +03:00
If metadata is manually restored with
.BR thin_repair (8)
directly, the pool metadata LV can be manually swapped with another LV
2014-03-14 01:19:05 +04:00
containing new metadata:
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
.B lvconvert --thinpool VG/ThinPoolLV --poolmetadata VG/NewThinMetaLV
2021-04-13 16:26:54 +03:00
.P
2021-01-23 02:40:52 +03:00
Note: Thin pool metadata is compact so even small corruptions
in them may result in significant portions of mappings to be lost.
It is recommended to use fast resilient storage for them.
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.SS Activation of thin snapshots
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
When a thin snapshot LV is created, it is by default given the
"activation skip" flag. This flag is indicated by the "k" attribute
displayed by lvs:
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
.nf
# lvs vg/thin1s1
2014-06-18 23:28:50 +04:00
LV VG Attr LSize Pool Origin
2017-03-27 17:45:48 +03:00
thin1s1 vg Vwi---tz-k 1.00t pool0 thin1
2014-03-14 01:19:05 +04:00
.fi
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
This flag causes the snapshot LV to be skipped, i.e. not activated,
by normal activation commands. The skipping behavior does not
apply to deactivation commands.
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
A snapshot LV with the "k" attribute can be activated using
2017-03-27 17:45:48 +03:00
the -K (or --ignoreactivationskip) option in addition to the
standard -ay (or --activate y) option.
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
Command to activate a thin snapshot LV:
2014-06-18 23:28:50 +04:00
.br
2017-03-27 17:45:48 +03:00
.B lvchange -ay -K VG/SnapLV
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
The persistent "activation skip" flag can be turned off during
2017-03-27 17:45:48 +03:00
lvcreate, or later with lvchange using the -kn
(or --setactivationskip n) option.
It can be turned on again with -ky (or --setactivationskip y).
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
When the "activation skip" flag is removed, normal activation
2017-03-27 17:45:48 +03:00
commands will activate the LV, and the -K activation option is
2014-03-14 01:19:05 +04:00
not needed.
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
Command to create snapshot LV without the activation skip flag:
2014-06-18 23:28:50 +04:00
.br
2017-03-27 17:45:48 +03:00
.B lvcreate -kn -n SnapLV -s VG/ThinLV
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
Command to remove the activation skip flag from a snapshot LV:
2014-06-18 23:28:50 +04:00
.br
2017-03-27 17:45:48 +03:00
.B lvchange -kn VG/SnapLV
2021-04-13 16:26:54 +03:00
.P
2014-04-04 18:50:17 +04:00
.BR lvm.conf (5)
.B auto_set_activation_skip
.br
controls the default activation skip setting used by lvcreate.
2021-04-13 16:26:54 +03:00
.
2014-04-04 01:20:15 +04:00
.SS Removing thin pool LVs, thin LVs and snapshots
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
Removing a thin LV and its related snapshots returns the blocks it
used to the thin pool LV. These blocks will be reused for other
thin LVs and snapshots.
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
Removing a thin pool LV removes both the data LV and metadata LV
and returns the space to the VG.
2021-04-13 16:26:54 +03:00
.P
2014-04-04 01:20:15 +04:00
lvremove of thin pool LVs, thin LVs and snapshots cannot be
2014-03-14 01:19:05 +04:00
reversed with vgcfgrestore.
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
vgcfgbackup does not back up thin pool metadata.
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.SS Manually manage free data space of thin pool LV
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
The available free space in a thin pool LV can be displayed
with the lvs command. Free space can be added by extending
2014-06-11 13:06:30 +04:00
the thin pool LV.
2021-04-13 16:26:54 +03:00
.P
2014-04-04 01:20:15 +04:00
Command to extend thin pool data space:
2014-06-18 23:28:50 +04:00
.br
2017-03-27 17:45:48 +03:00
.B lvextend -L Size VG/ThinPoolLV
2021-04-13 16:26:54 +03:00
.P
2014-06-18 23:28:50 +04:00
.I Example
.br
.nf
2014-03-14 01:19:05 +04:00
1. A thin pool LV is using 26.96% of its data blocks.
# lvs
2014-06-18 23:28:50 +04:00
LV VG Attr LSize Pool Origin Data%
2017-03-27 17:45:48 +03:00
pool0 vg twi-a-tz-- 10.00g 26.96
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
2. Double the amount of physical space in the thin pool LV.
2017-03-27 17:45:48 +03:00
# lvextend -L+10G vg/pool0
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
3. The percentage of used data blocks is half the previous value.
# lvs
2014-06-18 23:28:50 +04:00
LV VG Attr LSize Pool Origin Data%
2017-03-27 17:45:48 +03:00
pool0 vg twi-a-tz-- 20.00g 13.48
2014-03-14 01:19:05 +04:00
.fi
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
Other methods of increasing free data space in a thin pool LV
2021-01-23 02:40:52 +03:00
include removing a thin LV and its related snapshots, or running
2014-03-14 01:19:05 +04:00
fstrim on the file system using a thin LV.
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.SS Manually manage free metadata space of a thin pool LV
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
The available metadata space in a thin pool LV can be displayed
2017-03-27 17:45:48 +03:00
with the lvs -o+metadata_percent command.
2021-04-13 16:26:54 +03:00
.P
2014-04-04 01:20:15 +04:00
Command to extend thin pool metadata space:
2014-06-18 23:28:50 +04:00
.br
2017-03-27 17:45:48 +03:00
.B lvextend --poolmetadatasize Size VG/ThinPoolLV
2021-04-13 16:26:54 +03:00
.P
2014-06-18 23:28:50 +04:00
.I Example
.br
2014-06-11 13:06:30 +04:00
1. A thin pool LV is using 12.40% of its metadata blocks.
2014-03-14 01:19:05 +04:00
.nf
2017-03-27 17:45:48 +03:00
# lvs -oname,size,data_percent,metadata_percent vg/pool0
2014-06-18 23:28:50 +04:00
LV LSize Data% Meta%
pool0 20.00g 13.48 12.40
2014-03-14 01:19:05 +04:00
.fi
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
2. Display a thin pool LV with its component thin data LV and thin metadata LV.
.nf
2017-03-27 17:45:48 +03:00
# lvs -a -oname,attr,size vg
2014-06-18 23:28:50 +04:00
LV Attr LSize
2017-03-27 17:45:48 +03:00
pool0 twi-a-tz-- 20.00g
[pool0_tdata] Twi-ao---- 20.00g
[pool0_tmeta] ewi-ao---- 12.00m
2014-03-14 01:19:05 +04:00
.fi
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
3. Double the amount of physical space in the thin metadata LV.
.nf
2017-03-27 17:45:48 +03:00
# lvextend --poolmetadatasize +12M vg/pool0
2014-03-14 01:19:05 +04:00
.fi
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
4. The percentage of used metadata blocks is half the previous value.
.nf
2017-03-27 17:45:48 +03:00
# lvs -a -oname,size,data_percent,metadata_percent vg
2014-06-18 23:28:50 +04:00
LV LSize Data% Meta%
pool0 20.00g 13.48 6.20
[pool0_tdata] 20.00g
[pool0_tmeta] 24.00m
2014-03-14 01:19:05 +04:00
.fi
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.SS Using fstrim to increase free space in a thin pool LV
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
Removing files in a file system on top of a thin LV does not
generally add free space back to the thin pool. Manually running
the fstrim command can return space back to the thin pool that had
been used by removed files. fstrim uses discards and will not work
if the thin pool LV has discards mode set to ignore.
2021-04-13 16:26:54 +03:00
.P
2014-06-18 23:28:50 +04:00
.I Example
.br
2014-03-14 01:19:05 +04:00
A thin pool has 10G of physical data space, and a thin LV has a virtual
size of 100G. Writing a 1G file to the file system reduces the
free space in the thin pool by 10% and increases the virtual usage
of the file system by 1%. Removing the 1G file restores the virtual
1% to the file system, but does not restore the physical 10% to the
thin pool. The fstrim command restores the physical space to the thin pool.
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
.nf
2017-03-27 17:45:48 +03:00
# lvs -a -oname,attr,size,pool_lv,origin,data_percent,metadata_percent vg
2021-04-13 16:26:54 +03:00
LV Attr LSize Pool Origin Data% Meta%
pool0 twi-a-tz-- 10.00g 47.01 21.03
thin1 Vwi-aotz-- 100.00g pool0 2.70
.P
2017-03-27 17:45:48 +03:00
# df -h /mnt/X
2014-03-14 01:19:05 +04:00
Filesystem Size Used Avail Use% Mounted on
2017-03-27 17:45:48 +03:00
/dev/mapper/vg-thin1 99G 1.1G 93G 2% /mnt/X
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
# dd if=/dev/zero of=/mnt/X/1Gfile bs=4096 count=262144; sync
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
# lvs
2021-04-13 16:26:54 +03:00
pool0 vg twi-a-tz-- 10.00g 57.01 25.26
thin1 vg Vwi-aotz-- 100.00g pool0 3.70
.P
2017-03-27 17:45:48 +03:00
# df -h /mnt/X
/dev/mapper/vg-thin1 99G 2.1G 92G 3% /mnt/X
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
# rm /mnt/X/1Gfile
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
# lvs
2021-04-13 16:26:54 +03:00
pool0 vg twi-a-tz-- 10.00g 57.01 25.26
thin1 vg Vwi-aotz-- 100.00g pool0 3.70
.P
2017-03-27 17:45:48 +03:00
# df -h /mnt/X
/dev/mapper/vg-thin1 99G 1.1G 93G 2% /mnt/X
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
# fstrim -v /mnt/X
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
# lvs
2021-04-13 16:26:54 +03:00
pool0 vg twi-a-tz-- 10.00g 47.01 21.03
thin1 vg Vwi-aotz-- 100.00g pool0 2.70
2014-03-14 01:19:05 +04:00
.fi
2021-04-13 16:26:54 +03:00
.P
2014-05-14 18:44:09 +04:00
The "Discard" section covers an option for automatically freeing data
space in a thin pool.
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.SS Automatically extend thin pool LV
2021-04-13 16:26:54 +03:00
.
2015-01-22 21:52:39 +03:00
The lvm daemon dmeventd (lvm2-monitor) monitors the data usage of thin
pool LVs and extends them when the usage reaches a certain level. The
necessary free space must exist in the VG to extend thin pool LVs.
Monitoring and extension of thin pool LVs are controlled independently.
2021-04-13 16:26:54 +03:00
.P
\(em Monitoring \(em
.P
2015-01-22 21:52:39 +03:00
When a thin pool LV is activated, dmeventd will begin monitoring it by
default.
2021-04-13 16:26:54 +03:00
.sp
2015-01-22 21:52:39 +03:00
Command to start or stop dmeventd monitoring a thin pool LV:
.br
2021-04-13 16:26:54 +03:00
.B lvchange --monitor y|n VG/ThinPoolLV
.sp
2015-01-22 21:52:39 +03:00
The current dmeventd monitoring status of a thin pool LV can be displayed
with the command lvs -o+seg_monitor.
2021-04-13 16:26:54 +03:00
.P
\(em Autoextending \(em
.P
2015-01-22 21:52:39 +03:00
dmeventd should be configured to extend thin pool LVs before all data
space is used. Warnings are emitted through syslog when the use of a thin
pool reaches 80%, 85%, 90% and 95%. (See the section "Data space
exhaustion" for the effects of not extending a thin pool LV.) The point
at which dmeventd extends thin pool LVs, and the amount are controlled
with two configuration settings:
2021-04-13 16:26:54 +03:00
.P
2014-04-04 18:50:17 +04:00
.BR lvm.conf (5)
2014-07-12 00:15:03 +04:00
.B thin_pool_autoextend_threshold
.br
2015-01-22 21:52:39 +03:00
is a percentage full value that defines when the thin pool LV should be
2021-01-23 02:40:52 +03:00
extended. Setting this to 100 disables automatic extension. The minimum
2015-01-22 21:52:39 +03:00
value is 50.
2021-04-13 16:26:54 +03:00
.P
2014-07-12 00:15:03 +04:00
.BR lvm.conf (5)
.B thin_pool_autoextend_percent
2014-04-04 18:50:17 +04:00
.br
2015-01-22 21:52:39 +03:00
defines how much extra data space should be added to the thin pool LV from
the VG, in percent of its current size.
2021-04-13 16:26:54 +03:00
.P
\(em Disabling \(em
.P
2015-01-22 21:52:39 +03:00
There are multiple ways that extension of thin pools could be prevented:
.IP \[bu] 2
If the dmeventd daemon is not running, no monitoring or automatic
extension will occur.
2021-04-13 16:26:54 +03:00
.
2015-01-22 21:52:39 +03:00
.IP \[bu]
Even when dmeventd is running, all monitoring can be disabled with the
lvm.conf monitoring setting.
2021-04-13 16:26:54 +03:00
.
2015-01-22 21:52:39 +03:00
.IP \[bu]
To activate or create a thin pool LV without interacting with dmeventd,
2017-03-27 17:45:48 +03:00
the --ignoremonitoring option can be used. With this option, the command
2015-01-22 21:52:39 +03:00
will not ask dmeventd to monitor the thin pool LV.
2021-04-13 16:26:54 +03:00
.
2015-01-22 21:52:39 +03:00
.IP \[bu]
2021-01-23 02:40:52 +03:00
Setting thin_pool_autoextend_threshold to 100 disables automatic
2015-01-22 21:52:39 +03:00
extension of thin pool LVs, even if they are being monitored by dmeventd.
.P
2014-06-18 23:28:50 +04:00
.I Example
.br
2014-03-14 01:19:05 +04:00
If thin_pool_autoextend_threshold is 70 and thin_pool_autoextend_percent is 20,
whenever a pool exceeds 70% usage, it will be extended by another 20%.
For a 1G pool, using 700M will trigger a resize to 1.2G. When the usage exceeds
840M, the pool will be extended to 1.44G, and so on.
2021-04-13 16:26:54 +03:00
.
2014-04-04 01:20:15 +04:00
.SS Data space exhaustion
2021-04-13 16:26:54 +03:00
.
2015-01-20 19:45:47 +03:00
When properly managed, thin pool data space should be extended before it
2015-01-22 21:52:39 +03:00
is all used (see the section "Automatically extend thin pool LV"). If
2015-01-21 20:08:12 +03:00
thin pool data space is already exhausted, it can still be extended (see
the section "Manually manage free data space of thin pool LV".)
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
The behavior of a full thin pool is configurable with the --errorwhenfull
2015-01-22 21:52:39 +03:00
y|n option to lvcreate or lvchange. The errorwhenfull setting applies
only to writes; reading thin LVs can continue even when data space is
exhausted.
2021-04-13 16:26:54 +03:00
.P
2015-01-22 21:52:39 +03:00
Command to change the handling of a full thin pool:
.br
2021-04-13 16:26:54 +03:00
.B lvchange --errorwhenfull y|n VG/ThinPoolLV
.P
2015-01-22 21:52:39 +03:00
.BR lvm.conf (5)
.B error_when_full
.br
controls the default error when full behavior.
2021-04-13 16:26:54 +03:00
.P
2015-01-22 21:52:39 +03:00
The current setting of a thin pool LV can be displayed with the command:
lvs -o+lv_when_full.
2021-04-13 16:26:54 +03:00
.P
2015-01-22 21:52:39 +03:00
The errorwhenfull setting does not effect the monitoring and autoextend
settings, and the monitoring/autoextend settings do not effect the
errorwhenfull setting. It is only when monitoring/autoextend are not
effective that the thin pool becomes full and the errorwhenfull setting is
applied.
2021-04-13 16:26:54 +03:00
.P
\(em errorwhenfull n \(em
.P
2015-01-20 19:45:47 +03:00
This is the default. Writes to thin LVs are accepted and queued, with the
expectation that pool data space will be extended soon. Once data space
is extended, the queued writes will be processed, and the thin pool will
return to normal operation.
2021-04-13 16:26:54 +03:00
.P
2015-01-20 19:45:47 +03:00
While waiting to be extended, the thin pool will queue writes for up to 60
2015-01-21 20:08:12 +03:00
seconds (the default). If data space has not been extended after this
time, the queued writes will return an error to the caller, e.g. the file
2017-03-27 17:45:48 +03:00
system. This can result in file system corruption for non-journaled file
2017-08-24 18:25:01 +03:00
systems that may require repair. When a thin pool returns errors for writes
2015-02-06 13:24:30 +03:00
to a thin LV, any file system is subject to losing unsynced user data.
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
The 60 second timeout can be changed or disabled with the dm-thin-pool
2015-01-20 19:45:47 +03:00
kernel module option
.B no_space_timeout.
This option sets the number of seconds that thin pools will queue writes.
2015-01-21 20:08:12 +03:00
If set to 0, writes will not time out. Disabling timeouts can result in
the system running out of resources, memory exhaustion, hung tasks, and
deadlocks. (The timeout applies to all thin pools on the system.)
2021-04-13 16:26:54 +03:00
.P
\(em errorwhenfull y \(em
.P
2015-01-20 19:45:47 +03:00
Writes to thin LVs immediately return an error, and no writes are queued.
In the case of a file system, this can result in corruption that may
2017-08-24 18:25:01 +03:00
require fs repair (the specific consequences depend on the thin LV user.)
2021-04-13 16:26:54 +03:00
.P
\(em data percent \(em
.P
2014-04-04 01:20:15 +04:00
When data space is exhausted, the lvs command displays 100 under Data% for
the thin pool LV:
2021-04-13 16:26:54 +03:00
.P
2014-04-04 01:20:15 +04:00
.nf
# lvs vg/pool0
2014-06-18 23:28:50 +04:00
LV VG Attr LSize Pool Origin Data%
2017-03-27 17:45:48 +03:00
pool0 vg twi-a-tz-- 512.00m 100.00
2014-04-04 01:20:15 +04:00
.fi
2021-04-13 16:26:54 +03:00
.P
\(em causes \(em
.P
2015-01-21 20:08:12 +03:00
A thin pool may run out of data space for any of the following reasons:
2021-04-13 16:26:54 +03:00
.
2015-01-21 20:08:12 +03:00
.IP \[bu] 2
Automatic extension of the thin pool is disabled, and the thin pool is not
manually extended. (Disabling automatic extension is not recommended.)
2021-04-13 16:26:54 +03:00
.
2015-01-21 20:08:12 +03:00
.IP \[bu]
The dmeventd daemon is not running and the thin pool is not manually
2014-04-04 01:20:15 +04:00
extended. (Disabling dmeventd is not recommended.)
2021-04-13 16:26:54 +03:00
.
2015-01-21 20:08:12 +03:00
.IP \[bu]
Automatic extension of the thin pool is too slow given the rate of writes
to thin LVs in the pool. (This can be addressed by tuning the
2015-04-29 18:00:38 +03:00
thin_pool_autoextend_threshold and thin_pool_autoextend_percent.
See "Automatic extend settings".)
2021-04-13 16:26:54 +03:00
.
2015-01-21 20:08:12 +03:00
.IP \[bu]
The VG does not have enough free blocks to extend the thin pool.
2021-04-13 16:26:54 +03:00
.
2014-04-04 01:20:15 +04:00
.SS Metadata space exhaustion
2021-04-13 16:26:54 +03:00
.
2014-04-04 01:20:15 +04:00
If thin pool metadata space is exhausted (or a thin pool metadata
operation fails), errors will be returned for IO operations on thin LVs.
2021-04-13 16:26:54 +03:00
.P
2014-04-04 01:20:15 +04:00
When metadata space is exhausted, the lvs command displays 100 under Meta%
for the thin pool LV:
2021-04-13 16:26:54 +03:00
.P
2014-04-04 01:20:15 +04:00
.nf
2017-03-27 17:45:48 +03:00
# lvs -o lv_name,size,data_percent,metadata_percent vg/pool0
2014-06-18 23:28:50 +04:00
LV LSize Data% Meta%
pool0 100.00
2014-04-04 01:20:15 +04:00
.fi
2021-04-13 16:26:54 +03:00
.P
2014-04-04 01:20:15 +04:00
The same reasons for thin pool data space exhaustion apply to thin pool
metadata space.
2021-04-13 16:26:54 +03:00
.P
2014-04-04 01:20:15 +04:00
Metadata space exhaustion can lead to inconsistent thin pool metadata and
inconsistent file systems, so the response requires offline checking and
repair.
2021-04-13 16:26:54 +03:00
.TP 4
1.
Deactivate the thin pool LV, or reboot the system if this is not possible.
.TP
2.
Repair thin pool with lvconvert --repair.
.br
See "Metadata check and repair".
.TP
3.
Extend pool metadata space with lvextend --poolmetadatasize.
.br
See "Manually manage free metadata space of a thin pool LV".
.TP
4.
Check and repair file system.
.
2015-04-29 18:00:38 +03:00
.SS Automatic extend settings
2021-04-13 16:26:54 +03:00
.
2015-04-29 18:00:38 +03:00
Thin pool LVs can be extended according to preset values. The presets
determine if the LV should be extended based on how full it is, and if so
by how much. When dmeventd monitors thin pool LVs, it uses lvextend with
these presets. (See "Automatically extend thin pool LV".)
2021-04-13 16:26:54 +03:00
.P
2015-04-29 18:00:38 +03:00
Command to extend a thin pool data LV using presets:
.br
2017-03-27 17:45:48 +03:00
.B lvextend --use-policies VG/ThinPoolLV
2021-04-13 16:26:54 +03:00
.P
2015-04-29 18:00:38 +03:00
The command uses these settings:
2021-04-13 16:26:54 +03:00
.P
2015-04-29 18:00:38 +03:00
.BR lvm.conf (5)
.B thin_pool_autoextend_threshold
.br
autoextend the LV when its usage exceeds this percent.
2021-04-13 16:26:54 +03:00
.P
2015-04-29 18:00:38 +03:00
.BR lvm.conf (5)
.B thin_pool_autoextend_percent
.br
autoextend the LV by this much additional space.
2021-04-13 16:26:54 +03:00
.P
2015-04-29 18:00:38 +03:00
To see the default values of these settings, run:
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
.B lvmconfig --type default --withcomment
2015-04-29 18:00:38 +03:00
.RS
.B activation/thin_pool_autoextend_threshold
.RE
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
.B lvmconfig --type default --withcomment
2015-04-29 18:00:38 +03:00
.RS
.B activation/thin_pool_autoextend_percent
.RE
2021-04-13 16:26:54 +03:00
.P
2015-04-29 18:00:38 +03:00
To change these values globally, edit
.BR lvm.conf (5).
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
To change these values on a per-VG or per-LV basis, attach a "profile" to
2015-04-29 18:00:38 +03:00
the VG or LV. A profile is a collection of config settings, saved in a
local text file (using the lvm.conf format). lvm looks for profiles in
2021-04-15 14:16:41 +03:00
the profile_dir directory, e.g. \fI#DEFAULT_SYS_DIR#/profile/\fP. Once attached to a VG
2015-04-29 18:00:38 +03:00
or LV, lvm will process the VG or LV using the settings from the attached
profile. A profile is named and referenced by its file name.
2021-04-13 16:26:54 +03:00
.P
2015-04-29 18:00:38 +03:00
To use a profile to customize the lvextend settings for an LV:
2021-04-13 16:26:54 +03:00
.
2015-04-29 18:00:38 +03:00
.IP \[bu] 2
Create a file containing settings, saved in profile_dir.
2021-04-13 16:26:54 +03:00
.br
2015-04-29 18:00:38 +03:00
For the profile_dir location, run:
.br
.B lvmconfig config/profile_dir
2021-04-13 16:26:54 +03:00
.
.IP \[bu]
2015-04-29 18:00:38 +03:00
Attach the profile to an LV, using the command:
.br
2017-03-27 17:45:48 +03:00
.B lvchange --metadataprofile ProfileName VG/ThinPoolLV
2021-04-13 16:26:54 +03:00
.
.IP \[bu]
2015-04-29 18:00:38 +03:00
Extend the LV using the profile settings:
.br
2017-03-27 17:45:48 +03:00
.B lvextend --use-policies VG/ThinPoolLV
2015-04-29 18:00:38 +03:00
.P
.I Example
.br
.nf
# lvmconfig config/profile_dir
2020-09-09 14:22:37 +03:00
profile_dir="#DEFAULT_SYS_DIR#/profile"
2021-04-13 16:26:54 +03:00
.P
2020-09-09 14:22:37 +03:00
# cat #DEFAULT_SYS_DIR#/profile/pool0extend.profile
2015-04-29 18:00:38 +03:00
activation {
2021-04-15 14:16:41 +03:00
.RS
thin_pool_autoextend_threshold=50
thin_pool_autoextend_percent=10
.RE
2015-04-29 18:00:38 +03:00
}
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
# lvchange --metadataprofile pool0extend vg/pool0
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
# lvextend --use-policies vg/pool0
2015-04-29 18:00:38 +03:00
.fi
2021-04-13 16:26:54 +03:00
.P
Notes
.
2015-04-29 18:00:38 +03:00
.IP \[bu] 2
A profile is attached to a VG or LV by name, where the name references a
local file in profile_dir. If the VG is moved to another machine, the
file with the profile also needs to be moved.
2021-04-13 16:26:54 +03:00
.
.IP \[bu]
2015-04-29 18:00:38 +03:00
Only certain settings can be used in a VG or LV profile, see:
.br
2017-03-27 17:45:48 +03:00
.B lvmconfig --type profilable-metadata.
2021-04-13 16:26:54 +03:00
.
.IP \[bu]
2015-04-29 18:00:38 +03:00
An LV without a profile of its own will inherit the VG profile.
2021-04-13 16:26:54 +03:00
.
.IP \[bu]
2015-04-29 18:00:38 +03:00
Remove a profile from an LV using the command:
.br
2017-03-27 17:45:48 +03:00
.B lvchange --detachprofile VG/ThinPoolLV.
2021-04-13 16:26:54 +03:00
.
.IP \[bu]
2015-04-29 18:00:38 +03:00
Commands can also have profiles applied to them. The settings that can be
applied to a command are different than the settings that can be applied
2017-03-27 17:45:48 +03:00
to a VG or LV. See lvmconfig --type profilable-command. To apply a
2015-04-29 18:00:38 +03:00
profile to a command, write a profile, save it in the profile directory,
2017-03-27 17:45:48 +03:00
and run the command using the option: --commandprofile ProfileName.
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.SS Zeroing
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
When a thin pool provisions a new data block for a thin LV, the
new block is first overwritten with zeros. The zeroing mode is
2017-03-27 17:45:48 +03:00
indicated by the "z" attribute displayed by lvs. The option -Z
(or --zero) can be added to commands to specify the zeroing mode.
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
Command to set the zeroing mode when creating a thin pool LV:
2021-04-13 16:26:54 +03:00
.P
.B lvconvert --type thin-pool -Z y|n
2014-09-29 21:26:16 +04:00
.RS
2017-03-27 17:45:48 +03:00
.B --poolmetadata VG/ThinMetaLV VG/ThinDataLV
2014-09-29 21:26:16 +04:00
.RE
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
Command to change the zeroing mode of an existing thin pool LV:
2021-04-13 16:26:54 +03:00
.P
.B lvchange -Z y|n VG/ThinPoolLV
.P
2014-03-14 01:19:05 +04:00
If zeroing mode is changed from "n" to "y", previously provisioned
blocks are not zeroed.
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
Provisioning of large zeroed chunks impacts performance.
2021-04-13 16:26:54 +03:00
.P
2014-04-04 18:50:17 +04:00
.BR lvm.conf (5)
.B thin_pool_zero
.br
controls the default zeroing mode used when creating a thin pool.
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.SS Discard
2021-04-13 16:26:54 +03:00
.
2014-05-14 18:44:09 +04:00
The discard behavior of a thin pool LV determines how discard requests are
handled. Enabling discard under a file system may adversely affect the
file system performance (see the section on fstrim for an alternative.)
Possible discard behaviors:
2021-04-13 16:26:54 +03:00
.P
.B ignore:
Ignore any discards that are received.
.P
.B nopassdown:
Process any discards in the thin pool itself and allow
2017-04-26 23:49:28 +03:00
the no longer needed extents to be overwritten by new data.
2021-04-13 16:26:54 +03:00
.P
.B passdown:
Process discards in the thin pool (as with nopassdown), and
2014-03-14 01:19:05 +04:00
pass the discards down the the underlying device. This is the default
mode.
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
Command to display the current discard mode of a thin pool LV:
2014-06-18 23:28:50 +04:00
.br
2017-03-27 17:45:48 +03:00
.B lvs -o+discards VG/ThinPoolLV
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
Command to set the discard mode when creating a thin pool LV:
2014-06-18 23:28:50 +04:00
.br
2021-04-13 16:26:54 +03:00
.B lvconvert --discards ignore|nopassdown|passdown
2014-07-21 19:28:20 +04:00
.RS
2017-03-27 17:45:48 +03:00
.B --type thin-pool --poolmetadata VG/ThinMetaLV VG/ThinDataLV
2014-07-21 19:28:20 +04:00
.RE
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
Command to change the discard mode of an existing thin pool LV:
2014-06-18 23:28:50 +04:00
.br
2021-04-13 16:26:54 +03:00
.B lvchange --discards ignore|nopassdown|passdown VG/ThinPoolLV
.P
2014-06-18 23:28:50 +04:00
.I Example
2014-03-14 01:19:05 +04:00
.nf
2017-03-27 17:45:48 +03:00
# lvs -o name,discards vg/pool0
2021-04-13 16:26:54 +03:00
pool0 passdown
.P
2017-03-27 17:45:48 +03:00
# lvchange --discards ignore vg/pool0
2014-03-14 01:19:05 +04:00
.fi
2021-04-13 16:26:54 +03:00
.P
2014-04-04 18:50:17 +04:00
.BR lvm.conf (5)
.B thin_pool_discards
.br
controls the default discards mode used when creating a thin pool.
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.SS Chunk size
2021-04-13 16:26:54 +03:00
.
2015-05-27 23:53:01 +03:00
The size of data blocks managed by a thin pool can be specified with the
2017-03-27 17:45:48 +03:00
--chunksize option when the thin pool LV is created. The default unit
2015-05-27 23:53:01 +03:00
is KiB. The value must be a multiple of 64KiB between 64KiB and 1GiB.
2021-04-13 16:26:54 +03:00
.P
2015-05-27 23:53:01 +03:00
When a thin pool is used primarily for the thin provisioning feature, a
larger value is optimal. To optimize for many snapshots, a smaller value
reduces copying time and consumes less space.
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
Command to display the thin pool LV chunk size:
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
.B lvs -o+chunksize VG/ThinPoolLV
2021-04-13 16:26:54 +03:00
.P
2014-06-18 23:28:50 +04:00
.I Example
.nf
2017-03-27 17:45:48 +03:00
# lvs -o name,chunksize
2014-06-18 23:28:50 +04:00
pool0 64.00k
2014-03-14 01:19:05 +04:00
.fi
2021-04-13 16:26:54 +03:00
.P
2014-04-04 18:50:17 +04:00
.BR lvm.conf (5)
.B thin_pool_chunk_size
.br
controls the default chunk size used when creating a thin pool.
2021-04-13 16:26:54 +03:00
.P
2015-05-27 23:53:01 +03:00
The default value is shown by:
.br
2017-03-27 17:45:48 +03:00
.B lvmconfig --type default allocation/thin_pool_chunk_size
2021-04-13 16:26:54 +03:00
.P
.
2014-03-14 01:19:05 +04:00
.SS Size of pool metadata LV
2021-04-13 16:26:54 +03:00
.
2015-05-27 23:53:01 +03:00
The amount of thin metadata depends on how many blocks are shared between
thin LVs (i.e. through snapshots). A thin pool with many snapshots may
need a larger metadata LV. Thin pool metadata LV sizes can be from 2MiB
2021-01-12 19:59:29 +03:00
to approximately 16GiB.
2021-04-13 16:26:54 +03:00
.P
2015-05-27 23:53:01 +03:00
When using lvcreate to create what will become a thin metadata LV, the
2017-03-27 17:45:48 +03:00
size is specified with the -L|--size option.
2021-04-13 16:26:54 +03:00
.P
2015-05-27 23:53:01 +03:00
When an LVM command automatically creates a thin metadata LV, the size is
2017-03-27 17:45:48 +03:00
specified with the --poolmetadatasize option. When this option is not
2015-05-27 23:53:01 +03:00
given, LVM automatically chooses a size based on the data size and chunk
size.
2021-04-13 16:26:54 +03:00
.P
2015-05-27 23:53:01 +03:00
It can be hard to predict the amount of metadata space that will be
needed, so it is recommended to start with a size of 1GiB which should be
enough for all practical purposes. A thin pool metadata LV can later be
manually or automatically extended if needed.
2021-04-13 16:26:54 +03:00
.P
2021-01-12 19:59:29 +03:00
Configurable setting
.BR lvm.conf (5)
.BR allocation / thin_pool_crop_metadata
gives control over cropping to 15.81GiB to stay backward compatible with older
versions of lvm2. With enabled cropping there can be observed some problems when
2023-07-04 22:34:37 +03:00
using volumes above this size with thin tools (i.e.
.BR thin_repair (8)).
2021-01-12 19:59:29 +03:00
Cropping should be enabled only when compatibility is required.
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.SS Create a thin snapshot of an external, read only LV
2021-04-13 16:26:54 +03:00
.
2024-02-27 19:16:55 +03:00
Thin snapshots are typically taken of other thin LVs within the same thin pool.
But it is also possible to create thin snapshot of an external LV
(linear, stripe, thin in different thin pool, ...).
Only read only inactive volumes can be used as an external origin.
Writes to such thin volumes are then stored in its thin pool,
and unwritten parts are served from the external origin volume.
External origins can be actived in read only mode afterwards
and used for many thin volumes.
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
.B lvcreate -n SnapLV -s VG/ExternalOriginLV --thinpool VG/ThinPoolLV
2021-04-13 16:26:54 +03:00
.P
2024-02-27 19:16:55 +03:00
Alternative syntax:
.P
.B lvcreate --type thin -n NewThinLV --thinpool VG/NewThinPoolLV VG/ThinEOriginLV
.P
2014-06-18 23:28:50 +04:00
.I Example
.nf
2017-03-27 17:45:48 +03:00
# lvchange -an vg/lve
# lvchange --permission r vg/lve
# lvcreate -n snaplve -s vg/lve --thinpool vg/pool0
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
# lvs vg/lve vg/snaplve
2014-06-18 23:28:50 +04:00
LV VG Attr LSize Pool Origin Data%
2017-03-27 17:45:48 +03:00
lve vg ori------- 10.00g
snaplve vg Vwi-a-tz-- 10.00g pool0 lve 0.00
2014-03-14 01:19:05 +04:00
.fi
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.SS Convert a standard LV to a thin LV with an external origin
2021-04-13 16:26:54 +03:00
.
2024-02-27 19:16:55 +03:00
A new thin LV replaces existing LV and at the same time,
the existing LV is converted to a new created read only
external origin LV whose name can be given with --originname.
When not specified a default name is in form lvol#.
Unwritten portions for this thin LV are read from the external origin LV.
When thin LV is removed, external origin LV can be again use read write
mode, thus such conversion can be seen as a snapshot of such volume.
2021-04-13 16:26:54 +03:00
.P
2024-02-27 19:16:55 +03:00
Convert ExampleLV into a read only external origin LV with the new name
2014-03-14 01:19:05 +04:00
NewExternalOriginLV, and create a new thin LV that is given the previous
name of ExampleLV.
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
.B lvconvert --type thin --thinpool VG/ThinPoolLV
2014-07-21 19:28:20 +04:00
.RS
2017-03-27 17:45:48 +03:00
.B --originname NewExternalOriginLV VG/ExampleLV
2014-07-21 19:28:20 +04:00
.RE
2021-04-13 16:26:54 +03:00
.P
2014-06-18 23:28:50 +04:00
.I Example
.nf
2017-03-27 17:45:48 +03:00
# lvcreate -n lv_example -L 10G vg
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
# lvs
2017-03-27 17:45:48 +03:00
lv_example vg -wi-a----- 10.00g
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
# lvconvert --type thin --thinpool vg/pool0
--originname lv_external --thin vg/lv_example
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
# lvs
2014-06-18 23:28:50 +04:00
LV VG Attr LSize Pool Origin
2017-03-27 17:45:48 +03:00
lv_example vg Vwi-a-tz-- 10.00g pool0 lv_external
lv_external vg ori------- 10.00g
2024-02-27 19:16:55 +03:00
.P
.fi
Remove thin LV and restore back the original volume lv_example.
.P
.I Example
.nf
# lvremove -f vg/lv_example
.P
# lvs
LV VG Attr LSize Pool Origin
lv_external vg -ri------- 10,00g
.P
# lvchange --permission rw vg/lv_external
.P
# lvrename vg/lv_external vg/lv_example
.P
# lvchange -ay vg/lv_example
.P
# lvs
LV VG Attr LSize Pool Origin
lv_external vg -wi-a----- 10,00g
2014-03-14 01:19:05 +04:00
.fi
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.SS Single step thin pool LV creation
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
A thin pool LV can be created with a single lvcreate command,
rather than using lvconvert on existing LVs.
This one command creates a thin data LV, a thin metadata LV,
and combines the two into a thin pool LV.
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
.B lvcreate --type thin-pool -L LargeSize -n ThinPoolLV VG
2021-04-13 16:26:54 +03:00
.P
2014-06-18 23:28:50 +04:00
.I Example
.nf
2017-03-27 17:45:48 +03:00
# lvcreate --type thin-pool -L8M -n pool0 vg
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
# lvs vg/pool0
2014-06-18 23:28:50 +04:00
LV VG Attr LSize Pool Origin Data%
2017-03-27 17:45:48 +03:00
pool0 vg twi-a-tz-- 8.00m 0.00
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
# lvs -a
pool0 vg twi-a-tz-- 8.00m
[pool0_tdata] vg Twi-ao---- 8.00m
[pool0_tmeta] vg ewi-ao---- 8.00m
2014-03-14 01:19:05 +04:00
.fi
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
.SS Single step thin pool LV and thin LV creation
2021-04-13 16:26:54 +03:00
.
2014-03-14 01:19:05 +04:00
A thin pool LV and a thin LV can be created with a single
lvcreate command. This one command creates a thin data LV,
a thin metadata LV, combines the two into a thin pool LV,
and creates a thin LV in the new pool.
.br
2017-03-27 17:45:48 +03:00
-L LargeSize specifies the physical size of the thin pool LV.
2014-03-14 01:19:05 +04:00
.br
2017-03-27 17:45:48 +03:00
-V VirtualSize specifies the virtual size of the thin LV.
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
.B lvcreate --type thin -V VirtualSize -L LargeSize
2014-09-29 21:26:16 +04:00
.RS
2017-03-27 17:45:48 +03:00
.B -n ThinLV --thinpool VG/ThinPoolLV
2014-09-29 21:26:16 +04:00
.RE
2021-04-13 16:26:54 +03:00
.P
2014-03-14 01:19:05 +04:00
Equivalent to:
2014-06-18 23:28:50 +04:00
.br
2017-03-27 17:45:48 +03:00
.B lvcreate --type thin-pool -L LargeSize VG/ThinPoolLV
2014-06-18 23:28:50 +04:00
.br
2017-03-27 17:45:48 +03:00
.B lvcreate -n ThinLV -V VirtualSize --thinpool VG/ThinPoolLV
2021-04-13 16:26:54 +03:00
.P
2014-06-18 23:28:50 +04:00
.I Example
.nf
2017-03-27 17:45:48 +03:00
# lvcreate -L8M -V2G -n thin1 --thinpool vg/pool0
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
# lvs -a
pool0 vg twi-a-tz-- 8.00m
[pool0_tdata] vg Twi-ao---- 8.00m
[pool0_tmeta] vg ewi-ao---- 8.00m
thin1 vg Vwi-a-tz-- 2.00g pool0
2014-03-14 01:19:05 +04:00
.fi
2021-04-13 16:26:54 +03:00
.
2014-05-14 23:05:21 +04:00
.SS Merge thin snapshots
2021-04-13 16:26:54 +03:00
.
2014-05-14 23:05:21 +04:00
A thin snapshot can be merged into its origin thin LV using the lvconvert
2017-03-27 17:45:48 +03:00
--merge command. The result of a snapshot merge is that the origin thin
2014-05-14 23:05:21 +04:00
LV takes the content of the snapshot LV, and the snapshot LV is removed.
Any content that was unique to the origin thin LV is lost after the merge.
2021-04-13 16:26:54 +03:00
.P
2014-05-14 23:05:21 +04:00
Because a merge changes the content of an LV, it cannot be done while the
LVs are open, e.g. mounted. If a merge is initiated while the LVs are open,
the effect of the merge is delayed until the origin thin LV is next
activated.
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
.B lvconvert --merge VG/SnapLV
2021-04-13 16:26:54 +03:00
.P
2014-06-18 23:28:50 +04:00
.I Example
.nf
2014-05-14 23:05:21 +04:00
# lvs vg
2014-06-18 23:28:50 +04:00
LV VG Attr LSize Pool Origin
2017-03-27 17:45:48 +03:00
pool0 vg twi-a-tz-- 10.00g
thin1 vg Vwi-a-tz-- 100.00g pool0
thin1s1 vg Vwi-a-tz-k 100.00g pool0 thin1
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
# lvconvert --merge vg/thin1s1
2021-04-13 16:26:54 +03:00
.P
2014-05-14 23:05:21 +04:00
# lvs vg
2014-06-18 23:28:50 +04:00
LV VG Attr LSize Pool Origin
2017-03-27 17:45:48 +03:00
pool0 vg twi-a-tz-- 10.00g
thin1 vg Vwi-a-tz-- 100.00g pool0
2014-05-14 23:05:21 +04:00
.fi
2021-04-13 16:26:54 +03:00
.P
2014-06-18 23:28:50 +04:00
.I Example
2014-05-14 23:05:21 +04:00
.nf
Delayed merging of open LVs.
2021-04-13 16:26:54 +03:00
.P
2014-05-14 23:05:21 +04:00
# lvs vg
2014-06-18 23:28:50 +04:00
LV VG Attr LSize Pool Origin
2017-03-27 17:45:48 +03:00
pool0 vg twi-a-tz-- 10.00g
thin1 vg Vwi-aotz-- 100.00g pool0
thin1s1 vg Vwi-aotz-k 100.00g pool0 thin1
2021-04-13 16:26:54 +03:00
.P
2014-05-14 23:05:21 +04:00
# df
2017-03-27 17:45:48 +03:00
/dev/mapper/vg-thin1 100G 33M 100G 1% /mnt/X
/dev/mapper/vg-thin1s1 100G 33M 100G 1% /mnt/Xs
2021-04-13 16:26:54 +03:00
.P
2014-05-14 23:05:21 +04:00
# ls /mnt/X
file1 file2 file3
# ls /mnt/Xs
file3 file4 file5
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
# lvconvert --merge vg/thin1s1
2014-05-14 23:05:21 +04:00
Logical volume vg/thin1s1 contains a filesystem in use.
Delaying merge since snapshot is open.
Merging of thin snapshot thin1s1 will occur on next activation.
2021-04-13 16:26:54 +03:00
.P
2014-05-14 23:05:21 +04:00
# umount /mnt/X
# umount /mnt/Xs
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
# lvs -a vg
2014-06-18 23:28:50 +04:00
LV VG Attr LSize Pool Origin
2017-03-27 17:45:48 +03:00
pool0 vg twi-a-tz-- 10.00g
[pool0_tdata] vg Twi-ao---- 10.00g
[pool0_tmeta] vg ewi-ao---- 1.00g
thin1 vg Owi-a-tz-- 100.00g pool0
[thin1s1] vg Swi-a-tz-k 100.00g pool0 thin1
2021-04-13 16:26:54 +03:00
.P
2017-03-27 17:45:48 +03:00
# lvchange -an vg/thin1
# lvchange -ay vg/thin1
2021-04-13 16:26:54 +03:00
.P
2014-05-14 23:05:21 +04:00
# mount /dev/vg/thin1 /mnt/X
2021-04-13 16:26:54 +03:00
.P
2014-05-14 23:05:21 +04:00
# ls /mnt/X
2014-06-11 13:06:30 +04:00
file3 file4 file5
2014-05-14 23:05:21 +04:00
.fi
2021-04-13 16:26:54 +03:00
.
2014-05-14 23:05:21 +04:00
.SS XFS on snapshots
2021-04-13 16:26:54 +03:00
.
2014-05-14 23:05:21 +04:00
Mounting an XFS file system on a new snapshot LV requires attention to the
file system's log state and uuid. On the snapshot LV, the xfs log will
contain a dummy transaction, and the xfs uuid will match the uuid from the
file system on the origin LV.
2021-04-13 16:26:54 +03:00
.P
2014-05-14 23:05:21 +04:00
If the snapshot LV is writable, mounting will recover the log to clear the
dummy transaction, but will require skipping the uuid check:
2021-04-13 16:26:54 +03:00
.P
# mount /dev/VG/SnapLV /mnt -o nouuid
.P
2019-10-24 18:09:41 +03:00
After the first mount with the above approach, the UUID can subsequently be
changed using:
2021-04-13 16:26:54 +03:00
.P
# xfs_admin -U generate /dev/VG/SnapLV
2023-07-04 22:34:37 +03:00
.br
2021-04-13 16:26:54 +03:00
# mount /dev/VG/SnapLV /mnt
.P
2019-10-24 18:09:41 +03:00
Once the UUID has been changed, the mount command will no longer require
the nouuid option.
2023-07-04 22:34:37 +03:00
.br
2014-05-14 23:05:21 +04:00
If the snapshot LV is readonly, the log recovery and uuid check need to be
skipped while mounting readonly:
2021-04-13 16:26:54 +03:00
.P
# mount /dev/VG/SnapLV /mnt -o ro,nouuid,norecovery
.
2014-04-04 18:50:17 +04:00
.SH SEE ALSO
2021-04-13 16:26:54 +03:00
.
.nh
.ad l
2014-04-04 18:50:17 +04:00
.BR lvm (8),
.BR lvm.conf (5),
2015-04-29 18:00:38 +03:00
.BR lvmconfig (8),
2014-04-04 18:50:17 +04:00
.BR lvcreate (8),
.BR lvconvert (8),
.BR lvchange (8),
.BR lvextend (8),
.BR lvremove (8),
.BR lvs (8),
2021-04-13 16:26:54 +03:00
.P
2023-07-04 22:34:37 +03:00
.BR thin_check (8),
2014-04-04 18:50:17 +04:00
.BR thin_dump (8),
2021-04-13 16:26:54 +03:00
.BR thin_repair (8),
2023-12-15 01:21:11 +03:00
.BR thin_restore (8),
.P
.BR vdoformat (8),
.BR vdostats (8)