Friday, September 28, 2018

mount /tmp on tmpfs? compile and runtime tmpfs overloads

I located (via yaourt) a large wine client -- a few hundred megabytes and half an hour to compile on an older laptop. But two wine compilation problems appeared during the install: 1) wine doesn't compile because its PGP key is unrecognized by yaourt, 2) wine doesn't compile because the system runs out of available RAM.

First the PGP problem: when the PGP rejection error notice is generated, one can see the key in the notice. Users can then copy it and add it to their keyring. The reason for the confusion is that yaourt relies on the user's personal key ring, which is a different key ring than pacman's dedicated keyring. So accept the key into your personal gpg ring...then restart the install and yaourt will accept the app.
$ gpg --recv-key [key]
...or you can examine the key owner's information with --fingerprint [key].

memory

Now we have the application, we have several ways to check the memory parameters.
$ free
total used free shared buff/cache available
Mem: 2034884 330740 1301548 45624 402596 1512420
Swap: 50426196 0 50426196

$ swapon
NAME TYPE SIZE USED PRIO
/dev/sda2 partition 48.1G 0B -2

$ df
Filesystem 1K-blocks Used Available Use% Mounted on
dev 1010468 0 1010468 0% /dev
run 1017440 592 1016848 1% /run
/dev/sda1 258030980 27348180 217575600 12% /
tmpfs 1017440 2972 1014468 1% /dev/shm
tmpfs 1017440 0 1017440 0% /sys/fs/cgroup
tmpfs 1017440 8 1017432 1% /tmp
tmpfs 203488 0 203488 0% /run/user/1000

$ cat /etc/fstab
/dev/sda1 / ext3 rw,relatime,block_validity,barrier,user_xattr,acl 0 1

/dev/sda2 none swap defaults,pri=-2 0 0

Where do these additional entries not in fstab originate? Can they be controlled? It appears we need some strategy for our tmpfs to go onto swap space once RAM is full so that the system doesn't lockup.

memory during compiling

During application compiling, tmpfs is used for parking files spawned or used by make. The tmpfs space is in RAM, viewable inside /tmp, and it allows compilations to progress quickly. However, compiling larger applications can require so much /tmp space, that RAM becomes filled. Once RAM is nearly full, make aborts complaining of a lack of space. Although tmpfs is supposed to overflow into SWAP space it does not. How can we compile these larger programs?

As noted, /tmp naturally resides in RAM. At the expense of 1) time, perhaps 25% longer compilation, and 2) the risk of thrashing one's hard drive, one can mount their /tmp directory on the hard disk. The important thing then is to refer this directory back to RAM after compiling the project. /var/tmp is the answer, but how to get it to connect with RAM?
# nano /etc/fstab
tmpfs /tmp tmpfs size=25G 0 0
This is all that's necessary. Checking...
$ df
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 1016196 5752 1010444 1% /dev/shm
tmpfs 26214400 8 26214392 1% /tmp
Now we can compile wine. We still have /dev/shm for regular RAM, but with spillover into 25G HDD swap if needed. Since I won't need this regularly, I will comment it from /etc/fstab once I compile wine.



No comments: