# creation of swap file in /tmp



## Deleted member 9563 (Jan 8, 2017)

Is it OK to put a swap file in /tmp? I was planning to do the following:


```
# mkdir /tmp/swap
# dd if=/dev/zero of=/tmp/swap bs=128k count=32768
# chmod 0600 /tmp/swap
```

The /etc/fstab file entry would look like this:


```
md99        none     swap    sw,file=/tmp/swap,late     0       0
```


----------



## leebrown66 (Jan 8, 2017)

Provided you don't have `clear_tmp_enable` set to `YES` in your rc.conf, I see no reason why not.
You could test it first without the /etc/fstab entry, make sure after reboot the file was retained in /tmp.


----------



## ASX (Jan 8, 2017)

I would not do something like that, considering that at some point in time, if not already, you could use tmpfs for /tmp, and tmpfs is backed from swap.


----------



## Deleted member 9563 (Jan 8, 2017)

leebrown66 that's a good point. I may want to clear it, and perhaps automatically at boot time. 

ASX I've just gone ahead and done the format in question, however in the last minute I chickened out and used /var/swap instead. In that process I also realized that it should actually be /var/swap/swap As for using tempfs, some hours of reading has not convinced me it has any advantage for me.

In any case while reading all the, often contradictory, descriptions of how to format a FreeBSD disk, I can't help but remember that my /tmp directory has only been used sparsely over the years, and the swap has never been invoked even once in as long as I can remember.


----------

