Red Hat Training

A Red Hat training course is available for RHEL 8

Chapter 13. Logical volume activation

By default, when you create a logical volume, it is in an active state. A logical volume that is an active state can be used through a block device. An activated logical volume is accessible and is subject to change.

There are various circumstances, where you need to make an individual logical volume inactive and therefore unknown to the kernel. You can activate or deactivate individual logical volume with the -a option of the lvchange command.

The following is the format to deactivate an individual logical volume:

# lvchange -an vg/lv

The following is the format to activate an individual logical volume:

# lvchange -ay vg/lv

You can 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 following is the format to deactivate all of the logical volumes in a volume group:

# vgchange -an vg

The following is the format to activate all of the logical volumes in a volume group:

# vgchange -ay vg
Note

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.

13.1. Controlling autoactivation of logical volumes and volume groups

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 set the autoactivation property on a VG or LV. When the autoactivation property is disabled, the VG or LV will not be activated by a command doing autoactivation, such as vgchange, lvchange, or pvscan using -aay option. If autoactivation is disabled on a VG, no LVs will be autoactivated in that VG, and the autoactivation property has no effect. If autoactivation is enabled on a VG, autoactivation can be disabled for individual LVs.

Procedure

  • You can update the autoactivation settings in one of the following ways:

    • Control autoactivation of a VG using the command line:

      # vgchange --setautoactivation <y|n>
    • Control autoactivation of a LV using the command line:

      # lvchange --setautoactivation <y|n>
    • Control autoactivation of a LV in the /etc/lvm/lvm.conf configuration file using one of the following configuration options:

      • 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. Setting auto_activation_volume_list to specific logical volumes and volume groups limits autoactivation to those logical volumes.

Additional resources

  • /etc/lvm/lvm.conf configuration file
  • lvmautoactivation(7) man page

13.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 about 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.

Alternatively, you can use the --setactivationskip y|n option with the lvcreate or the lvchange commands to enable or disable the activation skip flag.

Procedure

  • You can set the activation skip flag on a logical volume in the following ways:

    • 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 -n SnapLV -kn -s vg/ThinLV --thinpool vg/ThinPoolLV
    • The following command removes the activation skip flag from a snapshot logical volume:

      # lvchange -kn VG/SnapLV

Verification steps

  • Verify if a thin snapshot without the activation skip flag has been created:

    # lvs -a -o +devices,segtype
      LV                 VG            Attr       LSize    Pool       Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices             Type
      SnapLV             vg            Vwi-a-tz--  100.00m ThinPoolLV ThinLV 0.00                                                        thin
      ThinLV             vg            Vwi-a-tz--  100.00m ThinPoolLV        0.00                                                        thin
      ThinPoolLV         vg            twi-aotz--  100.00m                   0.00   10.94                            ThinPoolLV_tdata(0) thin-pool
      [ThinPoolLV_tdata] vg            Twi-ao----  100.00m                                                           /dev/sdc1(1)        linear
      [ThinPoolLV_tmeta] vg            ewi-ao----    4.00m                                                           /dev/sdd1(0)        linear
      [lvol0_pmspare]    vg            ewi-------    4.00m                                                           /dev/sdc1(0)        linear

13.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:

CommandActivation

lvchange -ay|-aey

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.

lvchange -asy

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.

lvchange -an

Deactivate the logical volume.

13.4. Activating a logical volume with missing devices

You can control whether LVs that are missing devices can be activated by using the lvchange command with the --activationmode partial|degraded|complete option. The values are described below:

Activation ModeMeaning

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 activationmode is determined by the activationmode setting in the /etc/lvm/lvm.conf file. It is used if no command line option is given.

Additional resources

  • lvmraid(7) man page