[root@client ~]# lvcreate -L 1G -T thin_vg/thinpool Using default stripesize 64.00 KiB. Logical volume "thinpool" created. [root@client ~]# lvdisplay thin_vg/thinpool --- Logical volume --- LV Name thinpool VG Name thin_vg LV UUID ncc3Kh-eZgD-WLQn-F4cq-pPJJ-rYjD-XsTx34 LV Write Access read/write LV Creation host, time client.centos7.study, 2019-07-12 13:02:42 -0700 LV Pool metadata thinpool_tmeta LV Pool data thinpool_tdata LV Status available # open 0 LV Size 1.00 GiB Allocated pool data 0.00% Allocated metadata 0.98% Current LE 256 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:6
[root@client ~]# lvcreate -V 10G -T thin_vg/thinpool -n annathin1 Using default stripesize 64.00 KiB. WARNING: Sum of all thin volume sizes (10.00 GiB) exceeds the size of thin pool thin_vg/thinpool and the size of whole volume group (2.00 GiB)! For thin pool auto extension activation/thin_pool_autoextend_threshold should be below 100. Logical volume "annathin1" created. [root@client ~]# lvdisplay thin_vg --- Logical volume --- LV Name thinpool VG Name thin_vg LV UUID ncc3Kh-eZgD-WLQn-F4cq-pPJJ-rYjD-XsTx34 LV Write Access read/write LV Creation host, time client.centos7.study, 2019-07-12 13:02:42 -0700 LV Pool metadata thinpool_tmeta LV Pool data thinpool_tdata LV Status available # open 2 LV Size 1.00 GiB Allocated pool data 0.00% Allocated metadata 1.07% Current LE 256 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:6 --- Logical volume --- LV Path /dev/thin_vg/annathin1 LV Name annathin1 VG Name thin_vg LV UUID q47tG0-P2xf-CMsw-a2tE-SgWl-gjni-VJD1jA LV Write Access read/write LV Creation host, time client.centos7.study, 2019-07-12 13:09:12 -0700 LV Pool name thinpool LV Status available # open 0 LV Size 10.00 GiB Mapped size 0.00% Current LE 2560 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:8 [root@client /]# mkfs.xfs /dev/thin_vg/annathin1 meta-data=/dev/thin_vg/annathin1 isize=512 agcount=16, agsize=163824 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=2621184, imaxpct=25 = sunit=16 swidth=16 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=16 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 [root@client /]# mkdir /mnt/annathin1 [root@client /]# mount /dev/thin_vg/annathin1 /mnt/annathin1/ [root@client /]# df -Th /mnt/annathin1 Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/thin_vg-annathin1 xfs 10G 33M 10G 1% /mnt/annathin1
copy some files to annathin1
1 2 3 4 5 6 7 8 9
[root@client ]# cp -a /etc/vsftpd/ /mnt/annathin1/ [root@client ]# cp -a /usr/share/doc/man-db-2.6.3/ /mnt/annathin1/ [root@client annathin1]# ll total 0 drwxr-xr-x. 2 root root 113 Jun 2 2017 man-db-2.6.3 drwxr-xr-x. 2 root root 128 Apr 4 12:46 vsftpd [root@client ~]# df -Th /mnt/annathin1/ Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/thin_vg-annathin1 xfs 10G 34M 10G 1% /mnt/annathin1
The vg thin_vg actually only has 1G, but it shows 10G after create thinpool. That is the magical of LVM thinpool. Note: users are not supposed to exceed actual 1G volume even though it shows having 10G volume, otherwise it will destory the filesystem!
[root@client ~]# lvcreate -s -l 99 -n thinpool_snapshot /dev/thin_vg/annathin1 Using default stripesize 64.00 KiB. WARNING: Sum of all thin volume sizes (10.00 GiB) exceeds the size of thin pools and the size of whole volume group (2.00 GiB)! For thin pool auto extension activation/thin_pool_autoextend_threshold should be below 100. Logical volume "thinpool_snapshot" created. [root@client ~]# lvdisplay /dev/thin_vg/thinpool_snapshot --- Logical volume --- LV Path /dev/thin_vg/thinpool_snapshot LV Name thinpool_snapshot VG Name thin_vg LV UUID 4fYojx-SvHi-5IVX-aoIk-RxpD-8Nlb-1hHK3g LV Write Access read/write LV Creation host, time client.centos7.study, 2019-07-14 17:01:32 -0700 LV snapshot status active destination for annathin1 LV Status available # open 0 LV Size 10.00 GiB Current LE 2560 COW-table size 396.00 MiB COW-table LE 99 Allocated to snapshot 0.02% Snapshot chunk size 4.00 KiB Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:11
[root@client ~]# lvdisplay /dev/thin_vg/annathin1 --- Logical volume --- LV Path /dev/thin_vg/annathin1 LV Name annathin1 VG Name thin_vg LV UUID q47tG0-P2xf-CMsw-a2tE-SgWl-gjni-VJD1jA LV Write Access read/write LV Creation host, time client.centos7.study, 2019-07-12 13:09:12 -0700 LV snapshot status source of thinpool_snapshot [active] LV Pool name thinpool LV Status available # open 1 LV Size 10.00 GiB Mapped size 0.12% Current LE 2560 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:8
Due to snapshot, /dev/thin_vg/annathin1 and /dev/thin_vg/thinpool_snapshot have same uuid. When mount to mount point, users need to use “nouuid” arguments.
[root@client man-db-2.6.3]# lvdisplay /dev/thin_vg/thinpool_snapshot --- Logical volume --- LV Path /dev/thin_vg/thinpool_snapshot LV Name thinpool_snapshot VG Name thin_vg LV UUID eT1j03-4v5E-7fUi-BSV0-6dun-RCL1-fy9atx LV Write Access read/write LV Creation host, time client.centos7.study, 2019-07-14 17:18:16 -0700 LV snapshot status active destination for annathin1 LV Status available # open 1 LV Size 10.00 GiB Current LE 2560 COW-table size 396.00 MiB COW-table LE 99 Allocated to snapshot 0.52% Snapshot chunk size 4.00 KiB Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:11
It shows the snapshot has been used 0.52%
next, we will restore annathin1 by snapshot, we will backup snapshot first.