Increasing the Size of tmpDSK (/tmp)
- Written by Vanessa Vasile
- Published in Howto
- 31 Comments
- Permalink
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.
- Stop MySQL, Apache, and cPanel to prevent writing to the /tmp partition
- Copy the contents of /tmp to another location, such as /home (cp -rfp /tmp /home)
- 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) .
- 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
Pingback: /tmp 100% full - cPanel Forums
Pingback: Servers Admins » Blog Archive » Managing Multiple Hard Drives with cPanel
What would you recommend making the size of the /tmp ? thanks Mally
Usually between 1-2GB
Pingback: 02.11.2010 | Güven Atbakan | Kişisel Blog
Hello there thx you very much
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.
phpMyAdmin and other cPanel software now use /var/cpanel/userhomes for tmp data storage – so the permissions of /tmp as 777 or 1777 will both work.
Thanks for your information very helpful
Thank you. very helpful!
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?
thanx this helps me…
Worked perfectly on a CentOS VPS (Linode) – Didn’t even need to reboot!
Also, the reason I needed to do this is because it keeps getting full. Is there any thing I can do to make sure it stays clean?
It depends – do you know what’s filling it up?
Thanks for your guide.
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
You need to many sure that /tmp is mounted using /usr/tmpDSK. Yours isn’t.
Pingback: Increasing the Size of tmpDSK (/tmp) | 英瑞.
Hi,
How I can change the size of /var?
Pingback: Increasing the Size of tmpDSK (/tmp) | Vps, Linux, diendanvps, dichvuvps
Pingback: Increasing the Size of tmpDSK (/tmp)
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.
thanks for sharing
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
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.
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?
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.
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?
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.
Thanks for your guide.