I have a tiny computer with not so much RAM (1-2GiB) and very little disk space in which I installed Gentoo. I also have space on a shared NFS.
In order to be able to compile any package, even the biggest ones, I created a swap file on the NFS, just in case (it is almost never used) and a directory used as the temporary compilation directory. It was working well, but I found that unpacking the packages (tar x
) on the NFS temporary directory was taking ages, even for quite small packages.
So, I decided to increase the swap file to quite a huge size (20GiB) and created a tmpfs of 16GiB to use as temporary compilation directory (/var/tmp/portage/dist
):
mount -t nfs nfs-server:/var/tmp/dist/$(hostname)/misc /var/tmp/misc
fallocate -l 20g /var/tmp/misc/swapfile
chmod 600 /var/tmp/misc/swapfile
mkswap /var/tmp/misc/swapfile
swapon /var/tmp/misc/swapfile
mount -t tmpfs -o size=16g tmpfs /var/tmp/portage/dist
chmod 1777 /var/tmp/portage/dist
For small packages, everything is done locally in RAM and is therefore very quick.
For medium size packages, it is fully filling the RAM and using a part of the swap file. Performance decreases, of course, but not that much.
But for biggest packages, the RAM is completely used, the usage of the swap file is increasing, and at a given moment, the system seems to freeze (I can't say that it freezes for sure, because my only access is through SSH, and I loose this connection, the system does not respond to any network request anymore, even a ping
). I think that compilation is then stopping, because I also have another NFS mount for a ccache directory which is not touched anymore by the tiny computer.
My questions are:
- What do you think is causing that freezing?
- Are there parameters I should set to prevent it (like
noatime
, for mytmpfs
)? - Did I choose the right solution or is there any other better way to achieve this?