Change hostPath volume to nfs volume type

Cluster information:

Kubernetes version:1.22.2
Installation method: bare-metal
Host OS: Ubuntu 20.04
CNI and version: Flannel 0.15.0
CRI and version: Docker 20.10.9

Currently, my cluster uses hostPath as the volume type. I want to change all volume types from hostPath to nfs and create pvc for every volume. How can I do this without losing data?