# Docker uses root partition, might need more storage space

**URL:** https://meta.discourse.org/t/docker-uses-root-partition-might-need-more-storage-space/69298
**Category:** Self-hosting
**Tags:** server-resources
**Created:** [September 3, 2017, 8:23pm UTC](https://meta.discourse.org/t/docker-uses-root-partition-might-need-more-storage-space/69298 "2017-09-03T20:23:49Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![Ironclad14](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ironclad14/32/120185_2.png) [@Ironclad14](https://meta.discourse.org/u/Ironclad14)
#### Post date: [September 3, 2017, 8:23pm UTC](https://meta.discourse.org/t/docker-uses-root-partition-might-need-more-storage-space/69298/1 "2017-09-03T20:23:49Z")

</div>

Hi guys,

First post here, sadly it’s regarding support. Docker seems to use my /root partition which is only 20 GB and the rest of my 2TB drive is on /home.

```
root@legio:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 20G 8.3G 9.9G 46% /
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.8G 4.0K 7.8G 1% /dev/shm
tmpfs 7.8G 394M 7.4G 5% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/md2 487M 25M 433M 6% /boot
/dev/md4 1.8T 51G 1.7T 3% /home
overlay 20G 8.3G 9.9G 46% /var/lib/docker/overlay2/aa30e247cdd1f95098ce909f333aae8a968b431c07856f242614528d6e2490c3/merged
shm 64M 4.0K 64M 1% /var/lib/docker/containers/201cd5c089c15b57b38fc94b3331212494d0a9514ea6ca51ec88bbcacce0cf0a/shm
overlay 20G 8.3G 9.9G 46% /var/lib/docker/overlay2/d249b6017bcfdae9742caed4402fe02936b1ddb55eb5178504d161061d49f178/merged
shm 64M 0 64M 0% /var/lib/docker/containers/0b11fcac390be8525e451bf00270916063c7da519c368e170c49f5f741c1b425/shm

```

Can you let me know of any way I can make use of more space without having to resize partitions? It’s risky business while they’re mounted and data loss isn’t something anyone likes to deal with. 🙂

Running Debian 9.1 stable on a dedicated machine.

Any help will be appreciated.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [September 3, 2017, 8:44pm UTC](https://meta.discourse.org/t/docker-uses-root-partition-might-need-more-storage-space/69298/2 "2017-09-03T20:44:21Z")

</div>

Do we have a #howto for this @techapj? That is, configuring Discourse to use another drive for the high storage requirement items like the database, file/image uploads, backups, etc?

---

<div class="post-metadata">

### Author: ![Ironclad14](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ironclad14/32/120185_2.png) [@Ironclad14](https://meta.discourse.org/u/Ironclad14)
#### Post date: [September 3, 2017, 10:36pm UTC](https://meta.discourse.org/t/docker-uses-root-partition-might-need-more-storage-space/69298/3 "2017-09-03T22:36:32Z")

</div>

That would be the easiest solution, yeah. 🙂

---

<div class="post-metadata">

### Author: ![dax](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dax/32/244677_2.png) [@dax](https://meta.discourse.org/u/dax)
#### Post date: [September 3, 2017, 11:48pm UTC](https://meta.discourse.org/t/docker-uses-root-partition-might-need-more-storage-space/69298/4 "2017-09-03T23:48:31Z")

</div>

This topic, though related to digital ocean block storage, can help you at least for uploads:

> [@Need a how-to guide for using DigitalOcean Block Storage for image uploads](https://meta.discourse.org/t/need-a-how-to-guide-for-using-digialocean-block-storage-for-image-uploads/49535/10):
>
> The man makes a point. It appears to be less than 1/3 the speed on the simplest of benchmarks. (I checked and both the host and the storage are at SFO2.) root#:dd if=/dev/zero of=/tmp/output conv=fdatasync bs=384k count=1k 1024+0 records in 1024+0 records out 402653184 bytes (403 MB, 384 MiB) copied, 0.590498 s, 682 MB/s root#:dd if=/dev/zero of=/mnt/volume-sfo2-01/test conv=fdatasync bs=384k count=1k 1024+0 records in 1024+0 records out 402653184 bytes (403 MB, 384 MiB) copied, 1.99937 s, 201…

You should read all the topic, there are pros and cons.

---

<div class="post-metadata">

### Author: ![Ironclad14](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ironclad14/32/120185_2.png) [@Ironclad14](https://meta.discourse.org/u/Ironclad14)
#### Post date: [September 4, 2017, 12:01am UTC](https://meta.discourse.org/t/docker-uses-root-partition-might-need-more-storage-space/69298/5 "2017-09-04T00:01:45Z")

</div>

Creating symlinks doesn’t seem like a very good way in my opinion, it’s too workaround-y. Lets see what @codinghorror and @techAPJ will come up with.

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [September 4, 2017, 10:28am UTC](https://meta.discourse.org/t/docker-uses-root-partition-might-need-more-storage-space/69298/6 "2017-09-04T10:28:48Z")

</div>

There is no #howto for this as of now, added on my list to look into it and write one. 📝

---

<div class="post-metadata">

### Author: ![Ironclad14](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ironclad14/32/120185_2.png) [@Ironclad14](https://meta.discourse.org/u/Ironclad14)
#### Post date: [September 4, 2017, 10:30am UTC](https://meta.discourse.org/t/docker-uses-root-partition-might-need-more-storage-space/69298/7 "2017-09-04T10:30:14Z")

</div>

Thanks! The 20 gigs I have should be sufficient for now but it’ll be useful.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [October 13, 2017, 5:07am UTC](https://meta.discourse.org/t/docker-uses-root-partition-might-need-more-storage-space/69298/8 "2017-10-13T05:07:09Z")

</div>

I did this for free codecamp:

```plaintext
volumes:
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /var/discourse/shared/standalone/log/var-log
      guest: /var/log
  - volume:
      host: /var/postgres_data
      guest: /shared/postgres_data

```

Basically I keep `/var/postgres_data` in root and then mount `/var/discourse/shared/` on the second volume, additionally I put docker containers in `/var/discourse/shared/docker`

There are many ways of skinning this, just keep postgres\_data on the fastest drive and you should be good.

---

<div class="post-metadata">

### Author: ![thabbs](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thabbs/32/82150_2.png) [@thabbs](https://meta.discourse.org/u/thabbs)
#### Post date: [October 13, 2017, 5:04pm UTC](https://meta.discourse.org/t/docker-uses-root-partition-might-need-more-storage-space/69298/9 "2017-10-13T17:04:14Z")

</div>

Another solution on OS level can be to mount /var/lib/docker on a dedicated partition.

To do this, please, stop Docker, make sure that no process accesses /var/lib/docker and do the following:

Provide an additional volume. In this example it is /dev/sdx8.  
Format it accordingly, i.e.

```
mkfs.xfs -n ftype=1 /dev/sdx8

```

or

```
mkfs.ext4 /dev/sdx8

```

etc.

If it fails in mkfs.xfs you might run a newer version of mkfs.xfs which has ftype=1 already as default. Just issue

```
mkfs.xfs /dev/sdx8

```

Stop Docker.

```
service docker stop

```

Make sure the directory is not used anymore:

```
lsof | grep /var/lib/docker

```

Prepare directories and mount the new volume:

```
mv /var/lib/docker /var/lib/__docker
mkdir /var/lib/docker
mount /dev/sdx8 /var/lib/docker

```

Move all contents there to:

```
rsync -aH /var/lib/__docker/ /var/lib/docker
# mind the trailing slash. It takes care to copy the whole tree to the right position.

```

Don’t forget to add /dev/sdx8 to /etc/fstab.

Remove the old directory if everything is fine.

```
rm -rf /var/lib/__docker

```

---

<div class="post-metadata">

### Author: ![dylanh724](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanh724/32/119642_2.png) [@dylanh724](https://meta.discourse.org/u/dylanh724)
#### Post date: [November 23, 2017, 11:22am UTC](https://meta.discourse.org/t/docker-uses-root-partition-might-need-more-storage-space/69298/10 "2017-11-23T11:22:05Z")

</div>

If following the above guide, as a semi-newb, let me know if I got this right:

1. Assume mounted volume is at `/mnt/someVolume/`
2. Make an empty dir at mnt vol?

```plaintext
mkdir /mnt/someVolume/discourse/shared/

```

1. When you say ‘mount’, do you mean **symlink**?

```plaintext
ln -s /mnt/someVolume/discourse/shared /var/discourse/shared

```

1. Edit `/var/discourse/containers/app.yaml` …

```plaintext
volumes:
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /var/discourse/shared/standalone/log/var-log
      guest: /var/log
  - volume: #KEEP THE SAME, right?
      host: /var/postgres_data
      guest: /shared/postgres_data

```

1. **move** docker containers?

```plaintext
mv /var/discourse/containers /mnt/someVolume/discourse/shared/containers

```

Then maybe stop/start again? Do I need to rebuild? Anything missing or need correcting?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 23, 2017, 7:28pm UTC](https://meta.discourse.org/t/docker-uses-root-partition-might-need-more-storage-space/69298/11 "2017-11-23T19:28:43Z")

</div>

This stuff is messy, I recommend you create a test droplet and try it out there, it’s the easiest way to answer all questions with zero risk

---

<div class="post-metadata">

### Author: ![dylanh724](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanh724/32/119642_2.png) [@dylanh724](https://meta.discourse.org/u/dylanh724)
#### Post date: [November 25, 2017, 4:13am UTC](https://meta.discourse.org/t/docker-uses-root-partition-might-need-more-storage-space/69298/12 "2017-11-25T04:13:23Z")

</div>

Does this mean my summary interpretation is also on the right track?

I’m not sure if a test droplet is the best way to go, in my case. The IPs will be different, I’d have to setup a new host, and even if I did all that, nginx would be completely off… I’m pretty sure this would be even-more confusing. I’d probably be better off just making a backup before I change anything.

---

<div class="post-metadata">

### Author: ![Ironclad14](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ironclad14/32/120185_2.png) [@Ironclad14](https://meta.discourse.org/u/Ironclad14)
#### Post date: [March 24, 2018, 10:16pm UTC](https://meta.discourse.org/t/docker-uses-root-partition-might-need-more-storage-space/69298/13 "2018-03-24T22:16:24Z")

</div>

About to try this on a fresh install. I’ll report back.

---

<div class="post-metadata">

### Author: ![Ironclad14](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ironclad14/32/120185_2.png) [@Ironclad14](https://meta.discourse.org/u/Ironclad14)
#### Post date: [March 24, 2018, 10:49pm UTC](https://meta.discourse.org/t/docker-uses-root-partition-might-need-more-storage-space/69298/14 "2018-03-24T22:49:52Z")

</div>

Okay, this is my /etc/fstab

```
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/md3 / ext4 errors=remount-ro,relatime 0 1
/dev/md2 /boot ext4 errors=remount-ro,relatime 0 1
/dev/md4 /home ext4 defaults,relatime 1 2
/dev/sda5 swap swap defaults 0 0
/dev/sdb5 swap swap defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts defaults 0 0

```

When I do `mkfs.ext4 /dev/sdx8` do I have to do it to /dev/md4? It’s my biggest partition.

Thanks.

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [June 6, 2018, 5:39pm UTC](https://meta.discourse.org/t/docker-uses-root-partition-might-need-more-storage-space/69298/15 "2018-06-06T17:39:04Z")

</div>

Based on @sam’s suggestion I spun up a new droplet → installed Discourse → added a block storage volume → moved uploads and backups to that volume. Everything worked out fine. Here is the howto:

> [@Move Uploads and Backups to DigitalOcean Block Storage](https://meta.discourse.org/t/moving-uploads-and-backups-to-digitalocean-block-storage/89274):
>
> So you want to move all uploads and backups to [DigitalOcean Block Storage](https://www.digitalocean.com/community/tutorials/an-introduction-to-digitalocean-block-storage)? Before you do this, though, you might instead consider [Configure an S3 compatible object storage provider for uploads](https://meta.discourse.org/t/using-object-storage-for-uploads-s3-clones/148916). It is no more complicated to set up and provides some other advantages. Setup a Discourse instance on DigitalOcean Setup a Discourse instance on DigitalOcean using our [official guide](https://github.com/discourse/discourse/blob/main/docs/INSTALL-cloud.md). Add a Volume to your droplet [Add](https://www.digitalocean.com/community/tutorials/an-introduction-to-digitalocean-block-storage) a block storage volume to your droplet. Note down the name of the volume. In my case…

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [June 12, 2019, 5:32pm UTC](https://meta.discourse.org/t/docker-uses-root-partition-might-need-more-storage-space/69298/16 "2019-06-12T17:32:12Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
