< 3 Volume Group Administration | Commands | 5 Snapshots >
26. Overview
https://www.udemy.com/course/a-complete-guide-on-linux-lvm/learn/lecture/13062374#overview
- Thin Provisioning allows you to over commit the storage and create LVs that are larger than the available extents.
Example:
- PV1 & PV2 are both 50GB
- VG1 = 100GB
- Create a Thin Pool = Size of VG (100GB)
- It can be smaller and can be increased later.
- You can now create 3 LVs whos combined space is larger than the actual space available.
- Each disk will only use what it is using, not how much was assigned to it!
27. Thin Pool Setup
https://www.udemy.com/course/a-complete-guide-on-linux-lvm/learn/lecture/13062392#overview
- Setup: 2 drives, /sdg1, sdh 2GB each
- Use lvdisplay to see usage parameters after it has been created
# Create the Physical Volumes pvcreate /dev/sdg1 /dev/sdh1 # Create the VG vgcreate /dev/vg_thin /dev/sdg1 /dev/sdh1 # Create the thin pool # This is similar to creating an LV lvcreate -L 3GB --thinpool thin_pool vg_thin # Create a thin volume lvcreate -V 1G --thin -n thin_vol1 vg_thin/thin_pool lvcreate -V 1G --thin -n thin_vol2 vg_thin/thin_pool lvcreate -V 1G --thin -n thin_vol3 vg_thin/thin_pool
28 & 29 Lab
# Format the volumes mkfs -t ext4 /dev/vg_thin/thin_vol1 mkfs -t ext4 /dev/vg_thin/thin_vol2 mkfs -t ext4 /dev/vg_thin/thin_vol3 # mount the volumes mkdir /mnt/tv1 mount /dev/vg_thin/thin_vol1 mkdir /mnt/tv2 mount /dev/vg_thin/thin_vol2 mkdir /mnt/tv3 mount /dev/vg_thin/thin_vol3 # View space taken lvdisplay /dev/vg_thin/thin_pool LV Size 3.00GiB Allocated Pool data 4.79%
Create a 4th LV
# This will over provision the 3GB thin_pool size lvcreate -V 1G --thin -n thin_vol4 vg_thin/thin_pool # It will give a warning, but will provision it!
29. Format, mount, and check the used space.
mkfs -t ext4 /dev/vg_thin/thin_vol4 mkdir /mnt/tv4 mount /dev/vg_thin_thin_vol4 /mnt/tv4 # Copy some files to all drives. cp 250mb.file /mnt/tv1 cp 250mb.file /mnt/tv2 cp 250mb.file /mnt/tv3 cp 250mb.file /mnt/tv4 # check used space (fake values, some used for formatting) lvdisplay /dev/vg_thin/thin_pool LV Size 3.00GiB Allocated Pool Data 33.3%
If you need to add additional Space:
- Extend the thin_pool by take some/all of the remaining space in the Volume Group
- Add a new PV to the Volume Group, then extend
lvextend -L +500MB /dev/vg_thin/thin_pool
