AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
#Power
 View Only
  • 1.  Getting volume group from filesystem

    Posted Thu May 05, 2011 07:23 AM

    Originally posted by: _Joseph_


    Is there a "single" command to get the volume group that a filesystem lives on? I know I can use lsvg -l <vgname> to get the filesystems based on the volume group name. But I would like to get the volume group based on the filesystem name. Is there any command/parameter for this?

    Thanks!
    #AIX-Forum


  • 2.  Re: Getting volume group from filesystem

    Posted Thu May 05, 2011 08:58 AM

    Originally posted by: styerd


    Perhaps not what you had in mind ...
    odmget -qname=$(odmget -qvalue=<fs> CuAt | grep name | cut -d\" -f2) CuDv | grep parent | cut -d\" -f2
    #AIX-Forum


  • 3.  Re: Getting volume group from filesystem

    Posted Thu May 05, 2011 09:12 AM

    Originally posted by: tony.evans


    That command probably works (not tested) and it certainly fits with the UNIX philosophy (provide commands which do one thing very well and quietly, and build complex commands by tying them together), but I would generally avoid using the ODM to get the data.

    lsfs lists information about filesystems and their relationship to logical volumes.
    lslv lists information about logical volumes and their relationship to volume groups.

    I would go with,

    
    lslv $(lsfs -c /filesystem/mount | tail -1 | awk -F
    ":" 
    '{print $2}' | awk -F
    "/" 
    '{print $NF}') | awk 
    '/VOLUME GROUP/ {print $NF}'
    


    Again, not a single command, but certainly the 'UNIX way'. We've both also demonstrated another UNIX truism, there's always more than one way.

    (I expect the forum will now mangle my code and I'll be back to try posting it again in a second)
    #AIX-Forum


  • 4.  Re: Getting volume group from filesystem

    Posted Thu May 05, 2011 09:18 AM

    Originally posted by: tony.evans


    Cool, the forum didn't mangle it.

    Also, the trick is once you know how to get the data, you create a small script and just put it into your path - that's how most UNIX commands start out anyway.
    #AIX-Forum


  • 5.  Re: Getting volume group from filesystem

    Posted Thu May 05, 2011 12:41 PM

    Originally posted by: _Joseph_


    Many thanks! I too like to steer away from the odm as much as possible. Thanks to all for the input. The command worked great!
    #AIX-Forum