Increase /tmp partition size on linux
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:
1 2 |
Incompatible archive: PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature Installation Failed |
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:
1 2 3 4 5 6 7 8 9 |
root@foo1 [~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_web1-LogVol01 1.8T 214G 1.5T 13% / tmpfs 24G 20K 24G 1% /dev/shm /dev/sdb1 485M 154M 306M 34% /boot /dev/sdc1 110G 3.3G 101G 4% /var/lib/mysql /dev/sda 235G 59G 164G 27% /home /usr/tmpDSK 4.0G 240M 3.6G 7% /tmp |
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:
1 |
dd if=/dev/zero of=/usr/tmp-dir bs=1024M count=2 |
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
1 |
mke2fs -j /usr/tmp-dir |
- At this point the partition is ready to be used and we can mount it directly:
1 |
mount -t ext3 -o loop /usr/tmp-dir /tmp |
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
1 |
mount |
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:
1 |
/usr/tmp-dir /tmp ext3 defaults,loop 0 0 |
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:
1 2 |
chmod 1777 /tmp chown root.root /tmp |
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.