@stgraber I tried a temporary solution using incus file pull and incus file push, hoping to minimize the impact, but it turned out to be much more complicated than expected.
incus create mysql mysql
incus file pull --recursive mysql/var/lib/mysql ./
incus storage volume create default mysql
incus storage volume attach default mysql mysql /var/lib/mysql
incus file push --recursive ./mysql mysql/var/lib
incus start mysql
This was an attempt to preserve /var/lib/mysql data by moving it out, attaching a volume, and restoring it back. However, I ran into a couple of problems:
1. incus file push silently fails on stopped containers
There’s no error, files “appear” to upload (even with incus file edit), but they disappear after container start.
root@mysql:~# ls /var/lib/mysql/
root@mysql:~# ls -ld /var/lib/mysql
drwx--x--x 2 root root 2 May 8 02:05 /var/lib/mysql
=> Empty. Seems incus file push only works properly on running containers, but this isn’t documented or warned about.
2. Permission denied when accessing mounted volumes
Even after setting:
incus storage volume set default data initial.uid 1000
incus storage volume set default data initial.gid 1000
incus storage volume set default data security.shifted=true
Trying to access the mount from inside the container fails:
touch: cannot touch 'grass': Permission denied
Only works if I chown the mount from inside the container after it’s started.
Environment:
Can someone clarify the expected behavior or suggest a better approach?
It seems there are two issues I’m facing:
- Copying data into a stopped container:
When using incus file push on a stopped container, files appear to upload but disappear after the container starts. It seems file push only works properly when containers are running.
- Permission issues with mounted volumes:
Even after setting initial.uid and initial.gid, I still get “Permission denied” errors when accessing the mounted volume from inside the container. This works only if I change the ownership (chown) from inside the container after it’s started.
Any suggestions or clarifications would be greatly appreciated.