Red Hat Bugzilla – Bug 190730
lvdisplay -c uses incorrect size units
Last modified: 2007-11-30 17:11:31 EST
From the man page of lvdisplay
Generate colon separated output for easier parsing in scripts or
programs. N.B. lvs (8) provides considerably more control over
The values are:
* logical volume name
* volume group name
* logical volume access
* logical volume status
* internal logical volume number
* open count of logical volume
* logical volume size in kilobytes
* current logical extents associated to logical volume
* allocated logical extents of logical volume
* allocation policy of logical volume
* read ahead sectors of logical volume
* major device number of logical volume
* minor device number of logical volume
So the 7th field should print out the size of the LV in kb. However, on
checking up on it, it appears to be printing the size in 512byte sectors. Note
how in this example, the count in lvdisplay differs from the count in lvdisplay
-c by exactly a factor of 2.
[root@erwin info]# lvdisplay /dev/vg00/root --units k
--- Logical volume ---
LV Name /dev/vg00/root
VG Name vg00
LV UUID Ifyj3F-nV6n-XQxa-xfn1-IupD-T62P-iXvBYB
LV Write Access read/write
LV Status available
# open 1
LV Size 41943040.00 KB
Current LE 10240
Read ahead sectors 0
Block device 253:0
[root@erwin info]# lvdisplay /dev/vg00/root -c
Volume size is in 512byte sectors. There is bug in man page.
Better use lvs in lvm2 environment.
The -c output is provided only for compatibility with LVM1, and is supposed to
produce output close to that produced by LVM1.
New scripts should be using 'lvs' instead.
Unsure which would be the least disruptive way to fix this discrepancy.
So should lvdisplay -c be considered depracated in favor of lvs? And if so, is
this formally mentioned in thedocs anywhere beyond man page just mentioning lvs
as an alternative?
Fix to man page checked in. Closing as NEXTRELEASE.
If this is inadequate and/or anyone cares to comment, feel free.
I did a quick run with a 64MB LV on upstream lvm2 and a lvm1 on a rhel3.9
machine. Both lvm1 and lvm2 display the LV size in sectors so the man page
change seems warranted.
The summary of differences in output for "lvdisplay -c" is as follows:
* logical volume name - SAME
* volume group name - SAME
* logical volume access - SAME
* logical volume status - SAME
* internal logical volume number - '0' (lvm1), '-1' (lvm2)
* open count of logical volume - SAME
* logical volume size in kilobytes - SAME (but this is really sectors)
* current logical extents associated to logical volume - '2' (lvm1) '16' (lvm2)
* allocated logical extents of logical volume - '2' (lvm1) '-1' (lvm2)
* allocation policy of logical volume - SAME
* read ahead sectors of logical volume - 1024 (lvm1) '0' (lvm2)
* major device number of logical volume - 58 (lvm1) 253 (lvm2)
* minor device number of logical volume - OK
diff --ignore-all-space lvdisplay_c-lvm1.txt lvdisplay_c-lvm2.txt
The significant differences between lvdisplay (without the -c) on lvm1 vs lvm2
seem to be:
1) lvm2 has a couple extra fields - UUID and "Allocated LE"
2) lvm2 does not have "LV #"
diff --ignore-all-space lvdisplay-lvm1.txt lvdisplay-lvm2.txt
> LV UUID ZurW9y-XMS7-E1Vh-Y5gA-bg2j-pn61-agD06N
< LV # 1
< LV Size 64 MB
< Current LE 2
< Allocated LE 2
< Allocation next free
< Read ahead sectors 1024
< Block device 58:0
> LV Size 64.00 MB
> Current LE 16
> Segments 1
> Allocation inherit
> Read ahead sectors 0
> Block device 253:0