Today has been a very rewarding day for finding interesting articles. Apart from the articles that I will mentioned in my next article here is one for my readers who runs the Gentoo operating system.
Basically the idea is to mount a virtual file-system over the directory that stores temporary files used during compilation of new software (/var/tmp/portage). As most you you might know, Gentoo includes a system that automatically compile and install software for you. The great part is that it is very easy to use, the down part however is that it sometimes takes hours to install a certain software. The Hard Drive being the slowest part in the equation has just to be removed.
To try it out simply add this line to your /etc/fstab file and mount it as root or reboot.
none /var/tmp/portage tmpfs size=212M,nr_inodes=1M 0 0
You might also want to kill the content for the directory before, as it most probably contains lost of useless data which would then be hidden behind the mount.
rm -fr /var/tmp/portage ; mkdir /var/tmp/portage
Now the guy in the article use a 1412M sized tmpfs virtual partition on a 2G of RAM system. I really wonder how this would work on a 512MB RAM system. It might just swap all the time removing the whole idea. So I'm not sure this tricks helps people who really needs help. (the people with regular hardware)
What I really would like to understand is how the tmpfs kernel module know when to delete or not a file from the memory. I'd be afraid that it kills some .o out of the memory before the full compilation comes to an end. Or that it keeps all these temporary files in memory for hours after the compilation is done. I'd like to understand the magic.
For more Linux related article, checkout their Kernel Knowledge page
Update: Then later I found in the comment it is useless to add an extra tmpfs as Gentoo always have one enabled.
And I Quote .... "You can always do this by using the existing tmpfs, /dev/shm. /dev/shm will allocate up to 1/2 of your system RAM for tmpfs and it should already exist. To use it change/add the following three lines to your gentoo /etc/make.conf file:"
PORTAGE_TMPFS="/dev/shm" PORTAGE_TMPDIR="/dev/shm" BUILD_PREFIX="/dev/shm"
Good luck in your trials. And please post comments on your experimentations.