// Module included in the following assemblies:
//
// storage/persistent_storage/persistent_storage_local/persistent-storage-using-lvms.adoc

:_mod-docs-content-type: PROCEDURE
[id="lvms-reusing-vg-from-prev-installation_{context}"]
= Reusing a volume group from the previous LVM Storage installation

[role="_abstract"]
You can reuse an existing volume group (VG) from a previous {lvms} installation to preserve your existing storage configuration and avoid recreating VGs when reinstalling or upgrading {lvms}.

You can only reuse a VG, but not the logical volume associated with the VG.

[IMPORTANT]
====
You can perform this procedure only while creating an `LVMCluster` custom resource (CR).
====

.Prerequisites
* The VG that you want to reuse must not be corrupted.
* The VG that you want to reuse must have the `lvms` tag. For more information on adding tags to LVM objects, see "Grouping LVM objects with tags".

.Procedure
. Open the `LVMCluster` CR YAML file.

. Configure the `LVMCluster` CR parameters as described in the following example:
+
.Example `LVMCluster` CR YAML file
[source,yaml]
----
apiVersion: lvm.topolvm.io/v1alpha1
kind: LVMCluster
metadata:
  name: my-lvmcluster
  namespace: openshift-storage
spec:
# ...
  storage:
    deviceClasses:
    - name: vg1
      fstype: ext4
      default: true
      deviceSelector:
# ...
        forceWipeDevicesAndDestroyAllData: false
      thinPoolConfig:
# ...
      nodeSelector:
# ...
----
+
* `spec.storage.deviceClasses.name`: Specifies the name of a VG from the previous {lvms} installation.
* `spec.storage.deviceClasses.fstype`: Set this field to `ext4` or `xfs`. By default, this field is set to `xfs`.
* `spec.storage.deviceClasses.name.deviceSelector`: You can add new devices to the VG that you want to reuse by specifying the new device paths in the `deviceSelector` field. If you do not want to add new devices to the VG, ensure that the `deviceSelector` configuration in the current {lvms} installation is same as that of the previous {lvms} installation.
* `spec...forceWipeDevicesAndDestroyAllData`: If this field is set to `true`, {lvms} wipes all the data on the devices that are added to the VG.
* `spec....thinPoolConfig`: To retain the `thinPoolConfig` configuration of the VG that you want to reuse, ensure that the `thinPoolConfig` configuration in the current {lvms} installation is same as that of the previous {lvms} installation. Otherwise, you can configure the `thinPoolConfig` field as required. 
* `spec...nodeSelector`: Configure the requirements to choose the nodes on which you want to create the LVM volume group. If this field is empty, all nodes without no-schedule taints are considered.

. Save the `LVMCluster` CR YAML file.

.Verification
To view the devices that are part a volume group, run the following command:
[source,terminal]
----
$ pvs -S vgname=<vg_name>
----
Replace `<vg_name>` with the name of the volume group.