// Module included in the following assemblies:
//
// storage/persistent_storage/persistent-storage-local.adoc

:_mod-docs-content-type: PROCEDURE
[id="local-removing-device_{context}"]
= Removing a local volume or local volume set

[role="_abstract"]
Remove local volumes (LVs) and local volume sets (LVSs) when no longer needed by releasing bound persistent volumes (PV), deleting the LV or LVS, and cleaning up any PVs with `Retain` reclaim policy.

.Prerequisites
* The PV must be in a `Released` or `Available` state.
+
[WARNING]
====
Deleting a PV that is still in use can result in data loss or corruption.
====

.Procedure
. If there are any bound PVs owned by the LV or LVS that is being deleted, delete the corresponding persistent volume claims (PVCs) to release the PVs:

.. To find bound PVs owned by a particular LV or LVS, run the following command:
+
[source, terminal]
----
$ oc get pv --selector storage.openshift.com/owner-name=<LV_LVS_name>
----
+
`<LV_LVS_name>` is the name of the LV or LVS.
+
.Example output
[source,terminal]
----
NAME                CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM                 STORAGECLASS   VOLUMEATTRIBUTESCLASS   REASON   AGE
local-pv-3fa1c73    5Gi        RWO            Delete           Available                         slow           <unset>                          28s
local-pv-1cec77cf   30Gi       RWX            Retain           Bound       openshift/storage     my-sc          <unset>                          168d
----
+
Bound PVs have a status of `Bound` and their corresponding PVCs appear in the `CLAIM` column. In the preceding example, PV `local-pv-1cec77cf` is bound, and its PVC is `openshift/storage`.

.. Delete corresponding PVCs of bound PVs owned by the LV or LVS being deleted by running the following command:
+
[source, terminal]
----
$ oc delete pvc <name>
----
+ 
In this example, you would delete PVC `openshift/storage`.

. Delete the LVs or LVSs by running the applicable following command:
+
* Command for deleting LV:
+
[source,terminal]
----
$ oc delete lv <name>
----
+
or
+
* Command for deleting LVS:
+
[source,terminal]
----
$ oc delete lvs <name>
----

. If any PV owned by the LV or LVS has a `Retain` reclaim policy, back up any important data, and then delete the PV:
+
[NOTE]
====
PVs with a `Delete` policy are automatically deleted when you delete the LVs or LVS.
====
+
.. To find PVs with `Retain` reclaim policy, run the following command:
+
[source,terminal]
----
$ oc get pv
----
+
.Example output
[source,terminal]
----
NAME                CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM                STORAGECLASS   REASON   AGE
local-pv-1cec77cf   30Gi       RWX            Retain           Available                        my-sc                   168d
----
+
In this example,  PV `local-pv-1cec77cf` has a `Retain` reclaim policy and needs to be manually deleted.

.. Back up any important data on this volume.

.. Delete the PV by running the following command:
+
[source,terminal]
----
$ oc delete pv <name>
----
+
In this example, delete PV `local-pv-1cec77cf`.