Member-only story
Ubuntu
Get rid of full disk in Ubuntu
Recently when working with docker-compose, I met an issue:
No space left on device
The first solution comes up to my mind is add disk space from different partition to the partition that holds docker. But this is difficult. Turns out we have easier problem that we can mount the directory that holds docker data to different directory.
Check the /var/lib/docker, we will see that it belongs to /dev/sdb3
user:/var/lib/docker$ df .
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sdb3 58795996 53734356 2045244 97% /
And /dev/sdb3 is about to full.
Check the home directory
user:/home$ df .
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sdb4 892956360 429285640 418241268 51% /home
/dev/sdb4 still has a lot of space. So we will mount /var to this home directory.
This is how we could do that
mkdir -p /home/var
rsync -va /var /home/var
mv /var /var.old
# you can remove/var.old
when you are done to reclaim the spacemkdir -p /var
mount -o bind /home/var /var
- update your
/etc/fstab
to make the bind-mount permanent.