Skip to contentSkip to conversation

Concise LVM Summary

linux-lvm [email protected] 3 participants 5 messages Apr 8, 2006 – Apr 12, 2006

lore
Share & tools
lore
#0 lore raw

I'm trying to write a perl script to give concise output of pvs, vgs, lvs, pvdisplay, vgdisplay, lvdisplay and df -- something like:

VG home [PE (4MB): 0 (0 b) / 52205 (203.93 GB)]
LV /dev/home/lvol0 /home [LE: 52205 (203.93 GB); DF: 64G/201G (129G) 34%]
PV /dev/sdb [PE (4096KB): 0 (0 b) / 38156 (149.05 GB); DF: ??/149G (??) ??%]
PV /dev/hdb4 [PE (4096KB): 0 (0 b) / 14049 (54.88 GB); DF: ??/55G (??) ??%]

however, there are a few things I have yet to figure out:

- determine the actual disk usage of a particular PV in a given LV
- the lvs column option which produces the heading "Log"
- the nature of the pvs,vgs,lvs separator inconsistencies:

lvs - Headers and LV lines are separator terminated vgs - Headers not separator terminated, VG lines are pvs - Headers not separator terminated, PV lines are

- The unabreviated names of the column headings
(a website detailing each would be nice)
- whether pvdisplay,vgdisplay,lvdisplay offer anything more than pvs, vgs, lvs with all columns displayed
- Why the majority of pvs,vgs,lvs columns lack data

I'm still working on the code, but the above are the major stumbling blocks I've come across so far...

TIA!

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

#1 lore raw

vgdisplay -v <VG>| grep -B2 Total
-?-

Quoted 15 lines

VG home [PE (4MB): 0 (0 b) / 52205 (203.93 GB)]
LV /dev/home/lvol0 /home [LE: 52205 (203.93 GB); DF: 64G/201G (129G) 34%]
PV /dev/sdb [PE (4096KB): 0 (0 b) / 38156 (149.05 GB); DF: ??/149G (??) ??%]
PV /dev/hdb4 [PE (4096KB): 0 (0 b) / 14049 (54.88 GB); DF: ??/55G (??) ??%]

however, there are a few things I have yet to figure out:

- determine the actual disk usage of a particular PV in a given LV

- whether pvdisplay,vgdisplay,lvdisplay offer anything more than pvs, vgs, lvs with all columns displayed

Signature · 2 lines
"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
#2 lore raw
In reply to [email protected]

You can pretty much print things how you want by specifying the right things on the command line. 'lvs' and friends will default to printing out certain columns, but you can change that.

prompt> lvs --noheadings # print things out without the headings prompt> lvs --noheadings -o lv_name #print just the lv names prompt> lvs --noheadings -o lv_name, uuid #print the lv names and their uuid etc

for a more complete list, see the various man pages

brassow

Quoted 46 lines · On Apr 8, 2006, at 4:11 PM, <[email protected]> wrote:

I'm trying to write a perl script to give concise output of pvs, vgs, lvs, pvdisplay, vgdisplay, lvdisplay and df -- something like:

VG home [PE (4MB): 0 (0 b) / 52205 (203.93 GB)]
LV /dev/home/lvol0 /home [LE: 52205 (203.93 GB); DF: 64G/201G (129G) 34%]
PV /dev/sdb [PE (4096KB): 0 (0 b) / 38156 (149.05 GB); DF: ??/149G (??) ??%]
PV /dev/hdb4 [PE (4096KB): 0 (0 b) / 14049 (54.88 GB); DF: ??/55G (??) ??%]

however, there are a few things I have yet to figure out:

- determine the actual disk usage of a particular PV in a given LV
- the lvs column option which produces the heading "Log"
- the nature of the pvs,vgs,lvs separator inconsistencies:

lvs - Headers and LV lines are separator terminated vgs - Headers not separator terminated, VG lines are pvs - Headers not separator terminated, PV lines are

- The unabreviated names of the column headings
(a website detailing each would be nice)
- whether pvdisplay,vgdisplay,lvdisplay offer anything more than pvs, vgs, lvs with all columns displayed
- Why the majority of pvs,vgs,lvs columns lack data

I'm still working on the code, but the above are the major stumbling blocks I've come across so far...

TIA!

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

_______________________________________________
linux-lvm mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/

#3 lore raw

lvs,pvs,vgs each provide for output of specified columns (with optional headers and field separators); HOWEVER this is still limited as (at least on my debian pkg) PV and LV commands cannot be combined, thus negating the possibility of anything even as simple as:

# vgs -o vg_name,lv_name,pv_name
  Can't report LV and PV fields at the same time

Also, the man pages (at least those provided with the debian pkg) aren't particularly detailed. They list some (but not all) of the possible column headers and even exclude one of the default column headers (I have no idea what optional column generates the "Log" header).

While this can be segmented into separate commands, the whole idea was concise presentation. I'm basically using perl to parse the output of vgs,lvs,pvs with full columns and output the pertitent (at least to me anyway) information.

I still haven't figured out how to figure out the disk usage of a particular PV in a given LV. To illustrate:

# vgdisplay -v | grep -B3 Free
    Finding all volume groups
    Finding volume group "home"
  PE Size               4.00 MB
  Total PE              52205
  Alloc PE / Size       52205 / 203.93 GB
  Free  PE / Size       0 / 0
--
  PV Name               /dev/sdb
  PV UUID               zTUa5N-NtiP-6aMh-6WJi-d3Xk-MSwN-enKL2P
  PV Status             allocatable
  Total PE / Free PE    38156 / 0
--
  PV Name               /dev/hdb4
  PV UUID               9QYlyj-1dS2-NkVQ-fmZ5-v5bp-N9J6-qirHn6
  PV Status             allocatable
  Total PE / Free PE    14049 / 0

This returns the number of allocated PEs of a given PV to a particular VG, but does not offer any indication of actual disk usage of those PE on the PV in the LV. Similarly:

# vgs -o vg_name,devices
  VG   Devices
  home /dev/sdb(0)
  home /dev/hdb4(0)

Reveals which PVs are allocated to which VG -- but none of the options appear to offer anything akin to df specific to a particular PV in the LV. I'm looking for something like:

~# df -h /home
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/home-lvol0

                      201G   72G  122G  38% /home

But with a per PV breakdown -- someting like (numbers made up):

VG home               Size  Used Avail Use% Mounted on
LV /dev/home/lvol0    201G   72G  122G  38% /home
PV /dev/sdb(0)        160G   50G  110G  31%

PV /dev/hdb4(0) 41G 22G 19G 54%

Quoted 10 lines · --- Jonathan E Brassow

You can pretty much print things how you want by specifying the right things on the command line. 'lvs' and friends will default to printing out certain columns, but you can change that.

prompt> lvs --noheadings # print things out without the headings prompt> lvs --noheadings -o lv_name #print just the lv names prompt> lvs --noheadings -o lv_name, uuid #print the lv names and their uuid
etc

Quoted 3 lines

for a more complete list, see the various man pages

brassow

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

#4 lore raw
Quoted 4 lines · On Tue, 2006-04-11 at 21:17 -0700, [email protected] wrote:

lvs,pvs,vgs each provide for output of specified columns (with optional headers and field separators); HOWEVER this is still limited as (at least on my debian pkg) PV and LV commands cannot be combined, thus negating the possibility of anything even as simple as:

Of course, but you said you were using a perl script to put the info together. Using the commands as suggested makes them easier to parse.

You should be able to figure out how full a PV is that is part of an LV, but I'm not sure you can determine what parts of a pv an lv uses - or how much space an lv uses of a pv.

For example:
prompt> lvs --noheadings -o devices vg/lv
/dev/sda(0)
/dev/sdb(0)
prompt> pvs --noheadings -o pv_used,pv_size /dev/sda
17.15G 17.15G

So, you can use vgs to get the vg names, lvs to get the lv names in those vgs and the devices they live on, and pvs to get basic usage.

If you want to do more, you might consider looking at /etc/lvm/backup/<vg name>

brassow