Why I Need to Do This
I have a server with both SSD and HDD, concretely:
- SSD: 50GB, for system use
- HDD: 2048GB, for data storage
I use this VPS to run my blog and some docker containers. Here comes the problem: 50GB SSD is not enough.
I mount the HDD at /sto to store some large files like videos and cloud backups. However, Docker images, containers and runtime data are still using the space of my SSD.
| Location | Note |
|---|---|
| Docker Data Directory | /var/lib/docker |
| Containerd | /var/lib/containerd |
These to eat up a lot of space of the SSD, so I need to move them to a new place.
Command To Use
Before going into the sections below, we need to learn about the data archive command:
rsync -aHAXx --numeric-ids /path/to/olddir/ /path/to/newdir/
This helps us copy the file from old directory to new place while keeping metadata like ownership, ACL etc.
Move Directory
For docker, we use rsync to move the /var/lib/docker to the new desired place, and change the docker /etc/docker/daemon.json:
For containerd, still use rsync to move the data, then change /etc/containerd/config.toml:
root = "/var/lib/containerd"
state = "/run/containerd"
Note the root line may already be there commented out, we just need to uncomment it and change the path to point to our new directory.