/tmp on tmpfs
We'd like to mount a tmpfs on /tmp by default. (Administrators can override this)
- Name: Lennart Poettering
- Email: lennart at poettering dot net
- Name: Kay Sievers
- Email: email@example.com
- Targeted release: Fedora 18
- Last updated: 2012-03-22
- Percentage of completion: 0%
We'd like to mount a tmpfs on /tmp by default, but still allow administrators to opt out from this.
Solaris has been doing this since 1994. (Much like other Unixes, too.) Debian's next release defaults to tmpfs on /tmp, too. ArchLinux defaults to this as well. Ubuntu has plans for their 12.10 release.
Benefit to Fedora
By implementing this we generate less IO on disks. This increases SSD lifetime,s aves a bit of power and makes things a bit faster.
/tmp is automatically flushed at boot.
We bring Fedora closer to commercial Unixes and other Linux distributions.
We make the delta to stateless read-only systems smaller.
systemd upstream needs a minimal change to ship a mount unit for /tmp by default.
We might need to patch a couple of packages not to store big files and files needing boot persistance in /tmp, but rather in /var/tmp. This work has already progressed due to Debian's work.
How To Test
The system should boot up and work as normal. Applications should work as normal. However, /bin/mount should show /tmp to be a tmpfs. Besides that the system operates normally and a check that /tmp is actually a tmpfs there is little to test.
The user experience should barely change. This is mostly a low-level change that has little visibility to the user.
The plan is like this:
Turn on /tmp as tmpfs very early in the Fedora 18 cycle. Fix any problems coming up, and revert back to non-tmpfs /tmp if they become too many. The revert should by fairly trivial and isolated. Just consists of dropping a unit file from the systemd package.
/tmp now defaults to tmpfs. This might break a few programs which assume that they can place large files in /tmp or that /tmp is persistant across boot. If these programms cannot be fixed to usr /var/tmp instead of /tmp for this, there are two options:
Disable mounting of tmpfs on /tmp by issuing "systemctl mask tmp.mount". Note that this will entirely disable any mounting of any file system to /tmp. To mount a different file system to this place instead place a configuration file like this in /etc/systemd/system/tmp.mount:
[Mount] What=/dev/sda5 Where=/tmp Type=ext4
Comments and Discussion
A couple of FAQs:
What about quota on /tmp? tmpfs does not support quota!
That is true, however no different as with /run or /dev/shm where unprivileged users have access too. The quota on tmpfs problem needs to be fixed in the kernel anyway, whether it is 2 or 3 file systems that are writable by normal users makes little difference.
My CD burning application writes huge .iso files to /tmp, and this breaks on tmpfs!
The application should be fixed to use /var/tmp.
My application writes temporary files to /tmp and they are gone after a reboot!
The application should be fixed to use /var/tmp. FHS recommends that /tmp is flushed on reboot, and that's what we do here.