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

EXAMPLES

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