Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-21-2006, 06:58 AM   #1
LQ Newbie
Registered: Feb 2006
Posts: 10

Rep: Reputation: 0
How to find Physical Volumes associated with a Logical Volume Group

Regards 's

I am trying to find out all the Physical Volumes a Logical Volume Group is associated with.

I am able to get all the active Logical Volume(LV) Groups on the system through ioctl(VG_STATUS_GET_NAMELIST) and the Logical Volumes in the group through ioctl(LV_STATUS_BYINDEX). But I am unable to find out an ioctl call to get the Physical Volume associated with the LV Group.

I tried out the call, ioctl(VG_STATUS) which returns struct *vg_t which incidentally contains an array of pv_t* structures. But these structures are not populated by this call. How can I do this?

Any help is appreciated...

Old 02-21-2006, 09:11 AM   #2
Senior Member
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Take a look at the code in lvdisplay's -m option. It performs mapping of logical to physical volumes:

# lvdisplay -m /dev/VolGroup00/LogVol00
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                KWqG5q-wFzR-2BJP-wxSF-sXTt-K7HF-r0R0pg
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                54.75 GB
  Current LE             1752
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:0

  --- Segments ---
  Logical extent 0 to 1751:
    Type                linear
    Physical volume     /dev/hda2
    Physical extents    0 to 1751
Old 02-21-2006, 10:19 AM   #3
Registered: Jan 2005
Location: Nice, France
Distribution: Ubuntu,RHES, Mandriva, RHAS, AIX 4.3.3, 5.2 & 5.3, Debian,Solaris8/10
Posts: 119

Rep: Reputation: 20
You can issue a <pvscan> too.

$ pvscan
pvscan -- reading all physical volumes (this may take a while...)
pvscan -- ACTIVE PV "/dev/sda2" of VG "root_vg" [14.64 GB / 7.17 GB free]
pvscan -- ACTIVE PV "/dev/sda4" of VG "omgr_vg" [15.26 GB / 0 free]
pvscan -- total: 2 [29.92 GB] / in use: 2 [29.92 GB] / in no VG: 0 [0]

Old 09-27-2013, 07:59 AM   #4
Registered: Jul 2005
Posts: 32

Rep: Reputation: 0
Hello macemoneta,

I needed this information only now and got this post. However, this does not work in my system.

#lvdisplay -m /dev/mapper/myvg-mylv
--- Logical volume ---
LV Name /dev/myvg/mylv
VG Name myvg
LV UUID <Removed from here>
LV Write Access read/write
LV Status available
# open 1
LV Size 26.00 GB
Current LE 6656
Mirrored volumes 2
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:27

--- Segments ---
Logical extent 0 to 6655:
Type mirror
Mirrors 2
Mirror size 6656
Mirror log volume mylv_mlog
Mirror region size 512.00 KB
Mirror original:
Logical volume mylv_mimage_0
Logical extents 0 to 6655
Mirror destinations:
Logical volume mylv_mimage_1
Logical extents 0 to 6655
There are no PV's by the name mimage_0 and mimage_1.

Another command also returns the same PV names, but these PV's do not exist!

# lvs --segments -o +pe_ranges
LV VG Attr #Str Type SSize PE Ranges
...Output truncated.....
mylv myvg mwi-ao 2 mirror 26.00G mylv_mimage_0:0-6655 mylv_mimage_1:0-6655
...Output truncated.....
pvscan returns 6 PV's in this VG. Out of this, atleast 2 PV's are of the same size. So it is tough to identify which PV my LV is on.

There is no issue with the LVM setup in this system.

So please comment on how to find out the PV's associated with this LV.

Thank you very much!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mounting Logical Volumes acidblue Fedora 6 01-28-2006 10:02 PM
I did not know about logical volumes gezi Linux - Newbie 5 04-27-2005 09:26 AM
FC3 slow boot: scans logical volumes..? tardigrade Fedora 1 04-03-2005 01:45 AM
LVM Problem - vgimport - wrong number of physical volumes to import volume group Anything1 Linux - Software 0 09-06-2003 07:18 PM
how to read the output of df -k and about logical volumes commands jdara1 Linux - Software 3 05-23-2003 12:22 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:02 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration