Sometimes the default mounted size in /tmp is too small and it might cause many unexpected crashes in Linux applications (such as mysql queries performing schema change, etc.) as well as your website application. In this case, although we can find and delete old files in /tmp directory, but it might also be full quickly after that since the size is too small. This tutorial will help to Increase size of /tmp folder/partition for program utilization.
- To create a partition of 4GB, use the below dd command:
[bash]dd if=/dev/zero of=/home/tmp-dir bs=1024M count=4[/bash]
- Once the partition is created, you need to create the file system on it using the mke2fs command
[bash]mke2fs -j /home/tmp-dir[/bash]
- Now, the partition is ready to be used but you need to mount it on /tmp directory.
[bash]mount -t ext3 -o loop /home/tmp-dir /tmp[/bash]
Here, we have used ‘loop’ while mounting /home/tmp-dir partition because we are not mounting an actual block device but to make a file accessible as a block device.
- To verify the partition, execute
- To make sure this partition is mounted automatically after every reboot, edit the /etc/fstab file and replace the /tmp line with the following one:
#/dev/mapper/vg-tmp /tmp ext4 discard,noatime 1 2
/home/tmp-dir /tmp ext3 defaults,loop 0 0
That’s all. Check to be sure your tmp size is increased, and if it solves your application problems.
Note: If there is a large tmp file opening, remember that we will need to remove it from memory to free up the space. Just need to check which process is using it
and kill the according one.