Topics: Red Hat / Linux, Storage
Using tmp.mount
If you've ever looked at the /tmp file system on a RHEL system, you may have noticed that it is, by default, simply a folder in the root directory.
For example:
The risk of having this is, that anyone can fill up the root file system, by writing temporary data to the /tmp folder, which is risky for system stability.# df -h /tmp Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 100G 4.6G 96G 5% /
Red Hat Enterprise Linux 7 offers the ability to use /tmp as a mount point for a temporary file storage system (tmpfs), but unfortunately, it is not enabled by default.
When enabled, this temporary storage appears as a mounted file system, but stores its content in volatile memory instead of on a persistent storage device. And when using this, no files in /tmp are stored on the hard drive except when memory is low, in which case swap space is used. This also means that the contents of /tmp are not persisted across a reboot.
To enable this feature, execute the following commands:
RHEL uses a default size of half the memory size for the in-memory /tmp file system. For example on a system with 16 GB of memory, an 8 GB /tmp file system is set up after enabling the tmp.mount feature:# systemctl enable tmp.mount # systemctl start tmp.mount
By having this in place, it's no longer possible to fill up the root file system, when writing files and/or data to the /tmp file system. The downside, however, is that this uses memory, and when filling up the memory, may be using the swap space. As such, having a dedicated file system on disk for the /tmp folder is still the better solution.# df -h /tmp Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 100G 53G 48G 53% / # systemctl enable tmp.mount # systemctl start tmp.mount # df -h /tmp Filesystem Size Used Avail Use% Mounted on tmpfs 7.8G 0 7.8G 0% /tmp
If you found this useful, here's more on the same topic(s) in our blog:
- Howto extend an ext3 filesystem in RHEL5
- Mounting a Windows share on an AIX system
- Howto Red Hat Enterprise Linux 5 configuring the network
- Howto extend an ext3 filesystem in RHEL5
- Missing disk method in HACMP configuration
UNIX Health Check delivers software to scan Linux and AIX systems for potential issues. Run our software on your system, and receive a report in just a few minutes. UNIX Health Check is an automated check list. It will report on perfomance, capacity, stability and security issues. It will alert on configurations that can be improved per best practices, or items that should be improved per audit guidelines. A report will be generated in the format you wish, and the report includes the issues discovered and information on how to solve the issues as well.
Interested in learning more?
Interested in learning more?




