lvchange
Modify attributes of a logical volume
TLDR
Activate a logical volume
Deactivate a logical volume
Enable autoactivation for a logical volume
Set a logical volume to read-only (use rw for read-write)
Skip activation for a logical volume
Refresh a logical volume using the latest metadata
SYNOPSIS
lvchange [OPTIONS] LogicalVolumePath [ LogicalVolumePath... ]
lvchange [OPTIONS] VolumeGroupName/LogicalVolumeName [ VolumeGroupName/LogicalVolumeName... ]
PARAMETERS
-a, --activate {y|n|l|L|r|R}
Controls the activation state of the logical volume. 'y' (default) activates, 'n' deactivates, 'l' activates locally, 'L' activates on a specific host, 'r' activates in read-only mode, 'R' activates read-only locally.
-p, --permission {r|rw}
Sets the logical volume's permission to read-only ('r') or read-write ('rw').
-r, --readahead {
Sets the read-ahead sector count for the logical volume. 'Auto' uses the system default.
-s, --sync {y|n}
Controls whether outdated mirrored/RAID images are synchronized. 'y' synchronizes, 'n' disables.
-C, --contiguous {y|n}
Sets or clears the contiguous allocation policy. 'y' requires contiguous physical extents, 'n' allows non-contiguous. (Less commonly used for existing LVs).
--cachemode {writethrough|writeback}
Sets the cache mode for a cache logical volume.
--cachepolicy
Sets the cache policy for a cache logical volume.
--metadatasignature {y|n}
Enables or disables the metadata signature for the LV.
-K, --setactivationskip {y|n}
Sets or clears the activation skip flag for the logical volume. If set, the LV will not be activated during boot.
-k, --cleansnapshot
Deletes the snapshot's invalid original volume, typically used after an unexpected shutdown.
--addtag
Adds a tag to the logical volume for organizational purposes.
--deltag
Deletes a tag from the logical volume.
--refresh
Refreshes the kernel's device mapper table for the logical volume, useful after certain metadata changes.
-v, --verbose
Displays verbose runtime information, showing more details about the command's execution.
-y, --yes
Assumes 'yes' to all questions; useful for scripting and non-interactive operations.
-n, --noudevsync
Disables udev synchronization. Use with extreme caution as it can lead to inconsistent device states.
DESCRIPTION
The lvchange command is a crucial utility within the Logical Volume Manager (LVM) framework in Linux, designed to modify the attributes of existing logical volumes (LVs) without altering their size. Unlike commands like lvextend or lvreduce, which resize logical volumes, lvchange focuses on metadata and operational parameters.
Common uses include activating or deactivating logical volumes (making them available or unavailable to the system), setting read/write permissions, adjusting read-ahead settings, managing cache modes for cached LVs, setting data synchronization parameters for RAID or mirrored LVs, or modifying various other flags. It can be applied to individual logical volumes or to all logical volumes within a specified volume group or on the system. Proper use of lvchange is essential for managing the operational state and performance characteristics of LVM-based storage.
CAVEATS
Changing activation state for a logical volume that contains a mounted filesystem can lead to data corruption or system instability. Always unmount filesystems before deactivating LVs.
Using -n (--noudevsync) can be dangerous as it bypasses udev notifications, potentially leading to inconsistent device states if not handled carefully.
Modifying attributes like readahead might not immediately reflect changes for mounted filesystems without remounting or refreshing the kernel's device mapper table.
ACTIVATION STATES
The activation options (-a) are critical for controlling access to LVM logical volumes. 'y' typically activates on all nodes in a cluster (if LVM is configured for clustering), while 'l' activates only locally. 'r' provides read-only access, which is useful for data recovery or consistency checks without risking writes.
PERMISSIONS AND OWNERSHIP
lvchange requires root privileges to execute, as it modifies fundamental storage configurations. Misconfigurations can lead to data inaccessibility or system boot failures, emphasizing the need for careful use.
HISTORY
The lvchange command is an integral part of the Logical Volume Manager (LVM) framework, which was first introduced in Linux 2.4 kernels to provide flexible disk management capabilities. As LVM evolved, lvchange gained functionalities to support new features such as snapshots, mirroring (RAID LVs), thin provisioning, and caching. Its role has remained consistent: to manage the operational attributes and state of logical volumes, adapting to new storage technologies and management paradigms within the LVM ecosystem.