tmpfs little help

There may be some confusion between tmpfs(5) and md(4)-based /tmp, set up by the tmpmfs and tmpsize directives in rc.conf.

tmpmfs is the original method of creating a fixed size memory disk, then mounting it as /tmp.

tmpfs is the newer, experimental virtual-memory based method.

The only thing required to set up tmpfs is a line in fstab (as the kernel module will be loaded automatically).

Code:
tmpfs   /tmp    tmpfs   rw,mode=01777   0       0

You don't need to specify a filesystem size for tmpfs; it simply uses as much virtual memory as required.
 
sk8harddiefast said:
Is dangerous to delete now all files on /tmp? Are useless. Right?
That would remove tmpfs' mountpoint (/tmp/tmpfs) thus breaking the startup next time your reboot.
Maybe you are misunderstanding something so let it be clear: tmpfs is mounted on the /tmp/tmpfs directory not on the /tmp directory. The disk-based filesystem mounted on /tmp contains many files that are unrelated to tmpfs (mostly sockets and FIFO pipes) besides your tmpfs mountpoint.
So you can remove all the files in /tmp but keep /tmp/tmpfs.

Or if you want the whole /tmp to be cleared every time your reboot the machine, then do as in jem's post above and mount tmpfs directly on /tmp. Do not forget to remove the UFS /tmp line.
 
I was meaning all except /tmp/tmpfs. I mounted tmpfs on /tmp and "df -h /tmp" now is:
Code:
Filesystem    Size    Used   Avail Capacity  Mounted on
tmpfs         5.4G    8.3M    5.4G     0%    /tmp
The only problem is:
Code:
sudo echo "export TMPDIR=/tmp" >> .profile
bash: .profile: Permission denied
 
sk8harddiefast said:
I was meaning all except /tmp/tmpfs. I mounted tmpfs on /tmp and "df -h /tmp" now is:
Code:
Filesystem    Size    Used   Avail Capacity  Mounted on
tmpfs         5.4G    8.3M    5.4G     0%    /tmp
The only problem is:
Code:
sudo echo "export TMPDIR=/tmp" >> .profile
bash: .profile: Permission denied

Reset the owner/group/permissions on your ~/.profile and don't use sudo when editing your user files?

You could also put the TMPDIR statement in your global /etc/profile, if you're so inclined.
 
Sorry. I had run [echo "export TMPDIR=/tmp" >> .profile] on / so I guess that understood root's .profile. When I went to /home/user and execute the same command then done :) Solved :D
 
This bears repeating, and it will be printed in boldface when booting:
Code:
[B]WARNING: TMPFS is considered to be a highly experimental feature in FreeBSD.[/B]
Use with caution.
 
I saw it when I boot first time. Looks to run fine for me :) If I see any problem, just I will remove the line from fstab. For now conky tells me that tmpfs is growing :p I made a reboot to see if data will be deleted and deleted. Seems to work.
 
If you like to have /tmp in RAM/swap, you can always fall back to trusted tmpmfs (run grep ^tmp /etc/defaults/rc.conf for example). It's what I always used before playing with tmpfs.
 
I set tmpmfs="YES" on rc.conf and change on fstab this:
Code:
tmpfs	/tmp    tmpfs	rw,mode=01777	  0     0
to this:
Code:
tmpmfs	/tmp    tmpmfs	  rw,mode=01777	     0     0
 
sk8harddiefast said:
For now conky tells me that tmpfs is growing :p I made a reboot to see if data will be deleted and deleted. Seems to work.
No need to reboot. You can remove files (e.g. cache) manually at any time.
 
@sk8harddiefast, when you use 'tmpmfs', you don't need anything for /tmp in fstab. The automatically created md device (usually /dev/md0) will be used, and it will show up in mount.

I used this in /etc/rc.conf for a 1G /tmp with tmpmfs:

Code:
tmpmfs="YES"
tmpsize="1024m"
tmpmfs_flags="-m 0 -o async,noatime -S -p 1777"
 
Before people get confused: if you read this thread, be sure to distinguish between tmpmfs ("old and trusted") and tmpfs ("new and experimental"). They perform the same function, but they are very different.
 
aragon said:
Does anyone know what to avoid (or test) with tmpfs that might make it blow up?
Yes, nothing. As I said earlier, I have been using it extensively* since it was first introduced and never had any problem whatsoever.

* Every caching (browser, thumbnail, etc.) directory in my home directory is symlinked to it. I also store small temporary files there.
 
As I understood Tmpfs is a type of "fylesystem". Is mounted as partition on boot. The Tmpmfs is just an option to have all /tmp in Ram/Swap. Tmpfs do the same but Tmpmfs is option and not "filesystem" ? Something like that? Not sure. I am learning all this from the procedure.
 
sk8harddiefast said:
As I understood Tmpfs is a type of "fylesystem". Is mounted as partition on boot. The Tmpmfs is just an option to have all /tmp in Ram/Swap. Tmpfs do the same but Tmpmfs is option and not "filesystem"
Well, obviously, both are filesystems since they both can hold and organize files.

As you can see in /etc/rc.d/tmp, a "tmpmfs" is nothing more than an md(4) memory disk mounted on /tmp.

As for the difference, I think there is not much. From what I read here and there, tmpfs may be faster and more efficient than md.
 
nORKy said:
What is different between tmpmfs and tmpfs?

tmpmfs (configured from /etc/rc.conf) uses mdmfs(8) under /tmp/, essentially doing the same as if you issued # mdconfig -a -t swap -u0 && newfs -U /dev/md0 && mount /dev/md0 /tmp

tmpfs(5) is, AFIK a self contained filesystem & memory disk driver, supposedly designed to be a memory disk. Maybe one of the boffins can clue us in, but I'm not aware that UFS is particularly optimized for use on md(4). I suppose if someone were feeling testy they could run some benchmarks to compare. I'm happy to just have a gin&tonic and call myself a naughty boy (later).
 
Back
Top