3

Why can't we directly create a volume group over a disk without creating a physical volume from it?

What is a physical extent? Do we even have physical extents in a partition?

  • How would the Volume Group know the geometry of the disk? How could it play nice with non-LVM partitions on the same disk? – SF. Jun 26 '15 at 13:27

2 Answers2

8

The physical volume (PV) is simply the partition with LVM metadata added. You can't create the volume group (VG) without referring to the metadata, thus you have to first create the PV(s) that will be members of the VG. A physical extent (PE) is just that - the actual section of the disk that you're writing to, very similar to an old-style disk CHS (cylinder-head-sector) address. You will always have PEs in an LVM world.

John
  • 17,011
2

A “physical volume” is LVM terminology for the underlying storage on which it puts data. Some typical examples of physical volumes include

  • a whole disk
  • a disk partition
  • a RAID array
  • an encrypted volume

A volume group is an intermediate abstraction layer between physical volumes (corresponding to the underlying storage) and logical volumes (each containing a filesystem (usually)). To “create volume group over a disk”, you need, by definition, to declare the disk as a physical volume for use by LVM.

A “physical extent” is just a consecutive chunk of 4MB (by default) on an LVM physical volume. It's an LVM concept, not a disk concept.

You can make a disk an LVM physical volume, but it tends to facilitate maintenance to first create a partition (a single partition if you want to use the whole disk) and make that partition an LVM physical volume. See The merits of a partitionless filesystem

So to use LVM on a single disk, say /dev/sda:

  • Use fdisk (or gdisk, parted, etc.) to create a partition sda1.
  • Use pvcreate /dev/sda1 to make the partition a physical volume.
  • Run vgcreate mystorage /dev/sda1 to a volume group called mystorage using the partition as storage space.
  • Run lvcreate … mystorage for each of the logical volumes you want to create.