LVM: Two or more volume groups (VGs) on one physical volume (PV)
I have just a short question about LVM.
A physical volume is a Partition or a whole Disk. A volume group is a container for a least one physical volume.
So I know that a volume group can have more than one physical volume for example 3 partitions on two disks in one volume group.
But "for a least one physical" means that you can't create two or more volume groups on the same physical volume? So a volume group always uses the whole physical volume, is this correct?
So if I like to have more volume groups on a disk I need to create more partitions on the disk (physical volume) first?
Thanks
Solution 1:
Yes, your understanding is correct.
A Volume Group (VG) comprises Physical Volumes (PV). If the PVs are in one VG, they can't then be placed in another Volume Group.
So if you want to create multiple volume groups, you need separate PVs for them. As you have noted, you can share a physical disk among VGs, but it would need to be partitioned, and PVs created from the partitions, and put into separate volume groups.
Solution 2:
Two or more VGs can be created on a single drive, provided you partition it. However, you cannot create two VGs on the same disk partition or on a whole disk, as you noted.
Increasing number of PVs in a VG is usually done either by:
- adding physical disk (it might require halting the OS).
- creating LUN on a SAN. LUN stands for Logical Unit Number, and are reserved space on SAN seen as disk by the OS.
Unused partitions of a disk can be used to add more PVs; this can happen of you have not allocated all space to VG/PV, or in case of a LUN if you grow it. Note that, for Red Hat at least, if PV is a whole disk, the pvresize
command can be used to change size of PV.