# Unable to mount postgrsql data directory with persistance volume

**URL:** <https://discuss.kubernetes.io/t/unable-to-mount-postgrsql-data-directory-with-persistance-volume/8463>\
**Category:** General Discussions\
**Created:** [October 25, 2019, 5:48am UTC](https://discuss.kubernetes.io/t/unable-to-mount-postgrsql-data-directory-with-persistance-volume/8463 "2019-10-25T05:48:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![UDIT\_JOSHI](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/udit_joshi/32/3968_2.png) [@UDIT\_JOSHI](https://discuss.kubernetes.io/u/UDIT_JOSHI)\
**Post date:** [October 25, 2019, 5:48am UTC](https://discuss.kubernetes.io/t/unable-to-mount-postgrsql-data-directory-with-persistance-volume/8463/1 "2019-10-25T05:48:51Z")

</div>

I am using Kubernetes static PV to mount my Postgresql data. But I am unable to do this

Here is my YAML file where I create PV , PVC and my Postgres pod  
my data directory of Postgres located at “/var/lib/pgsql/9.3/data”

But initially, my data directory /var/lib/pgsql/9.3/data is nonempty. I already append some sample data here. I want that Kubernetes will create the volume in the same location and mount it to /mnt/data

I also provide permissions and ownership but my problem still not fixed. The same thing works fine if I use docker volume

```
apiVersion: v1
kind: PersistentVolume
metadata:
  name: task-pv-volume
  namespace: manhattan
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 100Mi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/mnt/data"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: task-pv-claim
  namespace: manhattan
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 80Mi
---
apiVersion: v1
kind: Pod
metadata:
  name: dbr-postgres
  namespace: manhattan
spec:
  volumes:
    - name: task-pv-storage
      persistentVolumeClaim:
        claimName: task-pv-claim
  containers:
    - name: task-pv-container
      image: postgresql:2.0.1
      tty: true
      volumeMounts:
        - mountPath: "/var/lib/pgsql/9.3/data"
           name: task-pv-storage
           subPath: data
           readOnly: false
  nodeSelector:
     kubernetes.io/hostname: k8s-master

```

Can anyone tell me what I am doing wrong?

### Cluster information:

Kubernetes version: v1.16.2  
Cloud being used: locally  
Installation method: kubeadem  
Host OS: Linux (Centos 7)  
CNI and version:  
CRI and version:

You can format your yaml by highlighting it and pressing Ctrl-Shift-C, it will make your output easier to read.
