There two main options to change the location of all the containers’ storages:
- “mount bind” the new location to the default storage directory (look Note 1)
- Change the path of the location in the configuration file /etc/containers/storage.conf
You should stop all your containers though it is not mandatory.
You should stop the containers (if any) and copy the directory, because when reconfigured the storage path podman won’t access the ones in the old path – containers and images!
STEP 1) Change the storage path in the podman configuration file.
If the SELinux has been disabled, which should not be done, it is just a matter of changing a path option in the configuration file /etc/containers/storage.conf
# Primary Read/Write location of container storage graphroot = "/var/lib/containers/storage"
Change it to whatever path you like. Mostly, it should point to the big storage device. In our case, the big storage is mounted under “/mnt/mystorage/virtual/storage”. Change the options to:
# Primary Read/Write location of container storage graphroot = "/mnt/mystorage/virtual/storage"
Check the running configuration with:
[root@lsrv1 mystorage]# podman info host: BuildahVersion: 1.12.0-dev CgroupVersion: v1 Conmon: package: conmon-2.0.8-1.el7.x86_64 path: /usr/bin/conmon version: 'conmon version 2.0.8, commit: f85c8b1ce77b73bcd48b2d802396321217008762' Distribution: distribution: '"centos"' version: "7" MemFree: 191963136 MemTotal: 16563531776 OCIRuntime: name: runc package: runc-1.0.0-67.rc10.el7_8.x86_64 path: /usr/bin/runc version: 'runc version spec: 1.0.1-dev' SwapFree: 7857680384 SwapTotal: 8581541888 arch: amd64 cpus: 8 eventlogger: journald hostname: lsrv1 kernel: 3.10.0-1062.9.1.el7.x86_64 os: linux rootless: false uptime: 607h 10m 53.36s (Approximately 25.29 days) registries: blocked: null insecure: null search: - registry.access.redhat.com - registry.fedoraproject.org - registry.centos.org - docker.io store: ConfigFile: /etc/containers/storage.conf ContainerStore: number: 0 GraphDriverName: overlay GraphOptions: {} GraphRoot: /mnt/mystorage/virtual/storage GraphStatus: Backing Filesystem: extfs Native Overlay Diff: "true" Supports d_type: "true" Using metacopy: "false" ImageStore: number: 0 RunRoot: /var/run/containers/storage VolumePath: /mnt/mystorage/virtual/storage/volumes