Change podman storage folder

3k views Asked by At

I installed "Podman Desktop" (on windows 10), now i need to move the folder in which podman save containers to another disk because it reached 50GB (!), i notice that the default is in "C:\Users\my_user\.local\share\containers...", i want to move it to "D:\podman" (for.ex)

I searched a lot but didn't find any option to do this in Podman desktop settings(neither in configuration files)

I really wonder if this seemingly simple and common operation isn't handled in some Podman Desktop UI option (or configuration file)

Thank you

2

There are 2 answers

2
Yılmaz Durmaz On

podman on Windows normally uses WSL backend, the VM is stored as a single vhdx file, so the following should work to move it:

1- stop your podman VM: podman machine stop. check with wsl -l -v and see "Stopped" state.

2- the VM should be in a folder podman-machine-default under %USERPROFILE%\.local\share\containers\podman\machine\wsl\wsldist\.

  • move copy this folder (not just vhdx) to your other drive such as d:\DevTools\podman-dist\ (no move, just copy)

3- make sure you have backups, then apply wsl --unregister podman-machine-default

  • this will delete original vhdx, so be careful not to use wrong name

4- import from the vhdx you have just copied to other drive:

  • wsl --import-in-place podman-machine-default d:\DevTools\podman-dist\podman-machine-default\ext4.vhdx

5- restart it podman machine start

WARNING: The procedure is only moving the vhdx and can cause data loss if there are customizations I am not aware, so make sure you have enough disk space and maybe another backup of vhdx. Also check carefully if there are other things coupled before this.


in case you can reload all your containers from scratch, then before doing the above steps, you can remove the default machine with podman machine rm and create it fresh with podman machine init. this way you will have only 700MB to deal with. the init still uses default location.

1
gavenkoa On

Create a default WSL VM::

podman.exe machine init --cpus 2 --disk-size 40 --memory 2048

Review WSL VMs, known to Podman:

podman.exe machine list
wsl -l -v

Find the location by the name or default:

podman machine info podman-machine-default
podman machine info 

Stop WSL engine, export VM as TAR, import TAR to VM at a a location of choice:

cd d:/srv/wsl
mkdir podman-machine-default
podman machine stop
wsl --shutdown
wsl --export podman-machine-default podman.tar
wsl --unregister podman-machine-default
wsl --import podman-machine-default podman-machine-default/ podman.tar --version 2
del podman.tar

Start Podman engine:

podman machine start

Some big stuff still reside in %USERPROFILE%\.local\share\containers (cached archives of images), but the biggest VM storage will be outside.