/tmp partition full… How to increase /tmp partition in Linux?
You can create a Virtual partition on Linux in case your server isn’t built with a /tmp partition OR you need to increase the size of the partition for some reason, and then you can mount the virtual partition as /tmp.
The following steps will guide you to create a virtual partition:
1) To create a virtual partition of 2GB, use the below dd command:
# dd if=/dev/zero of=/home/tmp-dir bs=1024M count=2
2) Once the partition is created, you need to create the file system on it using the mke2fs command
# mke2fs -j /home/tmp-dir
3) Now, the partition is ready to be used but you need to mount it on /tmp directory.
# mount -t ext3 -o loop /home/tmp-dir /tmp
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.
4) To verify the partition, execute
# mount
5) 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:
/home/tmp-dir /tmp ext3 defaults,loop 0 0
Hope, this helps.
January 26th, 2011 at 4:42 pm
Thanks for the tutorial, just a note shouldn’t you be mounting as noexec ? Other than that, great tut.
February 1st, 2011 at 8:26 am
Andy, yes, it is good for security reason to mount /tmp with noexec,nosuid option, however since this tutorial was only about increasing the size of the /tmp partition, I did not mentioned that 🙂
April 15th, 2011 at 7:58 am
bs=1024M could get you in trouble. I had my swap partition filled and dd got really slow from all the swapping. I’ve got 1.25 GB of RAM.
bs=1024k and a count k multiplier, like count=2k, works better if you don’t have several GB of RAM.
April 17th, 2011 at 11:08 am
Seron, true, it might use up resources with very less RAM on the server BUT generally people nowadays do use high configuration servers, like a few GBs of RAM and a few hundred GBs of Harddisk, so 2GB of a tmp file shouldn’t be an issue.
Thanks for the update though, it will help people with less RAM on their servers
June 27th, 2011 at 2:03 am
Hi. i do \”dd if=/dev/zero of=/tmp-dir bs=1024M count=2K\”
and its very slow now..
1Tb Harddrive & 16GB RAM
have solution?
June 29th, 2011 at 9:54 am
It seems you are trying to create a 2GB file in which case you have to use “count=2” and not “count=2K” which is the reason why it’s taking too long. Execute the following to create a 2GB of tmp-dir file
dd if=/dev/zero of=/tmp-dir bs=1024M count=2