[Gllug] Mapping from disk block to LVM partitions

Rich Walker rw at shadow.org.uk
Sun Dec 6 16:32:48 UTC 2009




Richard Jones <rich at annexia.org> wrote:
> 
> On Sun, Dec 06, 2009 at 12:22:17PM +0000, Rich Walker wrote:
> > Smartd finding disk errors on raid array recheck. Raid array is used for
> > LVM. What's the fastest/easiest way to get from disk block number to LVM
> > partition?
> 
> Not sure about "fastest" but I have spent quite a long time decoding
> LVM disk information a while back.
> 
> The information is stored in plain text in the first few megabytes of
> the PV.  Actually there are likely to be several copies, because the
> metadata is stored in a circular buffer, where new metadata is written
> after, not on top of, old metadata (so that there is some possibility
> of rolling back to earlier versions).
> 
> The metadata itself is in plain text as I said, in a simple C-like
> recursive format.
> 
> # pvs
>   PV         VG       Fmt  Attr PSize   PFree  
>   /dev/dm-0  vg_trick lvm2 a-   931.31G 575.38G
> 
> # strings /dev/dm-0
> LABELONE
> LVM2 0013l0DTj3QUp1TfM5jzMbfX1PTt0cP8C9a
>  LVM2 x[5A%r0N*>
> [...]
> # Generated by LVM2 version 2.02.45 (2009-03-03): Thu May 14 11:50:40 2009
> contents = "Text Format Volume Group"
> version = 1
> description = ""
> creation_host = "user-desktop.home.annexia.org" # Linux user-desktop.home.annexi
> a.org 2.6.29.1-102.fc11.x86_64 #1 SMP Mon Apr 20 15:33:38 EDT 2009 x86_64
> creation_time = 1242298240      # Thu May 14 11:50:40 2009
> vg_trick {
> id = "FPsBXd-JynR-HvhD-0FRI-Z8qe-5HrU-brjJYQ"
> seqno = 2
> status = ["RESIZEABLE", "READ", "WRITE"]
> flags = []
> extent_size = 8192
> max_lv = 0
> max_pv = 0
> physical_volumes {
> pv0 {
> id = "3l0DTj-3QUp-1TfM-5jzM-bfX1-PTt0-cP8C9a"
> device = "/dev/dm-0"
> status = ["ALLOCATABLE"]
> flags = []
> dev_size = 1953106424
> pe_start = 384
> pe_count = 238416
> logical_volumes {
> lv_root {
> id = "bQDbMV-eEdv-JuE3-UxYw-GJPw-PlSb-UnaH7N"
> status = ["READ", "WRITE", "VISIBLE"]
> flags = []
> segment_count = 1
> segment1 {
> start_extent = 0
> extent_count = 62500
> type = "striped"
> stripe_count = 1        # linear
> stripes = [
> "pv0", 0
>  ....
> 
> It's possible with a bit of effort to go from this to the actual
> mapping of LVs to blocks on the disk, or vice versa.
> 
> No idea if there is an easier way.  It's the sort of thing that
> libguestfs could probably be extended to do ...
> 


I was thinking "fastest" in the sense "most convenient over slow SSH
connection". One of the outputs of lvs:

# lvs -a --segments --verbose --units s
    Finding all logical volumes
  LV              VG   Attr   Start      SSize      #Str Type   Stripe Chunk
  BackupFromThoth V01  -wi-ao         0S  31457280S    1 linear     0S    0S
  GatewayMirror   V01  -wi-ao         0S  62914560S    1 linear     0S    0S
  PlatoMirror     V01  -wi-a-         0S 117440512S    1 linear     0S    0S
  HomeMirror      V02  -wi-ao         0S 251658240S    1 linear     0S    0S
  HomeMirror      V02  -wi-ao 251658240S 104857600S    1 linear     0S    0S
  Music           V02  -wi-ao         0S 125829120S    1 linear     0S    0S
  Music           V02  -wi-ao 125829120S   6324224S    1 linear     0S    0S
  Root            V02  -wi-a-         0S   6291456S    1 linear     0S    0S
  Usr             V02  -wi-a-         0S  10485760S    1 linear     0S    0S
  Var             V02  -wi-a-         0S  10485760S    1 linear     0S    0S
  Video           V02  -wi-ao         0S  77594624S    1 linear     0S    0S
  Video           V02  -wi-ao  77594624S  20971520S    1 linear     0S    0S
  ocfs_test       V02  -wi-a-         0S 104857600S    1 linear     0S    0S

looks promising, but getting those Start numbers offset from the PV
base?

cheers, Rich.


-- 
rich walker         |  Shadow Robot Company | rw at shadow.org.uk
technical director     251 Liverpool Road   | skype: rich_at_shadow
need a Hand?           London  N1 1LX       | +44 20 7700 2487
http://www.shadowrobot.com/hand/
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list