Below is one common approach using a bind mount to move Docker’s data directory to your /usr/g filesystem:
- Stop Docker to avoid any corruption while moving data:
bash
sudo systemctl stop docker
- Create a new directory on /usr/g for Docker data (if not already available):
bash
sudo mkdir -p /usr/g/docker
- Move the current Docker data from /var/lib/docker to the new location:
bash
sudo mv /var/lib/docker/* /usr/g/docker/
- Back up the original /var/lib/docker directory (optional):
bash
sudo mv /var/lib/docker /var/lib/docker.bak
Then recreate an empty directory for the mount point:
bash
sudo mkdir /var/lib/docker
- Mount the new directory as a bind mount to /var/lib/docker:
bash
sudo mount --bind /usr/g/docker /var/lib/docker
- To make this change permanent across reboots, add a bind mount entry to your /etc/fstab. Open /etc/fstab with your favorite editor, for example:
bash
sudo nano /etc/fstab
Then add the following line:
/usr/g/docker /var/lib/docker none bind 0 0
- Start Docker:
bash
sudo systemctl start docker
- Verify that Docker is using the new storage location by checking Docker info:
bash
sudo docker info | grep "Docker Root Dir"
This setup moves Docker’s data directory to a partition that has more available space on /usr/g while keeping the original path (/var/lib/docker) for Docker to use.