This seems to work pretty well. The idea is to have KDE put temporary files in RAM instead of on your hard drive. This works well if you have a slow writing drive (e.g., RAID and write throughs) and/or lots of RAM.
Step 0: You should really have a backup before you do this. If you can't be bothered, at least backup /etc/fstab:
Code:
mkdir ~/backup
cp /etc/fstab ~/backup/fstab
Step 1: Create a mount point for a tmpfs
Code:
sudo mkdir /tmp-ram
Step 2: Mount tmpfs on new mount point
Code:
sudo <your favorite editor> /etc/fstab
Examples of <your favorite editor> would be nano, kate, etc.
Add this line to the bottom of the /etc/fstab
Code:
tmpfs /tmp-ram tmpfs noatime,nosuid,nodev,size={SIZE} 0 0
{SIZE} is the maximum amount of RAM you want to dedicate to the temporary file system.
For example, I have:
Code:
tmpfs /tmp-ram tmpfs noatime,nosuid,nodev,size=900 0 0
The default limit is 1/2 of your RAM and swap space. If you exceed this, you can make your machine perform slowly or not at all, so don't commit too much memory.
Step 3: Create mount
Issue:
Or if you are lazy, just reboot. I prefer do to the mount -a so if I made a typo I will see an error message and can go fix it.
If you want to verify just say:
And verify that /tmp-ram is mounted with tmpfs file system.
Step 4:
Create file in ~/.kde/env named relo.sh with your favorite text editor (no sudo required)
Code:
export KDETMP=/tmp-ram
export KDEVARTMP=/tmp-ram
ln -s /tmp-ram/kde-{USERID} ~/.kde/tmp-{HOSTNAME}
Replace {HOSTNAME} with whatever the hostname command tells you your computer name is. For example, mine is:
Code:
~/.kde/tmp-enterprise
Replace {USERID} with your user ID
Edit file /etc/rc.local and put these lines before the exit 0 that should be at the end:
Code:
mkdir /tmp-ram/{USERID}
chown -R {USERID} /tmp-ram/{USERID}
chmod 700 /tmp-ram/{USERID}
Again, use your user ID, like this:
Code:
mkdir /tmp-ram/alw
chown -R alw /tmp-ram/alw
chmod 700 /tmp-ram/alw
Step 5. Log out of KDE
Just use the leave button and tell it to log off. You should go back to the login screen.
Step 6. Get a Console
Open a console (Control+Alt+F1) and log in.
Step 7. Remove tmp-{HOSTNAME}
Issue from the console:
Code:
rm ~/.kde/tmp-{HOSTNAME}
(replace {HOSTNAME} with your hostname)
You can then exit the console or if you are lazy you can reboot by issuing the command:
[CODE]sudo reboot[CODE]
Step 8. Return to X and log in
If you didn't reboot, make sure /tmp-ram/kde-{USERID} exists (issue the 3 commands you put in rc.local manually, if not, or just reboot) and use Control+Alt+F7 (not sure it is always on F7). Then log in as usual
Step 9. Verify
Open a konsole prompt and issue:
You should see cache-XXX, socket-XXX, and tmp-XXX as links to /tmp-ram (XXX is your hostname).
Reversal
It is pretty easy to reverse all of this. Simply remove relo.sh and delete the tmp file (~/.kde/tmp-{HOSTNAME}) when KDE is not running. Then log back in. You can also unmount the tmpfs, remove the fstab line, and delete the tmp-ram mount point. I would wait to do that until after you logged back into KDE and verified that the files no longer point to /tmp-ram.
Limitation & Notes
When KDE starts up it will have to rebuild the cache it uses which means you will get a slightly slower startup. It is imperceptible on my machine. Your mileage may vary.
This seems to work well for me. Then again, I have a write through SSD cache to a RAID array so writes are expensive even if cached.
Bookmarks