Red Hat Training
A Red Hat training course is available for RHEL 8
Chapter 12. Logical volume activation
A logical volume that is an active state can be used through a block device. A logical volume that is activated is accessible and is subject to change. When you create a logical volume it is activated by default.
There are various circumstances for which you need to make an individual logical volume inactive and thus unknown to the kernel. You can activate or deactivate individual logical volume with the -a
option of the lvchange
command.
The format for the command to deactivate an individual logical volume is as follows.
lvchange -an vg/lv
The format for the command to activate an individual logical volume is as follows.
lvchange -ay vg/lv
You can and activate or deactivate all of the logical volumes in a volume group with the -a
option of the vgchange
command. This is the equivalent of running the lvchange -a
command on each individual logical volume in the volume group.
The format for the command to deactivate all of the logical volumes in a volume group is as follows.
vgchange -an vg
The format for the command to activate all of the logical volumes in a volume group is as follows.
vgchange -ay vg
During manual activation, the systemd
automatically mounts LVM volumes with the corresponding mount point from the /etc/fstab
file unless the systemd-mount
unit is masked.
12.1. Controlling autoactivation of logical volumes
Autoactivation of a logical volume refers to the event-based automatic activation of a logical volume during system startup. As devices become available on the system (device online events), systemd/udev
runs the lvm2-pvscan
service for each device. This service runs the pvscan --cache -aay device
command, which reads the named device. If the device belongs to a volume group, the pvscan
command will check if all of the physical volumes for that volume group are present on the system. If so, the command will activate logical volumes in that volume group.
You can use the following configuration options in the /etc/lvm/lvm.conf
configuration file to control autoactivation of logical volumes.
global/event_activation
When
event_activation
is disabled,systemd/udev
will autoactivate logical volume only on whichever physical volumes are present during system startup. If all physical volumes have not appeared yet, then some logical volumes may not be autoactivated.activation/auto_activation_volume_list
Setting
auto_activation_volume_list
to an empty list disables autoactivation entirely. Settingauto_activation_volume_list
to specific logical volumes and volume groups limits autoactivation to those logical volumes.
For information on setting these options, see the /etc/lvm/lvm.conf
configuration file.
12.2. Controlling logical volume activation
You can control the activation of logical volume in the following ways:
-
Through the
activation/volume_list
setting in the/etc/lvm/conf
file. This allows you to specify which logical volumes are activated. For information on using this option, see the/etc/lvm/lvm.conf
configuration file. - By means of the activation skip flag for a logical volume. When this flag is set for a logical volume, the volume is skipped during normal activation commands.
You can set the activation skip flag on a logical volume in the following ways.
-
You can turn off the activation skip flag when creating a logical volume by specifying the
-kn
or--setactivationskip n
option of thelvcreate
command. -
You can turn off the activation skip flag for an existing logical volume by specifying the
-kn
or--setactivationskip n
option of thelvchange
command. -
You can turn on the activation skip flag on again for a volume where it has been turned off with the
-ky
or--setactivationskip y
option of thelvchange
command.
To determine whether the activation skip flag is set for a logical volume run the lvs
command, which displays the k
attribute as in the following example.
# lvs vg/thin1s1
LV VG Attr LSize Pool Origin
thin1s1 vg Vwi---tz-k 1.00t pool0 thin1
You can activate a logical volume with the k
attribute set by using the -K
or --ignoreactivationskip
option in addition to the standard -ay
or --activate y
option.
By default, thin snapshot volumes are flagged for activation skip when they are created. You can control the default activation skip setting on new thin snapshot volumes with the auto_set_activation_skip
setting in the /etc/lvm/lvm.conf
file.
The following command activates a thin snapshot logical volume that has the activation skip flag set.
# lvchange -ay -K VG/SnapLV
The following command creates a thin snapshot without the activation skip flag
# lvcreate --type thin -n SnapLV -kn -s ThinLV --thinpool VG/ThinPoolLV
The following command removes the activation skip flag from a snapshot logical volume.
# lvchange -kn VG/SnapLV
12.3. Activating shared logical volumes
You can control logical volume activation of a shared logical volume with the -a
option of the lvchange
and vgchange
commands, as follows.
Command | Activation |
---|---|
| Activate the shared logical volume in exclusive mode, allowing only a single host to activate the logical volume. If the activation fails, as would happen if the logical volume is active on another host, an error is reported. |
| Activate the shared logical volume in shared mode, allowing multiple hosts to activate the logical volume concurrently. If the activation fails, as would happen if the logical volume is active exclusively on another host, an error is reported. If the logical type prohibits shared access, such as a snapshot, the command will report an error and fail. Logical volume types that cannot be used concurrently from multiple hosts include thin, cache, raid, and snapshot. |
| Deactivate the logical volume. |
12.4. Activating a logical volume with missing devices
You can configure which logical volumes with missing devices are activated by setting the activation_mode
parameter with the lvchange
command to one of the following values.
Activation Mode | Meaning |
---|---|
complete | Allows only logical volumes with no missing physical volumes to be activated. This is the most restrictive mode. |
degraded | Allows RAID logical volumes with missing physical volumes to be activated. |
partial | Allows any logical volume with missing physical volumes to be activated. This option should be used for recovery or repair only. |
The default value of activation_mode
is determined by the activation_mode
setting in the /etc/lvm/lvm.conf
file. For further information, see the lvmraid
(7) man page.