1LVMAUTOACTIVATION(7)                                      LVMAUTOACTIVATION(7)
2
3
4

NAME

6       lvmautoactivation — LVM autoactivation
7

DESCRIPTION

9       Autoactivation  is the activation of LVs performed automatically by the
10       system in response to LVM devices being attached to the machine.   When
11       all  PVs in a VG have been attached, the VG is complete, and LVs in the
12       VG are activated.
13
14       Autoactivation of VGs, or specific LVs, can be prevented using vgchange
15       or  lvchange  --setautoactivation n.  The lvm.conf auto_activation_vol‐
16       ume_list is another way to limit autoactivation.
17
18   event autoactivation
19       LVM autoactivation is "event based", in which complete  VGs  are  acti‐
20       vated  in  response  to uevents which occur during system startup or at
21       any time after the system has started.  An old form  of  autoactivation
22       was  "static" in which complete VGs are activated at a fixed point dur‐
23       ing system startup by a systemd service, and not in response to events.
24
25       Event based autoactivation is driven by udev, udev rules, and  systemd.
26       When  a  device  is attached to a machine, a uevent is generated by the
27       kernel to notify userspace of the new device.  systemd-udev  runs  udev
28       rules  to process the new device.  Udev rules use blkid to identify the
29       device as an LVM PV and then execute the lvm-specific udev rule for the
30       device, which triggers autoactivation.
31
32       There are two variations of event based autoactivation that may be used
33       on a system, depending on the LVM udev rule that is installed (found in
34       /lib/udev/rules.d/.)   The  following summarizes the steps in each rule
35       which lead to autoactivation:
36
37       69-dm-lvm-metad.rules
38
39       • device /dev/name with major:minor X:Y is attached to the machine
40
41       • systemd/udev runs blkid to identify /dev/name as an LVM PV
42
43       • udev rule 69-dm-lvm-metad.rules is run for /dev/name
44
45       • the lvm udev rule runs the systemd service lvm2-pvscan@X:Yservice
46
47       • the lvm2-pvscan service runs:
48         pvscan --cache -aay --major X --minor Y
49
50       • pvscan reads the device, records that the PV is online  (see  pvs_on‐
51         line), and checks if the VG is complete.
52
53       • if  the  VG is complete, pvscan creates the vgs_online temp file, and
54         activates the VG.
55
56       • the activation command output  can  be  seen  from  systemctl  status
57         lvm2-pvscan*
58
59       69-dm-lvm.rules
60
61       • device /dev/name with major:minor X:Y is attached to the machine
62
63       • systemd/udev runs blkid to identify /dev/name as an LVM PV
64
65       • udev rule 69-dm-lvm.rules is run for /dev/name
66
67       • the lvm udev rule runs:
68         pvscan --cache --listvg --checkcomplete --vgonline
69         --autoactivation event --udevoutput --journal=output /dev/name
70
71       • pvscan  reads  the device, records that the PV is online (see pvs_on‐
72         line), and checks if the VG is complete.
73
74       • if the VG is complete, pvscan creates the vgs_online temp  file,  and
75         prints   the   name   of   the  VG  for  the  udev  rule  to  import:
76         LVM_VG_NAME_COMPLETE='vgname'
77
78       • if the lvm udev rule sees LVM_VG_NAME_COMPLETE from pvscan, it  acti‐
79         vates  the  VG  using  a  transient  systemd  service named lvm-acti‐
80         vate-<vgname>.
81
82       • the lvm-activate-<vgname> service runs
83         vgchange -aay --autoactivation event <vgname>
84
85       • the activation command output can be seen from journalctl -u  lvm-ac‐
86         tivate-<vgname>
87
88   pvscan options
89       --cache
90       Read the <device> arg (and only that device), and record that the PV is
91       online by creating the /run/lvm/pvs_online/<pvid> file  containing  the
92       name of the VG and the device for the PV.
93
94       -aay
95       Activate  the VG from the pvscan command (includes implicit --checkcom‐
96       plete and --vgonline.)
97
98       --checkcomplete
99       Check if the VG is complete, i.e. all PVs are present on the system, by
100       checking /run/lvm/pvs_online/<pvid> files.
101
102       --vgonline
103       Create  /run/lvm/vgs_online/<vgname> if the VG is complete (used to en‐
104       sure only one command performs activation.)
105
106       --autoactivation event
107       Inform the command it is used for event based autoactivation.
108
109       --listvg
110       Print the name of the VG using the device.
111
112       --udevoutput
113       Only print output that can be imported to the udev rule, using the udev
114       environment key format, i.e. NAME='value'.
115
116       --journal=output
117       Send  standard  command  output to the journal (when stdout is reserved
118       for udev output.)
119
120   run files
121       Autoactivation commands use a number of temp files  in  /run/lvm  (with
122       the expectation that /run is cleared between boots.)
123
124       pvs_online
125       pvscan  --cache  creates a file here for each PV that is attached.  The
126       file is named with the PVID and contains the VG name and device  infor‐
127       mation.   The  existence  of the file is used to determine when all PVs
128       for a given VG are present.  The device information in these  files  is
129       also  used  to  optimize locating devices for a VG when the VG is acti‐
130       vated.
131
132       pvs_lookup
133       pvscan --cache creates a file here named for a VG (if one  doesn't  al‐
134       ready  exist.)   The  file contains a list of PVIDs in the VG.  This is
135       needed when a PV is processed which has no VG metadata, in  which  case
136       the  list  of  PVIDs from the lookup file is used to check if the VG is
137       complete.
138
139       vgs_online
140       The first activation command (pvscan or  vgchange)  to  create  a  file
141       here,  named  for  the  VG, will activate the VG.  This resolves a race
142       when concurrent commands attempt to activate a VG at once.
143
144   static autoactivation
145       A static autoactivation method is no longer provided by  lvm.   Setting
146       event_activation=0 still disables event based autoactivation.  WARNING:
147       disabling event activation without an alternative may prevent a  system
148       from booting.  A custom systemd service could be written to run autoac‐
149       tivation during system startup, in which case disabling event autoacti‐
150       vation may be useful.
151
152   lvm.conf filter
153       Device  symlinks  from /dev/disk/ can be used in the lvm.conf filter to
154       guard against changes in kernel device names. The /dev/disk/by-path/ or
155       /dev/disk/by-id/ prefixes should be included in the filter names; these
156       prefixes help lvm detect that symlink names are used. Filters  contain‐
157       ing  symlinks  require special matching by commands run in the lvm udev
158       rule.
159
160       Common symlinks,  e.g.  beginning  with  wwn-,  scsi-,  pci-,  or  lvm-
161       pv-uuid-, are recommended.  Uncommon or custom symlinks created by cus‐
162       tom udev rules may be less reliable. If a custom udev rule creates sym‐
163       links  used  in  the  lvm  filter, then the udev rule should be started
164       prior to the lvm rule.
165

EXAMPLES

167       VG "vg" contains two PVs:
168       $ pvs -o name,vgname,uuid /dev/sdb /dev/sdc
169         PV         VG PV UUID
170         /dev/sdb   vg 1uKpaT-lFOZ-NLHX-j4jI-OBi1-QpdE-HZ5hZY
171         /dev/sdc   vg 5J3tM8-aIPe-2vbd-DBe7-bvRq-TGj0-DaKV2G
172
173       use of --cache:
174       $ pvscan --cache /dev/sdb
175         pvscan[12922] PV /dev/sdb online.
176       $ pvscan --cache /dev/sdc
177         pvscan[12923] PV /dev/sdc online.
178
179       $ cat /run/lvm/pvs_online/1uKpaTlFOZNLHXj4jIOBi1QpdEHZ5hZY
180       8:16
181       vg:vg
182       dev:/dev/sdb
183       $ cat /run/lvm/pvs_online/5J3tM8aIPe2vbdDBe7bvRqTGj0DaKV2G
184       8:32
185       vg:vg
186       dev:/dev/sdc
187
188       use of -aay:
189       $ pvscan --cache -aay /dev/sdb
190         pvscan[12935] PV /dev/sdb online, VG vg incomplete (need 1).
191       $ pvscan --cache -aay /dev/sdc
192         pvscan[12936] PV /dev/sdc online, VG vg is complete.
193         pvscan[12936] VG vg run autoactivation.
194         1 logical volume(s) in volume group "vg" now active
195
196       $ cat /run/lvm/pvs_online/1uKpaTlFOZNLHXj4jIOBi1QpdEHZ5hZY
197       8:16
198       vg:vg
199       dev:/dev/sdb
200       $ cat /run/lvm/pvs_online/5J3tM8aIPe2vbdDBe7bvRqTGj0DaKV2G
201       8:32
202       vg:vg
203       dev:/dev/sdc
204       $ ls /run/lvm/vgs_online/vg
205       /run/lvm/vgs_online/vg
206
207       use of --listvg:
208       $ pvscan --cache --listvg /dev/sdb
209         VG vg
210       $ pvscan --cache --listvg /dev/sdc
211         VG vg
212
213       $ cat /run/lvm/pvs_online/1uKpaTlFOZNLHXj4jIOBi1QpdEHZ5hZY
214       8:16
215       vg:vg
216       dev:/dev/sdb
217       $ cat /run/lvm/pvs_online/5J3tM8aIPe2vbdDBe7bvRqTGj0DaKV2G
218       8:32
219       vg:vg
220       dev:/dev/sdc
221
222       use of --checkcomplete:
223       $ pvscan --cache --listvg --checkcomplete --vgonline /dev/sdb
224         pvscan[12996] PV /dev/sdb online, VG vg incomplete (need 1).
225         VG vg incomplete
226       $ pvscan --cache --listvg --checkcomplete --vgonline /dev/sdc
227         pvscan[12997] PV /dev/sdc online, VG vg is complete.
228         VG vg complete
229
230       use of --udevoutput:
231       $ pvscan --cache --listvg --checkcomplete --vgonline --udevoutput /dev/sdb
232       LVM_VG_NAME_INCOMPLETE='vg'
233       $ pvscan --cache --listvg --checkcomplete --vgonline --udevoutput /dev/sdc
234       LVM_VG_NAME_COMPLETE='vg'
235
236       use of --listlvs:
237       $ lvs -o name,devices vg
238         LV    Devices
239         lvol0 /dev/sdb(0)
240         lvol1 /dev/sdc(0)
241         lvol2 /dev/sdb(1),/dev/sdc(1)
242
243       $ pvscan --cache --listlvs --checkcomplete /dev/sdb
244         pvscan[13288] PV /dev/sdb online, VG vg incomplete (need 1).
245         VG vg incomplete
246         LV vg/lvol0 complete
247         LV vg/lvol2 incomplete
248       $ pvscan --cache --listlvs --checkcomplete /dev/sdc
249         pvscan[13289] PV /dev/sdc online, VG vg is complete.
250         VG vg complete
251         LV vg/lvol1 complete
252         LV vg/lvol2 complete
253
254
255
256
257Red Hat, Inc           LVM TOOLS 2.03.22(2) (2023-08-02)  LVMAUTOACTIVATION(7)
Impressum