/tmp partition full. Howto increase /tmp partition size in Linux?

/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.

This entry was posted on Sunday, September 13th, 2009 and is filed under Linux Administration. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

6 Responses to “/tmp partition full. Howto increase /tmp partition size in Linux?”

  1. Andy

    Thanks for the tutorial, just a note shouldn’t you be mounting as noexec ? Other than that, great tut.

  2. admin

    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 🙂

  3. seron

    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.

  4. admin

    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

  5. Ferri

    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?

  6. admin

    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