Increase /tmp partition size on linux

→ Are you a new visitor? Please visit the page guidance for new visitors ←

Increase /tmp partition size on linux

The real purpose of this article is to show you how to increase the /tmp partition on linux, be it Ubuntu, Debian or CentOS, any linux distributions should work with this tutorial. The real reason why I wanted to make this tutorial is due to a friend of mine having issues with upload and plugin upgrades on wordpress. He was getting a strange error like below:

The main reason why this would fail to upgrade or upload content would be due:

  • No more disk space on system (this includes /tmp)
  • Problem with the php zip extension

You can check your partition sizes using the command df -h, see below example:

In cases where you do not have enough space in one of your partitions you need to:

  • clear some space in most cases
  • specify a new tmp folder for your php
  • increase the /tmp partition size

Steps to increase the /tmp partition size

  • Use the dd command to create ourselves a partition of 2GB for instance:

Of course you can change the path from “of” to a location where you have enough disk space and count and bs to a different value.

  • Once we have the partition created, it needs to have a file system, we use mke2fs to make the file system on the partition

  •  At this point the partition is ready to be used and we can mount it directly:

I’m using “loop” while mounting /usr/tmp-dir partition due to this not being an actual device, but a file acting like a device.

  • You can check the mount points following the command

 The last final steps are to make these settings permanent by adding the new file device to our /etc/fstab file. You only need to add the line there:

Setting the proper permissions on the /tmp folder

I forgot one little thing here, for uploads to work on the /tmp folder, you need to also set the proper permissions and ownership on your /tmp folder. Use the bellow commands for this:

So this tutorial idea came from a wordpress issue, its not bad considering I searched quiet a bit for a solution on that error.

Hope it helped someone out there, if you have questions, comment below and I’ll try to help out.

  • Henry Hoang

    Thanks a lot, it’s so helpful

Request an article ←