You know how "fdisk -l" lists drive partition tables and shows the partition id/types for each partition?

Is there a similar way to get the partition id for LVM logical volumes?

EDIT: I'm aware of "lvs", which is mostly what I'm looking for (it gives me the list of logical volumes, kind of like "fdisk -l"... except it would also be useful to know what the partition types of the logical volumes (which I like to think of as "virtual partitions") are. That info is what "fdisk -l" lists on the last two columns on the right. (Such as "8e" for a physical LVM partition, or "83" for Linux ext, etc.).

The tool I'm looking for may not be part of LVM; maybe just some other utility that can print partition ids/types given a partition?

Great Answer. It seems like no one else understood what the OP was asking for. I had to make one change to your script: I added the --dereference option to the file command. Each LV is linked to /dm-X by the device mapper.
–
codewaggleApr 24 '13 at 3:03

1

@codewaggle Thanks; option added. When I wrote the answer back in '09, the option was not needed, but times change.
–
TeddyApr 28 '13 at 18:52

1) A logical volume is NOT a (physical) disk partition. It is a virtual block device created inside Linux kernel with Device Mapper. It's a technology one can use to setup a single block device using two disk partitions as well as two block devices using a single disk partition, and much more.

So dm-0 and dm-1 are two LVs (lvroot and lvswap) created on my /dev/hdb2 partition of my first disk (with CentOS) while dm-2 and dm-3 are LVs created on my /dev/hda2 partition of my second disk (with Fedora).

Logical devices can have labels (UUIDs). You can check them with lvdisplay command, mentioned above. But they are just labels, which you can use (-u) instead of major, minor numbers (-j -m switches).

Partition type id is stored only in the partition table, not on the partition itself. On the other hand, LVM logical volumes are normally treated like individual partitions, not as disks, so there's no partition table and therefore no partition type id to look for.

Also note that the type id is only for informative purposes in Linux (this is not true for Windows, though). It has no bearing on the contents and the filesystem of that partition.

Logical volumes do not have a partition ID or type. They are composed of physical extents (PE) which may be spread over multiple physical volumes (PV), each of which could be a partition (e.g. /dev/sda2) or a complete disk (e.g. /dev/sdb).

Logical volumes don't have a concept of a "type", they're just block devices. If you want to examine the contents of a block device and determine what is in it, you might want to look at the blkid tool, which does exactly that.

LVM is an abstraction layer on top of the storage device to make it easier for you to manage it. I'm not sure what information beyond what fdisk provides you want, because the partition ID for LVM is displayed. However, for additional information about LVM logical volumes, you can use 'lvscan', 'lvs' and 'lvdisplay'.