[linux-lvm] convert logical sector -> physical sector + pv/vg extent number

Stuart D Gathman stuart at gathman.org
Thu Jan 6 13:47:09 UTC 2022


On Mon, 3 Jan 2022, Roland wrote:

> any chance to get retrieve this information for automated/script based
> processing ?

You might find this script enlightening:

https://github.com/sdgathman/lbatofile

It maps bad sectors to partition,LV,file,etc

The relevant function for your question is findlv()
Some of the commands run are:

pvdisplay --units k -m '/dev/lvm_pv'
pvs --units k -o+pe_start '/dev/lvm_pv'

> Am 03.01.22 um 00:12 schrieb Andy Smith:
>>  On Sun, Jan 02, 2022 at 08:00:30PM +0100, Roland wrote:
>>>  if i have a logical sector/block "x" on a lvm logical volume ,  is there
>>>  a way to easily calculate/determine (optimally by script/cli) the
>>>  corresponding physical sector of the physical device it belongs to and
>>>  the extent number of the appropiate pv/vg where it resides ?


More information about the linux-lvm mailing list