LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-05-2022, 12:04 PM   #1
trytwowheels
LQ Newbie
 
Registered: Feb 2022
Posts: 1

Rep: Reputation: 0
LVM Thin Provisioning and total LV allocation


I'm fairly experienced with Logical Volume Manager (LVM), though my knowledge is about 15 years old. So... Thin LVM is new to me. I'm using thin LVM within Proxmox. I'd like to see my total logical volume allocation. Not utilization (that's visible with "lvs", but allocation).

So far, only way I figured out is using "lvs", and summing via awk, paste, and bc. That seems awkward to me.

So, my lvs output looks like this:

Code:
root@green:/home/cburkins# /usr/sbin/lvs
  LV                                            VG  Attr       LSize    Pool Origin        Data%  Meta%  Move Log Cpy%Sync Convert
  data                                          pve twi-aotz-- <831.06g                    40.93  5.15                            
  root                                          pve -wi-ao----   96.00g                                                           
  snap_vm-102-disk-0_Complete_Initial_Install   pve Vri---tz-k   32.00g data vm-102-disk-0                                        
  snap_vm-103-disk-0_complete_initial_install   pve Vri---tz-k   20.00g data vm-103-disk-0                                        
  snap_vm-114-disk-0_snap01_afterInstall        pve Vri---tz-k   32.00g data vm-114-disk-0                                        
  snap_vm-123-disk-0_snap01_afterInstall        pve Vri---tz-k   32.00g data vm-123-disk-0                                        
  snap_vm-123-disk-0_snap02_afterUpdatesAndUser pve Vri---tz-k   32.00g data vm-123-disk-0                                        
  swap                                          pve -wi-ao----    8.00g                                                           
  vm-100-disk-0                                 pve Vwi-a-tz--   20.00g data               43.42                                  
  vm-101-disk-0                                 pve Vwi-a-tz--   32.00g data               0.00                                   
  vm-102-disk-0                                 pve Vwi-a-tz--   41.00g data               95.31                                  
  vm-103-disk-0                                 pve Vwi-a-tz--   20.00g data               57.81                                  
  vm-104-disk-0                                 pve Vwi-a-tz--   32.00g data               29.55                                  
  vm-105-disk-0                                 pve Vwi-a-tz--   15.00g data               78.38                                  
  vm-106-disk-0                                 pve Vwi-aotz--   32.00g data               19.35                                  
  vm-107-disk-0                                 pve Vwi-a-tz--   32.00g data               22.39                                  
  vm-108-disk-0                                 pve Vwi-aotz--   16.00g data               85.33                                  
  vm-109-disk-0                                 pve Vwi-aotz--   50.00g data               94.11                                  
  vm-110-disk-0                                 pve Vwi-a-tz--   32.00g data               90.19                                  
  vm-110-disk-1                                 pve Vwi-a-tz--    4.00m data               3.12                                   
  vm-111-disk-0                                 pve Vwi-a-tz--   10.00g data               83.61                                  
  vm-112-disk-0                                 pve Vwi-aotz--   10.00g data               80.00                                  
  vm-113-disk-0                                 pve Vwi-a-tz--   32.00g data               27.13                                  
  vm-114-disk-0                                 pve Vwi-a-tz--   32.00g data               33.32                                  
  vm-115-disk-0                                 pve Vwi-a-tz--   32.00g data               27.42                                  
  vm-116-disk-0                                 pve Vwi-a-tz--   32.00g data               21.68                                  
  vm-117-disk-0                                 pve Vwi-a-tz--   32.00g data               28.90                                  
  vm-118-disk-0                                 pve Vwi-a-tz--   32.00g data               37.52                                  
  vm-119-disk-0                                 pve Vwi-a-tz--   32.00g data               36.17                                  
  vm-120-disk-0                                 pve Vwi-aotz--   16.00g data               97.21                                  
  vm-121-disk-0                                 pve Vwi-a-tz--   10.00g data               79.50                                  
  vm-122-disk-0                                 pve Vwi-a-tz--   32.00g data               42.21                                  
  vm-123-disk-0                                 pve Vwi-a-tz--   32.00g data               34.63                                  
  vm-124-disk-0                                 pve Vwi-aotz--   32.00g data               9.83                                   
  vm-125-disk-0                                 pve Vwi-a-tz--  300.00g data               0.00                                   
  vm-126-disk-0                                 pve Vwi-a-tz--  400.00g data               0.00

This appears to be a mixture of LV and VG information. Everything start with a "vm-###' is a logical volume. While "pve" is a volume group".

I can see the utilization of the volume group "pve" as 40.93%, that's handy.

But I want to know how much I've actually allocated out of that volume group.

So I did this:


Code:
root@green:/home/cburkins# /usr/sbin/lvs | egrep -e "^  vm" | grep 'g ' | awk '{print $4}' | sed -e 's/g//' | paste -s -d+ - | bc 
1388.00
So, I've allocated 1388GB out of the 831GB available (via the magic of thin oversubscription). Cool.

But there must be an easier way to get that number ??

-Chad
 
Old 02-05-2022, 01:52 PM   #2
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,573

Rep: Reputation: 2533Reputation: 2533Reputation: 2533Reputation: 2533Reputation: 2533Reputation: 2533Reputation: 2533Reputation: 2533Reputation: 2533Reputation: 2533Reputation: 2533

Looking at the lvs manpage suggests there's a --units option that would seem to allow the script to be simplified to something like:

Code:
/usr/sbin/lvs --units g | awk '/^  vm/ {total += $4} END{print total}'
Possibly the lvs command could be made to output just the fourth column with --options and only the vm rows with --select.


Last edited by boughtonp; 02-05-2022 at 01:56 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
WARNING: Pool zeroing and 1.00 MiB large chunk size slows down thin provisioning? Yakooza Linux - Newbie 2 09-10-2018 04:00 AM
[SOLVED] Thin Provisioning fails for LVM-backed LXC containers in LXD sundialsvcs Linux - Containers 4 07-05-2017 09:29 PM
LXer: Linux 3.2 goes bigtime on file systems, improves thin provisioning LXer Syndicated Linux News 0 01-06-2012 06:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration