chown: changing ownership of '' ": Input/output error

10/9/2019

I have tried the database application for mysql and postgres too. When I use pv type as OSS, and deploy the application, pods goes in CrashbackLoopOff. The error which I am constantly getting is

chown: changing ownership of '/var/lib/mysql/': Input/output error

(For PostgreSQL I get the same error with var/lib/postgresql/data.)

The path which it is giving error is of container.The ways which I tried is, before uploading files to OSS I changed the ownership of files and folders from 999 to root and then uploaded to OSS. But then also I am getting this error for every database. Please give me solution for this as I am stuck from longer time. Thanks in Advance

-- Apurva D
alibaba-cloud
kubernetes
mysql
postgresql

1 Answer

10/9/2019

If I understand you correctly there are few things you can do:

  1. Launch the db container as root and than chown the directory. In case of mysql if you still can't change it than try running sudo chown -R mysql:mysql /var/lib/mysql as mysql:mysql is the default ownership there.

  2. Use initContainer in order to change the target folder to /var/lib/mysql/

  3. Use securityContext for containers. For example:

containers:
- name: mysql
  image: <msql_image>
  securityContext:
    runAsUser: 0

It should all also work for postgresql.

Please let me know if that helped.

-- OhHiMark
Source: StackOverflow