Red Hat Enterprise Linux Diagnostics and Troubleshooting
Logical volume management (LVM) provides administrators with a comprehensive storage virtualization framework. One or more data storage devices (physical volumes) are aggregated into a storage pool (volume group), from which volumes are carved out to act as block devices (logical volumes). LVM supports data striping or mirroring, or both, between physical volumes.
Similar to dm-multipath, logical volume management uses the kernel Device Mapper subsystem to create the LVM devices. Logical volumes are created in the /dev/ directory as dm-* device nodes, but with symlinks in both the /dev/mapper/ and /dev/ directories with persistent names.<vgname>/
LVM behavior is configured in the /etc/lvm/lvm.conf file. Settings in this file control locking behavior, device scanning, names of multipathed physical volumes, and other LVM attributes. The following table lists some common options:
| /etc/lvm/lvm.conf | Options |
|---|---|
scan
| Which directory to scan for physical volume device nodes. |
obtain_device_list_from_udev
| If udev should be used to obtain a list of eligible block devices for scanning. |
preferred_names
| A list of regular expressions to show which device names should have preference when displaying devices. If multiple device names (nodes) are found for the same PV, then the LVM tools give preference to those names that appear earlier in this list. |
filter
| A list of regular expressions prefixed with a for Add or r for Remove.
This list determines which device nodes are scanned for the presence of a PV signature.
The default is [ "a/.*/" ], which adds every device.
You can use this option to remove a device that should never be scanned. |
backup
| This setting determines whether to store a text-based backup of volume group metadata after every change. You can use this backup to restore a volume group if the on-disk metadata gets corrupted. |
backup_dir
| This setting specifies where to store the backup of volume group metadata. |
archive
| This setting determines whether to archive old volume group configurations or layouts to use later to revert changes. |
archive_dir
| This setting specifies where to store archives of old configurations. |
retain_min
| This setting specifies the minimum number of archives to store. |
retain_days
| This setting specifies the minimum number of days to keep archive files. |
During routine storage management, administrators might make a change to a volume group that they immediately regret, for example, shrinking a logical volume before shrinking the file system on that logical volume. In this situation, the administrator can try to extend the logical volume to the previous size; however, with possible corruption of the file system on the resized logical volume, the same blocks on the disk are not guaranteed to be available for use.
The LVM archive feature can be configured to store copies of volume group metadata. If the archive option is set to 1 in the /etc/lvm/lvm.conf file, then the LVM tools create an archived copy of the current volume group metadata before making any changes on disk. In a default configuration, these archives are in the /etc/lvm/archive/ directory. For a list of all archived metadata for a volume group, examine the files in the /etc/lvm/archive/ directory.
Alternatively, you can display the same information with the vgcfgrestore -l command. In this example, the <vgname>File: line provides the name and location of the metadata file for the described action. Carefully interpret the Description: lines to determine the order in which the archive is created.
[root@host ~]#vgcfgrestore -l vg_exampleFile: /etc/lvm/archive/vg_example_00000-943759797.vgVG name: vg_example Description: Created before executing 'vgcreate vg_example /dev/sda5' Backup Time: Mon Oct 4 07:01:47 2021 File: /etc/lvm/archive/vg_example_00001-1528176681.vg
VG name: vg_example Description: Created before executing 'lvcreate -L 1G -n lv_example vg_example' Backup Time: Mon Oct 4 07:02:00 2021 File: /etc/lvm/archive/vg_example_00002-1484695080.vg
VG name: vg_example Description: Created before executing 'lvresize -L -256M /dev/vg_example/lv_example' Backup Time: Mon Oct 4 07:02:34 2021 File: /etc/lvm/backup/vg_example
VG name: vg_example Description: Created after executing 'lvresize -L -256M /dev/vg_example/lv_example' Backup Time: Mon Oct 4 07:02:34 2021
The archive and backup files contain metadata for the following actions:
The | |
An | |
An archive of the current volume group is created before reducing the logical volume by | |
A backup of the current volume group is created after reducing the logical volume by |
To undo an LVM change:
Unmount any file systems that were created on the logical volume to ensure that the logical volume is not in current use.
To restore the volume group, use the
vgcfgrestorecommand with the-foption.<archive_file>
The following example uses the metadata file that was created before reducing the logical volume size.
[root@host ~]# vgcfgrestore -f /etc/lvm/archive/vg_example_00002-1484695080.vg vg_example
Restored volume group vg_exampleIn some scenarios, it might be necessary to deactivate and then reactivate the logical volume to ensure that all changes are also updated in memory.
[root@host ~]#lvchange -an /dev/vg_example/lv_example[root@host ~]#lvchange -ay /dev/vg_example/lv_example
References
lvm.conf(5), vgbackup(8), and vgcfgrestore(8) manual pages
For more information, refer to the Red Hat Enterprise Linux 8 Configuring and Managing Logical Volumes Guide at https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/configuring_and_managing_logical_volumes/index