How to change /tmp temporarily?

I have partitioned the main disk a long time ago, when the default was small standalone partitions for /tmp and root /. Most of times it is still sufficient for my usage, but some processes need more than 512MiB. Sometimes it is live-stream in Firefox, and now it is lang/rust when it is building from source, it bloats /tmp for some reason within its endless bootstraping while I have the version of rust installed.
So, the question. Is there any variable to set while building, say, lang/rust to point to more spacious directory?
The second question is how to change permanently /tmp or even root / (and not loose this 512MiB) or the whole system?
 
So, the question. Is there any variable to set while building, say, lang/rust to point to more spacious directory?
I don't think ports building takes up much space in /tmp, unless you have set WRKDIRPREFIX to point to /tmp – Have you done that? In that case, you might want to set it to somewhere else with sufficient free space.

One exception I’m aware of is KDE which uses $TMPDIR for package building, which defaults to /tmp. Maybe some other ports do this, too. So you might want to set TMPDIR, too.
The second question is how to change permanently /tmp or even root / (and not loose this 512MiB) or the whole system?
Depends how you have partitioned your disks. Do you have only those two partitions and no free space elsewhere? In that case it’s rather difficult.

Personally I always mount TMPFS on /tmp. On my workstation (32G RAM) I have this entry in /etc/fstab:
Code:
tmpfs   /tmp   tmpfs   rw,mode=01777,size=20G,inodes=262144,nosuid   0   0
Note that the size=20G parameter is only a maximum. The TMPFS will automatically grow and shrink to accomodate its contents.
 
I don't think ports building takes up much space in /tmp, unless you have set WRKDIRPREFIX to point to /tmp – Have you done that? In that case, you might want to set it to somewhere else with sufficient free space.

One exception I’m aware of is KDE which uses $TMPDIR for package building, which defaults to /tmp. Maybe some other ports do this, too. So you might want to set TMPDIR, too.
Yes, I also thought so until system is stopped working good, build of rust is failed due to insufficient space and temporary rust directory in /tmp grabbed all the partition. No, haven't set WRKDIRPREFIX to anything. Haven't seen anything like TMPDIR near rust's Makefile.

Depends how you have partitioned your disks. Do you have only those two partitions and no free space elsewhere? In that case it’s rather difficult.

Personally I always mount TMPFS on /tmp. On my workstation (32G RAM) I have this entry in /etc/fstab:
Code:
tmpfs   /tmp   tmpfs   rw,mode=01777,size=20G,inodes=262144,nosuid   0   0
Note that the size=20G parameter is only a maximum. The TMPFS will automatically grow and shrink to accomodate its contents.
Luckily, I have space on other discs, so I've made symlink /tmp there. But now root / is my concern since newer kernels and modules grow also...
As for RAM disk, I'm not sure yet. My 32 GiB of RAM are used (in InActive state mostly, but yet) with programmes like browser or network caching or other desktop stuff and it is used by shm also.
 
To specifically answer the question, set the environmental variable "TMPDIR" to where you want the temporary file(s) to be located. Note that this impacts any temporary file that any process that inherits the variable creates.

FWIW, I have a 512M /tmp partition and building rust just blows it out. I move the rust temporary directory (/tmp/rustNNNNNNN) to my temporary location and resume the build. It recovers cleanly and I don't have to waste a couple of hours.
 
Back
Top