When creating a Version 1.0 volume group, the vgcreate command may fail and display a message that the
extent size is too small or that the VGRA is too big. In this situation,
you must choose a larger extent size and run vgcreate again.
Increasing the extent size increases the data
area marked stale when a write to a mirrored logical volume fails.
That can increase the time required to resynchronize stale data. Also,
more space may be allocated to each logical volume because the space
is allocated in units of extent size. Therefore, the optimal extent
size is the smallest value that can be used to successfully create
the volume group with the desired configuration parameters.
The minimum extent size for a volume group is
calculated using the maximum number of logical volumes (MAXLVs) and
physical volumes (MAXPVs) in the volume group and the maximum number
of physical extents (MAXPXs) per each physical volume.
For a volume group with bootable physical volumes,
the metadata must fit within 768 KB. Therefore, running vgcreate with a set of values for MAXLVs, MAXPVs and MAXPXs that succeed
on a volume group without bootable physical volumes may fail on a
volume group with bootable physical volumes. In this situation, if
you must add a bootable physical volume to a volume group, recreate
the volume group by giving lesser values for these arguments. By far
the biggest factor in the size of the metadata is the values for MAXPVs
and MAXPXs. Alternatively, convert the bootable physical volume to
a normal physical volume by running pvcreate on
that physical volume without the –B option
and then adding it to the volume group. For a physical volume that
is already part of a volume group, you can use vgmodify to change a physical volume from a bootable to a normal physical
volume.
Sample Shell Script
The following shell script creates and compiles
a small program that displays the minimum extent size for a given
volume group:
#!/usr/bin/sh
cat << EOF > vgrasize.c
#include <stdio.h>
#define BS 1024 /* Device block Size */
#define roundup(val, rnd) (((val + rnd - 1) / rnd) * rnd)
main(int argc, char *argv[])
{
int i, length, lvs, pvs, pxs;
if (argc != 4) {
/* Usage example:
* Maximum LVs in the VG = 255
* Maximum PVs in the VG = 16
* Maximum extents per PV = 2500
*
* $ vgrasize 255 16 2500
*/
printf("USAGE: %s MAXLVs MAXPVs MAXPXs\n", argv[0]);
exit(1);
}
lvs = atoi(argv[1]);
pvs = atoi(argv[2]);
pxs = atoi(argv[3]);
length = 16 + 2 * roundup(2 +
(roundup(36 + ((3 * roundup(pvs, 32)) / 8) +
(roundup(pxs, 8) / 8) * pvs, BS) +
roundup(16 * lvs, BS) +
roundup(16 + 4 * pxs, BS) * pvs) / BS, 8);
if (length > 768) {
printf("Warning: A bootable PV cannot be added to a VG \n"
"created with the specified argument values. \n"
"The metadata size %d Kbytes, must be less \n"
"than 768 Kbytes.\n"
"If the intention is not to have a boot disk in this \n"
"VG then do not use '-B' option during pvcreate(1M) \n"
"for the PVs to be part of this VG. \n", length);
}
length = roundup(length, 1024) / 1024;
if (length > 256 ) {
printf("Cannot configure a VG with the maximum values"
" for LVs, PVs and PXs\n");
exit(1);
}
for (i = 1; i < length ; i = i << 1) { }
printf("\nMinimum extent size for this configuration = %d MB\n", i);
exit(0);
}
EOF
make vgrasize