You are on page 1of 10

lvcreate(1M)

lvcreate(1M)

NAME
lvcreate - create a new logical volume or snapshot volume in LVM volume group
SYNOPSIS
Creating a Logical Volume
/usr/sbin/lvcreate [-A autobackup ] [-c mirror_consistency] [-C contiguous ] [-d schedule ]
[-D distributed ] [-i stripes [-I stripe_size ]] [-l le_number -L lv_size ] [-m mirror_copies]
[-M mirror_write_cache] [-n lv_name ] [-p permission ] [-r relocate ] [-s strict ] vg_name
Creating a Snapshot Volume on Volume Group Version 2.2 or Higher
/usr/sbin/lvcreate -S snap_type [-A autobackup ] [-c mirror_consistency] [-C contiguous ]
[-D distributed ] [-e auto_prealloc_enabled] [-l prealloc_le_number | -L prealloc_le_size] [-m
mirror_copies ]
[-M
mirror_write_cache]
[-n
snap_lv_name ]
[-p
permission ]
[-P
threshold_value] [-s strict ] [-t timestamp ]
original_lv
Remarks
Mirrored disk operations require the installation of the optional HP MirrorDisk/UX software, which is not
included in the standard HP-UX operating system.
DESCRIPTION
The lvcreate command can be used in two ways. The rst form creates a new logical volume within
the volume group specied by vg_name . The second form, used with the -S option, creates a snapshot
volume off an existing logical volume; see Creating Snapshot Volumes below.
The total number of logical volumes that can be created depends on the version of the volume group. Use
the lvmadm command to nd the maximum number of logical volumes for each volume group version.
See lvm(7) for more information.
If you specify the -n lv_name option, a new logical volume is created with that given name. Otherwise, a
system-generated name of the form lvolN is created. For a logical volume created within a volume
group version 1.0, N is the decimal equivalent of the two least signicant bytes of the minor number of
the new logical volume and the range for N is 1 to 255. For a logical volume created within a volume
group version 2.0, N is the decimal equivalent of the least signicant 12 bits of the logical volumes minor
number, and the range for N is 1 to 511. For a logical volume created within a volume group version 2.1
and 2.2, N is the decimal equivalent of the least signicant 12 bits of the logical volumes minor number,
and the range for N is 1 to 2047 (see lvm(7)).
Two device les are created in vg_name : a block device le named lv_name or lvolN, and a character
(raw) device le named rlv_name or rlvolN.
If you omit the -l and -L options, the logical volume is created with zero length. This permits you to
choose its physical volume location when you allocate logical extents with the lvextend command (see
lvextend (1M)). If you specify -l or -L, the location is determined automatically.
The default settings provide the most commonly used characteristics. Use the options to tailor the logical
volume to the requirements of the system. Once a logical volume is created, some of its characteristics
can be changed with the lvchange, lvextend, and lvreduce commands (see lvchange (1M),
lvextend (1M), and lvreduce (1M)).
Creating Snapshot Volumes
The second form of lvcreate uses the -S option to create a snapshot volume of an existing logical
volume within a volume group. Snapshots can be of two types: fully-allocated and space-efcient. See
lvm(7) for more information about snapshots.
The snapshot volume is created as just another logical volume in the volume group. The following conditions apply to the creation of snapshot volumes:

It is necessary to provide an original logical volume.

The allocation policies of the snapshot are inherited from the original logical volume unless specied
explicitly, with the exception that contiguous allocation policy is not supported for space-efcient
snapshots. The allocation policy of a space-efcient snapshot is set to default allocation when the original logical volume is congured for contiguous allocation.

The snapshot is striped only if the original logical volume is striped. Specifying the stripe size or
stripe width for snapshots is not supported.

HP-UX 11i Version 3: September 2010

Hewlett-Packard Company

lvcreate(1M)

lvcreate(1M)

A snapshot defaults to non-mirrored even if the original logical volume is mirrored, unless mirroring
is explicitly congured during the snapshot creation.

When mirrored, a snapshot defaults to inherit the original logical volumes MCR/MWC conguration,
unless MCR/MWC is explicately congured during snapshot conguration.

Once created, the conguration of a snapshot cannot be changed except for the access permission,
volume availability, volume IO timeout, and MCR/MWC attributes.

If you omit the -l and -L options, then the snapshot created will be a fully-allocated snapshot, which
will have just as many allocated logical extents as the original logical volume. The -l or -L options can
be used to create a space-efcient snapshot by specifying the pre-allocated logical extents that will be
presented to the snapshot. The pre-allocated size of a space-efcient snapshot can vary between 1 and
the size of the original logical volume. The pre-allocated size of a space-efcient snapshot can be
increased but can not be decreased. See lvextend (1M) for details.
The -n option can be used to specify the name of the snapshot. If this option is not used, then the name
of the snapshot will default to the string comprising of the original logical volume name, the tag S, and
the snapshot volume minor number N, where N is the decimal equivalent of the least signicant 12 bits of
the snapshot volumes minor number. The range for N is 1 to 2047 (see lvm(7)).
The -t option can be used to append the timestamp to the snapshot volume name. The timestamp is of
the form: YYYYMMDD_HH.MM.SS. The default is to not append a timestamp to the name of the
snapshot.
Since the HP-UX system operates in Coordiated Universal Time (UTC), the timestamp value used in the
snapshot volume name and the timestamp eld of lvdisplay (see lvdisplay (1M)) is based on your TZ
environment variable (see environ (5) and tztab (4)).
Note the following for timestamp value:

If the timestamp is requested to be appended to the name of the snapshot volume, then the time used
for timestamp will be according to the TZ environment variable when the snapshot logical volume was
created. The snapshot volume name will never get changed, even if the TZ is changed after the
snapshot has been created.

The value of timestamp eld in the lvdisplay output for the snapshot will be according to the TZ
environment variable when lvdisplay is issued.

time(), gmtime(), and ctime() are used for generating the time for the timestamp value.
strptime() and strftime() are used for formatting the time. See time (2), gmtime (3C),
ctime (3C), strptime (3C), and strftime (3C).

Note the following for space efcient snapshots:

For a space efcient snapshots, when the number of extents in the pre-allocated extent pool falls below
a certain threshold, a message is logged in the systems syslog, and an event is published to the
listening subsystems. If the automatic increase of pre-allocated extents is enabled, then number of
pre-allocated extents gets automatically incremented by the threshold value. Note that lvmpud daemon must be running for this to succeed.

If the automatic increase of pre-allocated extents is not enabled but the threshold value is set and
when the number of extents in the pre-allocated extent pool falls below the threshold value which is
set, a message is logged in the systems syslog, and an event is published to the listening subsystems.

If neither -e or -P options are specied, then by default, automatic increase of pre-allocated extents
is enabled, and the threshold value is set to the default value. Please refer to lvm(7) for more details.

Options and Arguments


The -c, -d, -m, -M, and -s options are only meaningful if the optional HP MirrorDisk/UX software has
been installed on the system.

lvcreate recognizes the following options and arguments:


vg_name
original_lv

The path name of a volume group, used to create a logical volume in the
specied volume group.
The path name of the logical volume whose snapshot is to be created.
Only applicable with the -S option to create snapshop logical volumes.

Hewlett-Packard Company

HP-UX 11i Version 3: September 2010

lvcreate(1M)

-S snap_type

lvcreate(1M)

Create a point-in-time image of data. Current valid snap_type is:

Indicates the creation of a snapshot volume. See lvm(7) for more


information on snapshot volume.

If the -S option is not used, lvcreate creates a new logical volume


instead of a snapshot off an existing logical volume.

-A autobackup

Set automatic backup for this invocation of this command. autobackup


can have one of the following values:

Automatically back up conguration changes made to the logical


volume. This is the default.
After this command executes, the vgcfgbackup command (see
vgcfgbackup (1M)) is executed for the volume group to which the
logical volume belongs.

n
-c mirror_consistency

Do not back up conguration changes this time.

Set mirror consistency recovery. This option is effective only when -M n


is specied. It is ignored for -M y. mirror_consistency can have one of
the following values:

Set mirror consistency recovery on. This is the default.


LVM achieves mirror consistency during volume group activation
by going through all logical extents and copying data from a nonstale copy to the other mirror copies.

-C contiguous

Set mirror consistency recovery off. LVM does not perform mirror
consistency recovery on this logical volume when the volume group
is activated following a system crash. This setting should only be
used on logical volumes that do not require mirror consistency
recovery or where mirror consistency recovery is performed by
another subsystem; for example swap. See the WARNINGS section
for more details.

Set the contiguous allocation policy. A contiguous logical volume has


three characteristics:
Physical extents are allocated in ascending order,
No gap is allowed between physical extents within a mirror copy,
Physical extents of any mirror copy all reside on a single physical
volume.
Use the strict (-s) and contiguous (-C) options together to form various
combined allocation policies on a logical volume. For example, -s y -C
y denes a logical volume such that each mirror copy is contiguous, yet
mirror copies of a logical extent cannot share the same physical volume.
contiguous can have one of the following values:

Set a contiguous allocation policy.

Do not set a contiguous allocation policy. This is the default.

The enforcement of a contiguous allocation policy via the -C y option is


not supported on a striped logical volume nor on space-efcient
snapshots.

-d schedule

Set the scheduling policy when a logical extent with more than one mirror is written. (The scheduling policy of a striped logical volume is
striped and cannot be changed.) schedule can have one of the following
values:

Establish a parallel scheduling policy. This is the default.

Establish a sequential scheduling policy. Use this value with care,


because it leads to performance loss in most cases.

The -d option is not applicable with the -S option for snapshot volumes.
HP-UX 11i Version 3: September 2010

Hewlett-Packard Company

lvcreate(1M)

-D distributed

lvcreate(1M)

Set the distributed allocation policy. distributed can have one of the following values:

Turn on distributed allocation.

Turn off distributed allocation. This is the default.

When the distributed allocation policy is turned on, only one free extent
is allocated from the rst available physical volume. The next free
extent is allocated from the next available physical volume. Allocation of
free extents proceeds in round-robin order on the list of available physical volumes.
When the distributed allocation policy is turned off, all available free
extents are allocated from each available physical volume before
proceeding to the next available physical volume. This is the default.
The distributed allocation policy REQUIRES the PVG-strict allocation
policy (-s g) to ensure that mirrors of distributed extents do not overlap
(for maximum availability).
lvcreate (1M) will obtain the list of available physical volumes from
/etc/lvmpvg. See vgextend (1M) for more information on physical
volume groups and /etc/lvmpvg.
When a logical volume with distributed extents is mirrored, the resulting
layout is commonly referred to as EXTENT-BASED MIRRORED
STRIPES.
Note that EXTENT-BASED MIRRORED STRIPES can be created
without the distributed allocation policy by adding one extent at a time to
the desired physical volumes through lvextend (1M).

The distributed allocation policy is incompatible with the striped


scheduling policy (-i stripes) and the contiguous allocation policy (-C
y).
The lvchange (1M) command can be used to assign the distributed allocation policy to an existing logical volume.
See lvdisplay (1M) for display values.
See EXAMPLES.

-e auto_prealloc_enabled
Enable/Disable the automatic increase of pre-allocated extents.
auto_prealloc_enabled can have one of the following values:

y
n
-i stripes

Enable the automatic increase of pre-allocated extents. Note that


this feature is enabled only when lvmpud is running.
Disable the automatic increase of pre-allocated extents.

Set the number of disks to stripe across, for the new logical volume.
stripes must be at least 2 and no greater than a volume group versiondependent maximum; use the lvmadm command to determine the maximum supported stripes for the volume group version.
If -i is provided and -I is not, the stripe size is set to 8 kilobytes.
The -i option is not applicable for snapshot volumes.

-I stripe_size

Set the size in kilobytes of the stripe. stripe_size should be a power of 2.


stripe_size must be at least 4 and no greater than a volume group
version-dependent maximum; use the lvmadm command to determine
the maximum supported stripe_size for the volume group version.
If -I is provided and -i is not, the command will fail and return an
error. Stripe size should be a value less than or equal to physical extent
size and must be specied with the -i option.
The -I option is not applicable for snapshot volumes.

Hewlett-Packard Company

HP-UX 11i Version 3: September 2010

lvcreate(1M)

-l

lvcreate(1M)

Allocate space, specied in logical extents, to the logical volume or


snapshot volume.

-l le_number
allocates space to the logical volume, specied in logical extents.
le_number must be at least 1 and no greater than a volume group
version-dependent maximum; use the lvmadm command to determine the maximum number of logical extents for the volume group
version.

-l prealloc_le_number
allocates space for a space-efcient snapshot volume.
prealloc_le_number can range from 1 to the number of extent occupied by the original logical volume.
The default, when the -l option is not used (for creating a logical volume
or snapshot volume), is described above in the DESCRIPTION section.
Either -l or -L can be specied, but not both.

-L

Allocate space, in megabytes, to the logical volume or snapshot volume.

-L lv_size
allocates space to the logical volume, specied in megabytes.
lv_size must be at least 1 and no greater than a volume group
version-dependent maximum; use the lvmadm command to determine the maximum size for the volume group version.
lv_size is rounded up to the nearest multiple of the logical extent
size, equivalent to the physical extent size dened for the volume
group by the vgcreate command (see vgcreate (1M)).

-L prealloc_le_size
allocates space for a space-efcient snapshot volume, specied in
megabytes.
prealloc_le_size can range from 1 to the size of the original logical
volume.
prealloc_le_size is rounded up to the nearest multiple of the logical
extent size, equivalent to the physical extent size dened for the
volume group by the vgcreate command.
The default, when the -L option is not used (for creating logical volume
or snapshot volume) is described above in the DESCRIPTION section.
Either the -l or the -L option can be specied, but not both.

-m mirror_copies

Set the number of mirror copies allocated for each logical extent. A mirror copy contains the same data as the original.
mirror_copies must be at least 1 and no greater than a volume group
version-dependent maximum; use the lvmadm command to determine
the maximum number of mirror copies for the volume group version.
The default value is 0 (no mirror copies).

-M mirror_write_cache

Set the Mirror Write Cache ag. mirror_write_cache can have one of the
following values:

Set Mirror Write Cache on. This is the default.


Every write to a mirror copy is recorded in the Mirror Write Cache.
The Mirror Consistency Record in the Volume Group Reserved Area
on the disk is updated whenever there is a write to a logical track
group that is not already recorded in the cache. This allows LVM to
determine whether all the mirror copies are identical, even across
system crashes. When the volume group is activated, the Mirror
Consistency Record is used to perform mirror consistency recovery.

HP-UX 11i Version 3: September 2010

Hewlett-Packard Company

lvcreate(1M)

lvcreate(1M)

n
-n

Set Mirror Write Cache to off. Mirror write does not incur an additional write to the Mirror Consistency Record.

Specify the name of the new logical volume or snapshot volume.

-n lv_name
sets the name of the new logical volume to lv_name , where lv_name
is a simple le name, not a path name.

-n snap_lv_name
sets the name of the new snapshot volume to snap_lv_name .
The default, when the -n option is not used (for logical volume or
snapshot volume) is described above in the DESCRIPTION section.

-p permission

Set the access permission. permission can have one of the following
values:

w
r
-P threshold_value

Set the access permission to read-write. This is the default for the
logical volume.
Set the access permission to read-only. This is the default for the
snapshot volume.

Set the percentage threshold value at which increment messages will be


logged in the systems syslog, and/or the automatic increase of preallocated extents will be triggered.
The value ranges between 1 to 100. If the auto_prealloc_enabled
ag is set (see the -e option), then at the threshold value, the automatic
increase of pre-allocated extents will be triggered. Note that the number
of pre-allocated extents will be incremented by the threshold value. If
the auto_prealloc_enabled ag is not set, then at the threshold
value, the increment messages will be logged in the systems syslog for
the user to take action.

l
-r relocate

This parameter is valid for creating a logical volume within volume


groups version 1.0 only. For volume groups versions 2.0 or higher, it is
ignored and relocation is not supported.
Set the logical volume bad block relocation policy. This is an obsolete
ag available only to provide compatibility with prior HP-UX releases.
The relocate ag can have one of the following values:

y|n|N
This release does not provide the LVM bad block relocation feature;
but for compatibility reasons, the value is maintained as a logical
volume attribute. Displaying the logical volume attributes will
show the value of the ag selected. However, regardless of the
selection, no new relocations will be done.
If the volume group is activated on a different HP-UX release that
provides the bad block relocation feature, bad blocks may be relocated depending upon the value of this ag. Although no new relocations will be done, any bad block relocations present on a logical
volume (activated on HP-UX releases that provided this feature)
will be honored when the volume group is activated on this HP-UX
release.

y is the default value of this ag.


-s strict

Set the strict allocation policy. Mirror copies of a logical extent can be
allocated to share or not share the same physical volume or physical
volume group. strict can have one of the following values:

y
g

Hewlett-Packard Company

Set a strict allocation policy. Mirrors of a logical extent cannot


share the same physical volume. This is the default.
Set a PVG-strict allocation policy. Mirrors of a logical extent cannot share the same physical volume group. A PVG-strict allocation
policy cannot be set on a logical volume in a volume group that does
6

HP-UX 11i Version 3: September 2010

lvcreate(1M)

lvcreate(1M)

not have a physical volume group dened.

n
-t timestamp

Do not set a strict or PVG-strict allocation policy. Mirrors of a logical extent can share the same physical volume.

Append a timestamp to the snapshot volume name, in the form:


YYYYMMDD_HH.MM.SS.
timestamp can be one of the following:

Append the timestamp to the snapshot volume name.

Do not append the timestamp to the snapshot volume name. This is


the default.

This option is only applicable for the snapshot volume.


Striped Logical Volume Considerations
Striped and mirrored logical volumes are supported. A logical volume striped across stripes physical
volumes is allocated in sets of stripes logical extents. A set corresponds to stripes physical extents if the
volume is not mirrored or to stripes * (mirror_copies + 1) physical extents if the volume is mirrored.
stripes is the number of physical volumes the logical volume is striped across. It is set with the option -i
stripes . mirror_copies is the number of mirror copies allocated for each logical extent. It is set with the
-m option. The user data is striped across stripes physical extents of the set, and each of these extents is
mirrored on mirror_copies other physical extents of the same set. Striped logical volumes are only allocated using the strict or PVG-strict allocation policies. Each physical extent of a given set is allocated on
a different physical volume in the volume group.
The total number of physical extents of a striped logical volume is always a multiple of stripes (or stripes
* (mirror_copies + 1) if the volume is mirrored).
A minimum of stripes (or stripes * (mirror_copies + 1) if the volume is mirrored) physical volumes with
adequate free space and meeting the allocation policy is needed to allocate a striped logical volume.
Shared Volume Group Considerations
For volume group version 1.0 and 2.0, lvcreate cannot be used if the volume group is activated in
shared mode. For volume groups version 2.1 (or higher), lvcreate can be performed when activated in
either shared, exclusive, or standalone mode.
Note that the lvmpud daemon must be running on all the nodes sharing a volume group activated in
shared mode. See lvmpud (1M).
When lvcreate is issued, it creates the logical volume device special les on all the nodes sharing the
volume group. The device special les are created with the same name on the nodes sharing the volume
group.
When a node wants to share the volume group, the user must rst execute a vgimport if logical volumes
were created at the time the volume group was not activated on that node.
The logical volumes device special les should have the same name on all the nodes sharing the volume
group.
If PVG-strict allocation policy is set, the /etc/lvmpvg le used is the one on the system where the command is issued.
LVM shared mode is currently only available in Serviceguard cluster.
Note that snapshot logical volume creation is not supported when the volume group is activated in shared
mode.
EXTERNAL INFLUENCES
Environment Variables
LANG determines the language in which messages are displayed.
If LANG is not specied or is null, it defaults to "C" (see lang (5)).
If any internationalization variable contains an invalid setting, all internationalization variables default
to "C" (see environ (5)).
EXAMPLES
Create a logical volume in volume group /dev/vg02:
HP-UX 11i Version 3: September 2010

Hewlett-Packard Company

lvcreate(1M)

lvcreate(1M)

lvcreate /dev/vg02
Create a logical volume in volume group /dev/vg03 with non-strict allocation policy:

lvcreate -s n /dev/vg03
Create a logical volume of size 100 MB in volume group /dev/vg03:

lvcreate -L 100 /dev/vg03


Create a space-efcient snapshot of size 10MB of the original logical volume /dev/vg03/lvol1:

lvcreate -S s -L 10 /dev/vg03/lvol1
Create a space-efcient snapshot of size 10MB of the original logical volume /dev/vg03/lvol1 with
the threshold value set to 50%:

lvcreate -S s -L 10 -P 50 /dev/vg03/lvol1
Create a fully allocated snapshot called testsnap of the original logical volume /dev/vg03/lvol1:

lvcreate -S s -n testsnap -t y /dev/vg03/lvol1


Create a logical volume of size 90 MB striped across 3 disks with a stripe size of 64 KB:

lvcreate -L 90 -i 3 -I 64 /dev/vg03
Create a logical volume of size 90 MB striped across 3 disks with one mirror copy and a stripe size of 64
KB:

lvcreate -L 90 -i 3 -I 64 -m 1 /dev/vg03
Distributed Allocation Policy
This example shows how the -D y option can be used to create EXTENT-BASED MIRRORED STRIPES.
Assume that volume group /dev/vgtest has two physical volume groups: pvg1 and pvg2.

Assume that each physical volume group has 2 physical volumes.


Assume that the rst physical volume in each pvg has 3 extents free and the second physical volume in
each pvg has 2 extents free.
The following command creates a logical volume in vgtest with EXTENT-BASED MIRRORED STRIPES:

lvcreate -D y -s g -m 1 -l 5 /dev/vgtest
The distributed allocation proceeds as follows:
A free extent is allocated from the 1st pvol in pvg1.
A free extent is allocated from the 2nd pvol in pvg1.
A free extent is allocated from the 1st pvol in pvg1.
A free extent is allocated from the 2nd pvol in pvg1.
A free extent is allocated from the 1st pvol in pvg1.
Mirrors for the ve extents are then allocated from the free extents in pvg2 in a similar manner.
WARNINGS
The root, swap, and dump logical volumes (see lvlnboot (1M)) must be created with contiguous allocation
policy.
Snapshot creation is not supported for swap or dump logical volumes. Also, creation of space efcient
snapshot is not supported for root and boot logical volumes.
The creation of striped and mirrored logical volume(s) may prevent the import and activation of the
volume group on an earlier HP-UX release. See lvcreate (1M) on the earlier release to see if it explicitly
states that striping and mirroring is supported. If the striped and mirrored logical volumes of the volume
group are removed or un-mirrored, the volume group becomes again compatible with the older HP-UX
releases.
By setting mirror consistency recovery off, crash recovery time will be reduced. After a system crash the
mirrored logical volume will be available, but there may not be consistent data across each mirror copy.
The only types of data that can safely be put on a mirrored logical volume with mirror consistency
recovery turned off are:

data not needed after a crash, such as swap or other raw scratch data, or
data that an application itself will automatically reconstruct; for example, a raw logical volume for
which a database keeps a log of incomplete transactions.

Hewlett-Packard Company

HP-UX 11i Version 3: September 2010

lvcreate(1M)

lvcreate(1M)

SEE ALSO
lvchange(1M), lvdisplay(1M), lvextend(1M), lvmadm(1M), lvmpud(1M), lvreduce(1M), pvchange(1M),
intro(7), lvm(7).

HP-UX 11i Version 3: September 2010

Hewlett-Packard Company

(Notes)

(Notes)

10

Hewlett-Packard Company

HP-UX 11i Version 3: September 2010

You might also like