Skip to content

Instantly share code, notes, and snippets.

@aitseitz
Last active March 14, 2024 16:01
Show Gist options
  • Save aitseitz/b969f86c9225379fd50e47e691e20aa4 to your computer and use it in GitHub Desktop.
Save aitseitz/b969f86c9225379fd50e47e691e20aa4 to your computer and use it in GitHub Desktop.
Temporary Directories Linux
#!/bin/bash
# This scripts enabled /tmp as RAM disc
function checkTmpDirectoryStatus(){
echo "Check your /tmp directory"
df -h /tmp
echo ""
echo "Check status of systemd tmp.mount"
sudo systemctl status tmp.mount
}
function enableTmpDirectoyinMemory(){
echo "copy tmp.mount to systemd units"
sudo cp /usr/share/systemd/tmp.mount /etc/systemd/system/tmp.mount
echo "enabled tmp.mount"
sudo systemctl enable tmp.mount
echo "Check status of systemd tmp.mount again"
sudo systemctl status tmp.mount
}
checkTmpDirectoryStatus
#enableTmpDirectoyinMemory
exit 0
@aitseitz
Copy link
Author

Enable /tmp directoy in RAM/Memory

Situation:

The /tmp directoy is mounted as a filesystem
image

image

this leads to performance problems if the disc is not fast enough and on fast ssd it can lead to a shorter lifetime to to massive I/O operations on /tmp

Solution:

Enable tmp.mount via Systemd:

image

df -h /tmp
sudo cp /usr/share/systemd/tmp.mount /etc/systemd/system/tmp.mount
sudo systemctl enable tmp.mount
sudo systemctl status tmp.mount
df -h /tmp

Links:
https://forums.linuxmint.com/viewtopic.php?t=286307
https://systemd.io/TEMPORARY_DIRECTORIES/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment