Increasing the Size of tmpDSK (/tmp)

Increasing the Size of tmpDSK (/tmp)
5 (100%) 4 votes

You may have noticed that cPanel’s default partition size for /tmp is 512 MB, which in some cases can be way too small.  The /tmp partition on cPanel servers, assuming it was the one cPanel created and not one you did yourself, is a file-base

d partition that can easily be resized.

By default on most servers, /tmp is the temporary dumping place for a lot of things, for example:

  • PHP session files
  • PHP temporary file uploads
  • MySQL temporary files
  • Cache files for certain Apache modules

Most software that uses temporary files or sessions will automatically prefer to use /tmp – this folder is usually set to 777  permissions and therefore writeable by every user on the server.

When your /tmp partition fills up, it can cause noticeable problems for your users. If you run a larger server, the /tmp folder can fill up quickly and be very annoying as far as maintenance is concerned. Fortunately there is a very easy way to increase the size of this partition on a standalone server.

  1. Stop MySQL, Apache, and cPanel to prevent writing to the /tmp partition
  2. Copy the contents of /tmp to another location, such as /home (cp -rfp /tmp /home)
  3. Unmount /tmp. If you’re unable to, you can do an lsof (lsof |grep /tmp) to see what processes are still writing to it, and kill them off. Or do a lazy unmount (umount -l /tmp) .
  4. Delete /usr/tmpDSK (rm -rf /usr/tmpDSK)

Now open /scripts/securetmp and look for this line:

my $tmpdsksize     = 512000;    # Must be larger than 250000

And change the “512000” value to your desired size in MB, and save the file. Now run the following script to recreate /tmp:

/scripts/securetmp

This will recreate your /tmp (tmpDSK) partition using the size you specified. While the securetmp script may be overwritten in a cPanel update, the size of /tmp will not be affected one you alter its size.

31 Comments

  1. Pingback: /tmp 100% full - cPanel Forums

  2. Pingback: Servers Admins » Blog Archive » Managing Multiple Hard Drives with cPanel

  3. Pingback: 02.11.2010 | Güven Atbakan | Kişisel Blog

  4. jackb Reply

    Actually, the permissions of /tmp should be set to 1777, not 777. The sticky bit should be set to ensure that users are unable to modify other user’s data. Most phpmyadmin errors and common PHP script errors (such as /tmp/.sessXXXXXXXX) can be eliminated by properly setting /tmp to 1777.

  5. Chandrika Reply

    Hi thanks for this tutorial,

    Is there anything in the /tmp folder copied to /home/tmp that needs to be put back after following the rest of the process. Or is everything that was in the original expendable?

  6. Kevin Reply

    I followed the guide – any ideas why my /tmp size hasnt’ increased by the /usr/tmpDSK has?

    /tmp /var/tmp 3% (13,410 of 495,844)
    /usr/tmpDSK /tmp 2% (36,908 of 2,015,824)

    Thanks

    Kevin

  7. Pingback: Increasing the Size of tmpDSK (/tmp) | 英瑞.

  8. Pingback: Increasing the Size of tmpDSK (/tmp) | Vps, Linux, diendanvps, dichvuvps

  9. Pingback: Increasing the Size of tmpDSK (/tmp)

  10. terpal Reply

    I’d just like to add for completeness, that while /usr/tmpDSK with 8GB works well, /var/mysqltemp didnt work at all for me. Strange because the MySQL manual says it should work fine.

  11. David Reply

    Dear Vanessa
    I have a question
    Since my server is a VPS and using LVM so i’m wondering when i try to increase the size of the /tmp where the new size comes from?
    The extra size will be removed from anywhere else and how?
    Or we need to extend the HDD of the VPS and the allocate the new free space to the Volume Group related to /tmp?
    If this is the case so how to realize that /tmp belongs to which Volum group since when i initiate “df -hT” i can’t understand the volume group that /tmp comes from that

    Regards

    1. Vanessa Vasile Reply

      On cPanel servers, unless you have a dedicated /tmp partition on the disk, /tmp is just mounted from a file called /usr/tmpDSK. That file can really be located anywhere, so maybe see which disk /usr is on.

  12. C. Telinde Reply

    This was very helpful.

    I am assuming that it is not necessary to replace the data that was removed from /tmp. But I’m still curious; why was it necessary to copy the data out?

    1. Vanessa Vasile Reply

      Because when you resize, all the data is removed. It’s not always safe to assume that everything in that folder is expendable, unless you know this for a fact by examining their contents.

  13. Razvan Toader Reply

    I have a question.
    /tmp is mounted using /usr/tmpDSK and it’s always filling up even though it’s size is 4GB.
    Would it be ok to unmount and let it unmounted? I expect that when the /tmp is unmounted there won’t be anymore problems since the main disk is about 60GB. Am I right?

    1. Vanessa Vasile Reply

      You can technically leave /tmp unmounted and as a local folder to the root filesystem. The reason it’s usually mounted as a separate filesystem is so you can put noexec flags on its mount, for security reasons. You might want to see what’s taking up so much space though. We have clients with servers housing thousands of domains with a 4GB /tmp folder and we rarely see this issue.

Leave a Reply

Your email address will not be published. Required fields are marked *

Log in