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

2022-01-02 Thread Roland

hello,

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 ?

regards
roland

ps:
i wonder if there is bad block relocation possible with lvm, and i'm
trying to build some script. as far as i can see lvm has everything
needed for that to shuffle extents from one position on disk to another...


___
linux-lvm mailing list
linux-lvm@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/

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

2022-01-03 Thread Andy Smith
Hi Roland,

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 ?

lvdisplay --maps /path/to/lv

tells you all the mappings of logical extents within the LV to
physical extents within the PV.

pvdisplay --units s /dev/yourpv | grep 'PE Size'

tells you the size of a physical extent in sectors.

Between those you can work out the sector number on the physical
device for a sector number on a logical volume.

Cheers,
Andy

___
linux-lvm mailing list
linux-lvm@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/



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

2022-01-03 Thread Roland

thanks!

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

roland


Am 03.01.22 um 00:12 schrieb Andy Smith:

Hi Roland,

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 ?

lvdisplay --maps /path/to/lv

tells you all the mappings of logical extents within the LV to
physical extents within the PV.

pvdisplay --units s /dev/yourpv | grep 'PE Size'

tells you the size of a physical extent in sectors.

Between those you can work out the sector number on the physical
device for a sector number on a logical volume.

Cheers,
Andy

___
linux-lvm mailing list
linux-lvm@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/




___
linux-lvm mailing list
linux-lvm@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/

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

2022-01-03 Thread Roland

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

after long trial and error and reading manpages, i got it (see below):

what i'm yet missing is how "translation" of the headings/fields in
normal output can be avoided , i.e print the technical/internal field
name instead of a "human readable" or "translated" one.

'seg_start_pe' and 'pvseg_start' for example both translate to "Start",
and that does not only make it hard to read (and makes no real sense to
have duplicate field names) ,  but it's also difficult to build an
appropriate output field command option from the default output.  i
remember i had such issue with other tools...

think this is a missing feature ?

roland


# pvs --segments -olv_name,seg_start_pe,seg_size_pe,pvseg_start -S
lv_name=usedblocks -O seg_start
   LV Start SSize Start
   usedblocks 0 1   512
   usedblocks 1   233 1
   usedblocks   234 1   513
   usedblocks   235   277   235

# pvs --segments -olv_name,seg_start_pe,seg_size_pe,pvseg_start -S
lv_name=markedbad -O seg_start
   LV    Start SSize Start
   markedbad 0 1  1022
   markedbad 1 1 0
   markedbad 2 1   234

# pvs --segments -olv_name,seg_start_pe,seg_size_pe,pvseg_start -S
lv_name=markedbad -O seg_start --nameprefixes --noheadings
   LVM2_LV_NAME='markedbad' LVM2_SEG_START_PE='0' LVM2_SEG_SIZE_PE='1'
LVM2_PVSEG_START='1022'
   LVM2_LV_NAME='markedbad' LVM2_SEG_START_PE='1' LVM2_SEG_SIZE_PE='1'
LVM2_PVSEG_START='0'
   LVM2_LV_NAME='markedbad' LVM2_SEG_START_PE='2' LVM2_SEG_SIZE_PE='1'
LVM2_PVSEG_START='234'

# pvs --segments -olv_name,seg_start_pe,seg_size_pe,pvseg_start -S
lv_name=usedblocks -O seg_start --nameprefixes --noheadings
   LVM2_LV_NAME='usedblocks' LVM2_SEG_START_PE='0' LVM2_SEG_SIZE_PE='1'
LVM2_PVSEG_START='512'
   LVM2_LV_NAME='usedblocks' LVM2_SEG_START_PE='1'
LVM2_SEG_SIZE_PE='233' LVM2_PVSEG_START='1'
   LVM2_LV_NAME='usedblocks' LVM2_SEG_START_PE='234'
LVM2_SEG_SIZE_PE='1' LVM2_PVSEG_START='513'
   LVM2_LV_NAME='usedblocks' LVM2_SEG_START_PE='235'
LVM2_SEG_SIZE_PE='277' LVM2_PVSEG_START='235'

Am 03.01.22 um 12:13 schrieb Roland:

thanks!

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

roland


Am 03.01.22 um 00:12 schrieb Andy Smith:

Hi Roland,

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 ?

lvdisplay --maps /path/to/lv

tells you all the mappings of logical extents within the LV to
physical extents within the PV.

pvdisplay --units s /dev/yourpv | grep 'PE Size'

tells you the size of a physical extent in sectors.

Between those you can work out the sector number on the physical
device for a sector number on a logical volume.

Cheers,
Andy

___
linux-lvm mailing list
linux-lvm@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/




___
linux-lvm mailing list
linux-lvm@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/

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

2022-01-06 Thread Stuart D Gathman

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 ?___
linux-lvm mailing list
linux-lvm@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/