Professional Documents
Culture Documents
LV Create
LV Create
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:
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.
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).
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.
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
lvcreate(1M)
-S snap_type
lvcreate(1M)
-A autobackup
n
-c mirror_consistency
-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.
-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:
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:
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).
-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
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
Hewlett-Packard Company
lvcreate(1M)
-l
lvcreate(1M)
-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
-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:
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.
-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.
l
-r relocate
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.
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
lvcreate(1M)
lvcreate(1M)
n
-t timestamp
Do not set a strict or PVG-strict allocation policy. Mirrors of a logical extent can share the same physical volume.
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 -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 -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.
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
lvcreate(1M)
lvcreate(1M)
SEE ALSO
lvchange(1M), lvdisplay(1M), lvextend(1M), lvmadm(1M), lvmpud(1M), lvreduce(1M), pvchange(1M),
intro(7), lvm(7).
Hewlett-Packard Company
(Notes)
(Notes)
10
Hewlett-Packard Company