How to Safely Increase /tmp Size on cPanel/WHM Servers
The /tmp directory is a temporary storage area used by Linux and many applications—including cPanel/WHM, MySQL, PHP, and backup tools. If /tmp runs out of space, you may experience failed uploads, backup errors, or even service interruptions. Increasing the /tmp partition size is a common and safe way to prevent these issues.
Warning: Modifying
/etc/fstaband remounting/tmpaffects your server's filesystem. Always back up your data and, if possible, test changes on a staging server before applying to production.
Why Increase /tmp Size?
- Prevents errors with uploads, backups, and temporary files
- Avoids service interruptions for MySQL, PHP, and other applications
- Improves overall server stability and performance
Step-by-Step Guide to Increase /tmp Size
1. Check Current /tmp Usage
Before making changes, check how much space /tmp is using and whether it's full:
df -h /tmp
2. Edit /etc/fstab
Open the file in your preferred editor:
sudo nano /etc/fstab
Find the line for /tmp, for example:
tmpfs /tmp tmpfs defaults,noauto 0 0
Add or update the size option (e.g., size=4G):
tmpfs /tmp tmpfs defaults,size=4G 0 0
Tip: Adjust
4Gto your needs and available RAM./tmpis often mounted astmpfs(RAM-backed), so don't set it larger than your server can handle.
3. Reload Systemd Daemon
Apply changes to systemd:
sudo systemctl daemon-reload
4. Remount /tmp
Remount the /tmp partition to apply the new size:
sudo mount -o remount /tmp
5. Verify the Change
Check the new size:
df -h /tmp
6. Troubleshooting
- If the new size is not applied, try rebooting the server:bash
sudo reboot - Double-check for typos in
/etc/fstab—a mistake can prevent your system from booting. - If
/tmpis not mounted astmpfs, consult your hosting provider or sysadmin for the best resizing method.
Best Practices
- Backup First: Always back up important data before editing
/etc/fstab. - Monitor Usage: Regularly monitor
/tmpusage to prevent future issues. - Avoid Oversizing: Don't set
/tmpto an excessively large size that could impact RAM or system performance. - Security: Never set
/tmppermissions to777or allow world-writable access.
Conclusion
Increasing the /tmp size on cPanel/WHM is a straightforward process that can prevent common server errors and improve reliability. By following these steps and best practices, you can keep your Linux filesystem healthy and your hosting environment running smoothly.
