Get LVM LV / VG / PV name from UUID

lvm

The output of {lv,vg,pv}display gives:

  • Name
  • UUID

How do I find an LVM name given a UUID?

Best Answer

You can filter LVM commands’ output directly using the -S option:

# pvs --noheadings -o name -S uuid=MtLb3p-MUle-8fyk-fy6m-z99n-V9mi-xxxxxx
  /dev/sdb3

This also works with vgs and lvs to find VGs and LVs.

To avoid having to deal with the spaces at the start of the output, add --config 'log{prefix=""}':

# pvs --noheadings -o name -S uuid=MtLb3p-MUle-8fyk-fy6m-z99n-V9mi-xxxxxx --config 'log{prefix=""}'
/dev/sdb3
Related Question