summaryrefslogtreecommitdiff
path: root/man/pvcreate.8_des
blob: 69bd133aa10afc62d7faa9725591228c7b0171f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
pvcreate initializes a Physical Volume (PV) on a device so the device is
recognized as belonging to LVM.  This allows the PV to be used in a Volume
Group (VG).  An LVM disk label is written to the device, and LVM metadata
areas are initialized.  A PV can be placed on a whole device or partition.
.P
Use \fBvgcreate\fP(8) to create a new VG on the PV, or \fBvgextend\fP(8)
to add the PV to an existing VG.  Use \fBpvremove\fP(8) to remove the LVM
disk label from the device.
.P
The force option will create a PV without confirmation.  Repeating the
force option (\fB-ff\fP) will forcibly create a PV, overriding checks that
normally prevent it, e.g. if the PV is already in a VG.
.P
.B Metadata location, size, and alignment
.P
The LVM disk label begins 512 bytes from the start of the device, and is
512 bytes in size.
.P
The LVM metadata area begins at an offset (from the start of the device)
equal to the page size of the machine creating the PV (often 4 KiB.) The
metadata area contains a 512 byte header and a multi-KiB circular buffer
that holds text copies of the VG metadata.
.P
With default settings, the first physical extent (PE), which contains LV
data, is 1 MiB from the start of the device.  This location is controlled
by \fBdefault_data_alignment\fP in lvm.conf, which is set to 1 (MiB) by
default.  The pe_start will be a multiple of this many MiB.  This location
can be checked with:
.br
.B pvs -o pe_start
.I PV
.P
The size of the LVM metadata area is the space between the the start of
the metadata area and the first PE.  When metadata begins at 4 KiB and the
first PE is at 1024 KiB, the metadata area size is 1020 KiB.  This can be
checked with:
.br
.B pvs -o mda_size
.I PV
.P
The mda_size cannot be increased after pvcreate, so if larger metadata is
needed, it must be set during pvcreate.  Two copies of the VG metadata
must always fit within the metadata area, so the maximum VG metadata size
is around half the mda_size.  This can be checked with:
.br
.B vgs -o mda_free
.I VG
.P
A larger metadata area can be set with --metadatasize.  The resulting
mda_size may be larger than specified due to default_data_alignment
placing pe_start on a MiB boundary, and the fact that the metadata area
extends to the first PE.  With metadata starting at 4 KiB and
default_data_alignment 1 (MiB), setting --metadatasize 2048k results in
pe_start of 3 MiB and mda_size of 3068 KiB.  Alternatively, --metadatasize
2044k results in pe_start at 2 MiB and mda_size of 2044 KiB.
.P
The alignment of pe_start described above may be automatically overridden
based on md device properties or device i/o properties reported in sysfs.
These automatic adjustments can be enabled/disabled using lvm.conf
settings md_chunk_alignment and data_alignment_offset_detection.
.P
To use a different pe_start alignment, use the --dataalignment option.
The --metadatasize option would also typically be used in this case
because the metadata area size also determines the location of pe_start.
When using these two options together, pe_start is calculated as:
metadata area start (page size), plus the specified --metadatasize,
rounded up to the next multiple of --dataalignment.
With metadata starting at 4 KiB, --metadatasize 2048k, and --dataalignment 128k,
pe_start is 2176 KiB and mda_size is 2172 KiB.
The pe_start of 2176 KiB is the nearest even multiple of 128 KiB that
provides at least 2048 KiB of metadata space.
Always check the resulting alignment and metadata size when using
these options.
.P
To shift an aligned pe_start value, use the --dataalignmentoffset option.
The pe_start alignment is calculated as described above, and then the
value specified with --dataalignmentoffset is added to produce the final
pe_start value.