Skip to content

Instantly share code, notes, and snippets.

@therealromster
Created February 15, 2015 08:01
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save therealromster/c79bc7e875ec07aa7146 to your computer and use it in GitHub Desktop.
Save therealromster/c79bc7e875ec07aa7146 to your computer and use it in GitHub Desktop.
lvm2 docker direct-lvm setup
VMTHIN(7) LVMTHIN(7)
NAME
lvmthin — LVM thin provisioning
Thin Terms
ThinDataLV
thin data LV
large LV created in a VG
used by thin pool to store ThinLV blocks
ThinMetaLV
thin metadata LV
small LV created in a VG
used by thin pool to track data block usage
Thin Usage
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
Docker:
* `dm.thinpooldev`
Specifies a custom blockdevice to use for the thin pool.
If using a block device for device mapper storage, ideally lvm2
would be used to create/manage the thin-pool volume that is then
handed to docker to exclusively create/manage the thin and thin
snapshot volumes needed for it's containers. Managing the thin-pool
outside of docker makes for the most feature-rich method of having
docker utilize device mapper thin provisioning as the backing
storage for docker's containers. lvm2-based thin-pool management
feature highlights include: automatic or interactive thin-pool
resize support, dynamically change thin-pool features, automatic
thinp metadata checking when lvm2 activates the thin-pool, etc.
Example use:
``docker -d --storage-opt dm.thinpooldev=/dev/mapper/thin-pool``
edit /etc/docker.conf
DOCKER_OPTS="-d -p /var/run/docker.pid --storage-opt dm.basesize=50G --storage-opt dm.datadev=/dev/data/data --storage-opt dm.metadatadev=/dev/data/metadata"
change to:
DOCKER_OPTS="-d -p /var/run/docker.pid --storage-opt dm.basesize=50G dm.thinpooldev=/dev/mapper/thin-pool"
@vikramkhatri
Copy link

Can you please suggest the DR strategy using the direct-LVM apprach? How do I take backup then use rsync to send those backups to a DR site. In another words, how do I take a snapshot in direct-LVM and then do a tar cvf command (or similar) to do an online copy.

Thanks for your inputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment