import source from lvm2 2.02.79
[external/device-mapper.git] / man / lvcreate.8.in
1 .TH LVCREATE 8 "LVM TOOLS #VERSION#" "Sistina Software UK" \" -*- nroff -*-
2 .SH NAME
3 lvcreate \- create a logical volume in an existing volume group
4 .SH SYNOPSIS
5 .B lvcreate
6 [\-\-addtag Tag]
7 [\-\-alloc AllocationPolicy]
8 [\-A|\-\-autobackup y|n] [\-C|\-\-contiguous y|n] [\-d|\-\-debug]
9 [\-h|\-?|\-\-help] [\-\-noudevsync]
10 [\-\-ignoremonitoring]
11 [\-\-monitor {y|n}]
12 [\-i|\-\-stripes Stripes [\-I|\-\-stripesize StripeSize]]
13 {\-l|\-\-extents LogicalExtentsNumber[%{VG|PVS|FREE}] |
14  \-L|\-\-size LogicalVolumeSize[bBsSkKmMgGtTpPeE]}
15 [\-M|\-\-persistent y|n] [\-\-minor minor]
16 [\-m|\-\-mirrors Mirrors [\-\-nosync] [\-\-mirrorlog {disk|core|mirrored}] [\-\-corelog]
17 [\-R|\-\-regionsize MirrorLogRegionSize]]
18 [\-n|\-\-name LogicalVolumeName]
19 [\-p|\-\-permission r|rw] [\-r|\-\-readahead ReadAheadSectors|auto|none]
20 [\-t|\-\-test]
21 [\-\-type SegmentType]
22 [\-v|\-\-verbose] [\-Z|\-\-zero y|n]
23 VolumeGroupName [PhysicalVolumePath[:PE[-PE]]...]
24 .br
25
26 .br
27 .B lvcreate
28 {\-l|\-\-extents LogicalExtentsNumber[%{VG|FREE|ORIGIN}] |
29  \-L|\-\-size LogicalVolumeSize[bBsSkKmMgGtTpPeE]}
30 [\-c|\-\-chunksize ChunkSize]
31 [\-\-noudevsync]
32 [\-\-ignoremonitoring]
33 [\-\-monitor {y|n}]
34 \-n|\-\-name SnapshotLogicalVolumeName
35 {{\-s|\-\-snapshot}
36 OriginalLogicalVolumePath | 
37 [\-s|\-\-snapshot]
38 VolumeGroupName \-\-virtualsize VirtualSize}
39 .SH DESCRIPTION
40 lvcreate creates a new logical volume in a volume group ( see
41 .B vgcreate(8), vgchange(8)
42 ) by allocating logical extents from the free physical extent pool
43 of that volume group.  If there are not enough free physical extents then
44 the volume group can be extended ( see
45 .B vgextend(8)
46 ) with other physical volumes or by reducing existing logical volumes
47 of this volume group in size ( see
48 .B lvreduce(8)
49 ). If you specify one or more PhysicalVolumes, allocation of physical
50 extents will be restricted to these volumes.
51 .br
52 .br
53 The second form supports the creation of snapshot logical volumes which 
54 keep the contents of the original logical volume for backup purposes.
55 .SH OPTIONS
56 See \fBlvm\fP for common options.
57 .TP
58 .I \-c, \-\-chunksize ChunkSize
59 Power of 2 chunk size for the snapshot logical volume between 4k and 512k.
60 .TP
61 .I \-C, \-\-contiguous y|n
62 Sets or resets the contiguous allocation policy for
63 logical volumes. Default is no contiguous allocation based
64 on a next free principle.
65 .TP
66 .I \-i, \-\-stripes Stripes
67 Gives the number of stripes.
68 This is equal to the number of physical volumes to scatter
69 the logical volume.
70 .TP
71 .I \-I, \-\-stripesize StripeSize
72 Gives the number of kilobytes for the granularity of the stripes.
73 .br
74 StripeSize must be 2^n (n = 2 to 9) for metadata in LVM1 format.
75 For metadata in LVM2 format, the stripe size may be a larger
76 power of 2 but must not exceed the physical extent size.
77 .TP
78 .I \-l, \-\-extents LogicalExtentsNumber[%{VG|PVS|FREE|ORIGIN}]
79 Gives the number of logical extents to allocate for the new
80 logical volume.
81 The number can also be expressed as a percentage of the total space
82 in the Volume Group with the suffix %VG, as a percentage of the
83 remaining free space in the Volume Group with the suffix %FREE, as a
84 percentage of the remaining free space for the specified
85 PhysicalVolume(s) with the suffix %PVS, or (for a snapshot) as a
86 percentage of the total space in the Origin Logical Volume with the
87 suffix %ORIGIN.
88 .TP
89 .I \-L, \-\-size LogicalVolumeSize[bBsSkKmMgGtTpPeE]
90 Gives the size to allocate for the new logical volume.
91 A size suffix of K for kilobytes, M for megabytes,
92 G for gigabytes, T for terabytes, P for petabytes
93 or E for exabytes is optional.
94 .br
95 Default unit is megabytes.
96 .TP
97 .I \-\-minor minor
98 Set the minor number.
99 .TP
100 .I \-M, \-\-persistent y|n
101 Set to y to make the minor number specified persistent.
102 .TP
103 .I \-m, \-\-mirrors Mirrors
104 Creates a mirrored logical volume with Mirrors copies.  For example,
105 specifying "-m 1" would result in a mirror with two-sides; that is, a
106 linear volume plus one copy.
107
108 Specifying the optional argument --nosync will cause the creation
109 of the mirror to skip the initial resynchronization.  Any data written
110 afterwards will be mirrored, but the original contents will not be
111 copied.  This is useful for skipping a potentially long and resource
112 intensive initial sync of an empty device.
113
114 The optional argument --mirrorlog specifies the type of log to be used.
115 The default is disk, which is persistent and requires
116 a small amount of storage space, usually on a separate device from the
117 data being mirrored.  Using core means the mirror is regenerated
118 by copying the data from the first device again each time the
119 device is activated, for example, after every reboot.  Using "mirrored"
120 will create a persistent log that is itself mirrored.
121
122 The optional argument --corelog is equivalent to --mirrorlog core.
123
124 .TP
125 .I \-n, \-\-name LogicalVolumeName
126 The name for the new logical volume.
127 .br
128 Without this option a default names of "lvol#" will be generated where
129 # is the LVM internal number of the logical volume.
130 .TP
131 .I \-\-noudevsync
132 Disable udev synchronisation. The
133 process will not wait for notification from udev.
134 It will continue irrespective of any possible udev processing
135 in the background.  You should only use this if udev is not running
136 or has rules that ignore the devices LVM2 creates.
137 .TP
138 .I \-\-monitor y|n
139 Start or avoid monitoring a mirrored or snapshot logical volume with
140 dmeventd, if it is installed. 
141 If a device used by a monitored mirror reports an I/O error,
142 the failure is handled according to 
143 \fBmirror_image_fault_policy\fP and \fBmirror_log_fault_policy\fP
144 set in \fBlvm.conf\fP.
145 .TP
146 .I \-\-ignoremonitoring
147 Make no attempt to interact with dmeventd unless \-\-monitor
148 is specified.
149 .TP
150 .I \-p, \-\-permission r|rw
151 Set access permissions to read only or read and write.
152 .br
153 Default is read and write.
154 .TP
155 .I \-r, \-\-readahead ReadAheadSectors|auto|none
156 Set read ahead sector count of this logical volume.
157 For volume groups with metadata in lvm1 format, this must
158 be a value between 2 and 120.
159 The default value is "auto" which allows the kernel to choose
160 a suitable value automatically.
161 "None" is equivalent to specifying zero.
162 .TP
163 .I \-R, \-\-regionsize MirrorLogRegionSize
164 A mirror is divided into regions of this size (in MB), and the mirror log 
165 uses this granularity to track which regions are in sync.
166 .TP
167 .I \-s, \-\-snapshot
168 Create a snapshot logical volume (or snapshot) for an existing, so called
169 original logical volume (or origin).
170 Snapshots provide a 'frozen image' of the contents of the origin
171 while the origin can still be updated. They enable consistent
172 backups and online recovery of removed/overwritten data/files. The snapshot
173 does not need the same amount of storage the origin has. In a typical scenario,
174 15-20% might be enough. In case the snapshot runs out of storage, use
175 .B lvextend(8)
176 to grow it. Shrinking a snapshot is supported by
177 .B lvreduce(8)
178 as well. Run
179 .B lvdisplay(8)
180 on the snapshot in order to check how much data is allocated to it.
181 Note that a small amount of the space you allocate to the snapshot is
182 used to track the locations of the chunks of data, so you should
183 allocate slightly more space than you actually need and monitor the
184 rate at which the snapshot data is growing so you can avoid running out
185 of space.
186 .TP
187 .I \-\-type SegmentType
188 Create a logical volume that uses the specified segment type
189 (e.g. "mirror", "snapshot", "striped").  Especially useful when no
190 existing commandline switch alias enables the use of the desired type
191 (e.g. "error" or "zero" types).  Many segment types already have a
192 commandline switch alias that will enable their use (-s is an alias for
193 --type snapshot).
194 .TP
195 .I \-\-virtualsize VirtualSize
196 Create a sparse device of the given size (in MB by default) using a snapshot.  
197 Anything written to the device will be returned when reading from it.
198 Reading from other areas of the device will return blocks of zeros.
199 It is implemented by creating a hidden virtual device of the
200 requested size using the zero target.  A suffix of _vorigin is used for
201 this device.
202 .TP
203 .I \-Z, \-\-zero y|n
204 Controls zeroing of the first KB of data in the new logical volume.
205 .br
206 Default is yes.
207 .br
208 Volume will not be zeroed if read only flag is set.
209 .br
210 Snapshot volumes are zeroed always.
211
212 .br
213 Warning: trying to mount an unzeroed logical volume can cause the system to
214 hang.
215 .SH Examples
216 "lvcreate -i 3 -I 8 -L 100M vg00" tries to create a striped logical
217 volume with 3 stripes, a stripesize of 8KB and a size of 100MB in the volume
218 group named vg00. The logical volume name will be chosen by lvcreate.
219
220 "lvcreate -m1 -L 500M vg00" tries to create a mirror logical volume
221 with 2 sides with a useable size of 500 MiB.  This operation would
222 require 3 devices - two for the mirror devices and one for the disk
223 log.
224
225 "lvcreate -m1 --mirrorlog core -L 500M vg00" tries to create a mirror logical volume
226 with 2 sides with a useable size of 500 MiB.  This operation would
227 require 2 devices - the log is "in-memory".
228
229 "lvcreate --size 100m --snapshot --name snap /dev/vg00/lvol1"
230 .br
231 creates a snapshot logical volume named /dev/vg00/snap which has access to the
232 contents of the original logical volume named /dev/vg00/lvol1
233 at snapshot logical volume creation time. If the original logical volume
234 contains a file system, you can mount the snapshot logical volume on an
235 arbitrary directory in order to access the contents of the filesystem to run
236 a backup while the original filesystem continues to get updated.
237
238 "lvcreate --virtualsize 1T --size 100M --snapshot --name sparse vg1"
239 .br
240 creates a sparse device named /dev/vg1/sparse of size 1TB with space for just
241 under 100MB of actual data on it.
242 .br
243
244 "lvcreate -L 64M -n lvol1 vg00 /dev/sda:0-7 /dev/sdb:0-7"
245 .br
246 creates a linear logical volume "vg00/lvol1" using physical extents
247 /dev/sda:0-7 and /dev/sdb:0-7 for allocation of extents.
248
249
250 .SH SEE ALSO
251 .BR lvm (8), 
252 .BR vgcreate (8), 
253 .BR lvremove (8), 
254 .BR lvrename (8)
255 .BR lvextend (8), 
256 .BR lvreduce (8), 
257 .BR lvdisplay (8), 
258 .BR lvscan (8)