You are not logged in.

#1 2010-09-04 09:09:16

phoenigs
Member
From: Munich - Germany
Registered: 2010-09-03
Posts: 16

[SOLVED] Mounting /tmp as tmpfs does not work?

Hi,

running arch since a few days now, and began a bit of tweaking.
I read, mounting the /tmp dir as a tmpfs adding the following line to my /etc/fstab should slightly increase performance. (plus removing the old /tmp mount rule)

none /tmp tmpfs nodev,nosuid,noatime,size=1000M,mode=1777 0 0

I have conky running showing my ram usage. Shouldn't the numbers increase if I copy something to the /tmp directory? I copied a large file to the dir. but nothing happened to the ram usage.

Thank you in advance, Peter

Last edited by phoenigs (2010-09-05 19:08:20)

Offline

#2 2010-09-04 10:53:46

olvar
Member
Registered: 2009-11-13
Posts: 97

Re: [SOLVED] Mounting /tmp as tmpfs does not work?

I don't really know the expected behaviour of tmpfs in that regard, but probably just running "mount" would tell you whether it is correctly mounted or not.
Also running df -h could be helpful. One possibility that occurs to me, is that the file is being send to the swap, so no noticeable change in the physical ram. To avoid that you could use ramfs.

Last edited by olvar (2010-09-04 10:58:50)

Offline

#3 2010-09-04 15:17:50

phoenigs
Member
From: Munich - Germany
Registered: 2010-09-03
Posts: 16

Re: [SOLVED] Mounting /tmp as tmpfs does not work?

The swap space is monitored by conky, too. There wasn't any change either. I will test the other tips, when I'm back home again.

EDIT: some pages give the info that tmpfs uses swap, some don't. Have to check it again, because of all the reading I'm not sure anymore wink

Last edited by phoenigs (2010-09-04 15:25:59)

Offline

#4 2010-09-04 15:38:33

lilsirecho
Veteran
Registered: 2003-10-24
Posts: 5,000

Re: [SOLVED] Mounting /tmp as tmpfs does not work?

When the programmed level of tmpfs is reached , the system reverts to using swap.


Prediction...This year will be a very odd year!
Hard work does not kill people but why risk it: Charlie Mccarthy
A man is not complete until he is married..then..he is finished.
When ALL is lost, what can be found? Even bytes get lonely for a little bit!     X-ray confirms Iam spineless!

Offline

#5 2010-09-04 16:08:21

Labello
Member
From: Germany
Registered: 2010-01-21
Posts: 317
Website

Re: [SOLVED] Mounting /tmp as tmpfs does not work?


"They say just hold onto your hope but you know if you swallow your pride you will choke"
Alexisonfire - Midnight Regulations

Offline

#6 2010-09-04 22:43:14

phoenigs
Member
From: Munich - Germany
Registered: 2010-09-03
Posts: 16

Re: [SOLVED] Mounting /tmp as tmpfs does not work?

Hi again,

Here the outputs of the two commands:

[peter@phlap|~]$ mount
proc on /proc type proc (rw,relatime)
sys on /sys type sysfs (rw,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=10240k,nr_inodes=493581,mode=755)
/dev/disk/by-uuid/4afd9796-b899-47a8-a4e0-04d70209a635 on / type ext4 (rw,relatime,barrier=1,data=ordered)
devpts on /dev/pts type devpts (rw)
shm on /dev/shm type tmpfs (rw,nosuid,nodev)
/dev/sda4 on /home type ext4 (rw)
/dev/sda1 on /boot type ext2 (rw)
none on /tmp type tmpfs (rw,nosuid,nodev,noatime,size=1000M,mode=1777)
[peter@phlap|~]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
udev                   10M  208K  9.8M   3% /dev
/dev/disk/by-uuid/4afd9796-b899-47a8-a4e0-04d70209a635
                       39G  3.4G   34G  10% /
shm                   1.9G  2.1M  1.9G   1% /dev/shm
/dev/sda4             104G  1.1G   98G   2% /home
/dev/sda1              99M   16M   79M  17% /boot
none                 1000M  661M  340M  67% /tmp

(I know the / partition is chosen a bit too large)

But here is another output:

[peter@phlap|tmp]$ free -m
             total       used       free     shared    buffers     cached
Mem:          3858       1965       1892          0         28       1605
-/+ buffers/cache:        330       3527
Swap:         4502          0       4502

As you can see, the mounting works properly. I have copied a 600mb file to /tmp, and it still says 330mb free ram. Or does the tmpfs count as "cached"?

I just want the "proof" that my /tmp directory is in the ram now wink

Last edited by phoenigs (2010-09-04 22:54:13)

Offline

#7 2010-09-04 23:38:36

olvar
Member
Registered: 2009-11-13
Posts: 97

Re: [SOLVED] Mounting /tmp as tmpfs does not work?

In my experience it does shows as cached. I don't know if that is always the case, but I don't think I've seen otherwise.

Offline

#8 2010-09-05 00:23:24

Wintervenom
Member
Registered: 2008-08-20
Posts: 1,011

Re: [SOLVED] Mounting /tmp as tmpfs does not work?

#!/bin/sh

# Bind-mount "/tmp" "and "/var/lock" instead of mounting a new tmpfs
# so we do not waste more RAM than we actually need to.
mkdir -p /dev/shm/{tmp,lock}
mount --bind /dev/shm/tmp /tmp
mount --bind /dev/shm/tmp /var/tmp
mount --bind /dev/shm/lock /var/lock
chmod 1777 /dev/shm/{tmp,lock}

Last edited by Wintervenom (2010-09-05 00:28:21)

Offline

#9 2010-09-05 08:27:46

phoenigs
Member
From: Munich - Germany
Registered: 2010-09-03
Posts: 16

Re: [SOLVED] Mounting /tmp as tmpfs does not work?

# Bind-mount "/tmp" "and "/var/lock" instead of mounting a new tmpfs
# so we do not waste more RAM than we actually need to.

Read that this is the advantage of tmpfs againgt ramdist, because it just uses the memory needed, so what is the advantage of using this script?
(And another question how could I set it up to run automatically on startup, because it needs root privileges...)

Copying and deleting files on /tmp really changes the "cached" value, think that does it as a proof wink

Offline

Board footer

Powered by FluxBB