Moving /tmp to RAM and pleasing SELinux on RHEL5

On a box that had lots of unused memory, I decided to move /tmp to memory. But getting SELinux to stop complaining was a challenge. I would get log entries in /var/log/messages like

kernel: SELinux: security_context_to_sid(system_u:object_r:tmp_t) failed for (dev tmpfs, type tmpfs) errno=-22

Here is the line that I added to /etc/fstab that caused it to mount correctly:

tmpfs                  /tmp                    tmpfs   defaults,size=4096m,context=system_u:object_r:tmp_t:s0 0

This is what it looks like after a successful boot:

# df -h
Filesystem            Size  Used Avail Use% Mounted on
...
tmpfs                 3.9G     0  3.9G   0% /dev/shm
tmpfs                 4.0G     0  4.0G   0% /tmp

SELinux is not entirely happy about the situation, though. It still leaves this log entry:

setroubleshoot: SELinux is preventing the xfs from using potentially mislabeled files (/tmp/.font-unix). For complete SELinux messages. run sealert -l 30ae77a9-fc73-491d-9f84-5e6d2fb982ec

Topic: