[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 1

lvm_createvg Subroutine

Purpose

Creates a new volume group and installs the first physical volume.

Library

Logical Volume Manager Library (liblvm.a)

Syntax

#include <lvm.h>
int lvm_createvg (CreateVG)
struct createvg *CreateVG;

Description

Note: You must have root user authority to use this subroutine.

The lvm_createvg subroutine creates a new volume group and installs its first physical volume. The physical volume must not exist in another volume group.

The createvg structure pointed to by the CreateVG parameter is found in the lvm.h file and defined as follows:

struct createvg
        {
        mid_t kmid;
        char *vgname;
        long vg_major;
        char *pvname;
        long maxlvs;
        long ppsize;
        long vgda_size;
        short int override;
        struct unique_id vg_id;
        };
Field Definition
kmid Specifies the module ID that identifies the entry point of the logical volume device driver module. The module ID is returned when the logical volume device driver is loaded into the kernel.
vgname Specifies the character special file name that is either the full path name or a file name that resides in the /dev directory (for example, rvg13) of the volume group device. This device is actually a logical volume with the minor number 0, which is reserved for use by the Logical Volume Manager (LVM).
vg_major Specifies the major number for the volume group that is to be created.
pvname Specifies the character special file name, which is either the full path name or a single file name that resides in the /dev directory (for example, rhdisk0) of the physical volume being installed in the new volume group.
maxlvs Specifies the maximum number of logical volumes allowed in the volume group. Minor number 0 is reserved for the LVM. User logical volumes can range from minor number 1 through LVM_MAXLVS - 1.
ppsize Specifies the size of the physical partitions in the volume group. The range is LVM_MINPPSIZ to LVM_MAXPPSIZ. The size in bytes of every physical partition in the volume group is 2 to the power of the ppsize field.
vgda_size Indicates the number of 512-byte blocks which are to be reserved for one copy of the volume group descriptor area. The range is from LVM_MINVGDASIZ to LVM_MAXVGDASIZ. Twice this amount of space is reserved on each physical volume in the volume group so that two copies of the volume group descriptor area can be saved when needed.
override Specifies whether or not the LVM_VGMEMBER error code should be ignored. If the override field is TRUE, the LVM creates the volume group with the specified physical volume even if it appears to belong to another volume group, as long as that volume group is not varied on. If the volume group is varied on, the LVM_MEMACTVVG error code is returned. If the override field is FALSE, the LVM returns the LVM_VGMEMBER error code, if the specified physical volume is a member of another volume group whether that volume group is varied on or off. If the LVM_MEMACTVVG or LVM_VGMEMBER error code is returned, the vg_id field contains the ID of the volume group of which the specified physical volume is a member.

The vg_id field is an output field in which the ID of the newly created volume group will be returned upon successful completion.

The physical volume installed into the new volume group contains two copies of the volume group descriptor area in the reserved area at the beginning of the physical volume, since this is the first physical volume installed. The volume group descriptor area contains information about the physical and logical volumes in the volume group. This descriptor area is used by the LVM to manage the logical volumes and physical volumes in the volume group.

Parameters

CreateVG Points to the createvg structure.

Return Values

The lvm_createvg subroutine returns a value of 0 upon successful completion.

Error Codes

If the lvm_createvg subroutine fails, it returns one of the following values:

LVM_ALLOCERR A memory allocation error occurred.
LVM_BADBBDIR The physical volume could not be installed into the volume group because the bad-block directory could not be read from and or written to.
LVM_DALVOPN The logical volume reserved by the volume group could not be opened.
LVM_INVALID_PARAM A field in the createvg structure is not valid.
LVM_INV_DEVENT A device entry is invalid and cannot be checked to determine if it is raw.
LVM_LVMRECERR The LVM record, which contains information about the volume group descriptor area, could not be read or written.
LVM_MAJINUSE The specified major number is already being used by another device.
LVM_MEMACTVVG The physical volume specified is a member of another volume group that is varied on. This value is returned only when the override field is set to TRUE.
LVM_NOTCHARDEV The device specified is not a raw or character device.
LVM_PVOPNERR The physical volume device could not be opened.
LVM_RDPVID The record that contains the physical volume ID could not be read.
LVM_VGDASPACE The physical volume cannot be installed into the specified volume group because there is not enough space in the volume group descriptor area to add a description of the physical volume and its partitions.
LVM_VGMEMBER The physical volume cannot be installed into the specified volume group because its LVM record indicates it is already a member of another volume group. If the caller feels that the information in the LVM record is incorrect, the override field can be set to TRUE in order to override this error. This error is only returned when the override field is set to FALSE.
LVM_WRTDAERR An error occurred while trying to initialize either the volume group descriptor area, the volume group status area, or the mirror write consistency cache area on the physical volume.

Implementation Specifics

This subroutine is part of Base Operating System (BOS) Runtime.

Related Information

The lvm_varyonvg subroutine.

List of Logical Volume Subroutines and Logical Volume Programming Overview in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.


[ Previous | Next | Contents | Glossary | Home | Search ]