Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Tip/Trick: using tmpfs for /tmp
View unanswered posts
View posts from last 24 hours

Goto page 1, 2, 3  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
adsmith
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1386
Location: NC, USA

PostPosted: Sun Dec 19, 2004 3:29 am    Post subject: Tip/Trick: using tmpfs for /tmp Reply with quote

A nifty little filesystem setting I just ran across is setting /tmp to a tmpfs filesystem.

Basically, tmpfs is a type of filesystem which uses RAM (and swap) as its device, but it is dynamically allocated, unlike a ramdisk. Therefore, it only takes as much RAM as it needs. /dev/shm already uses this.

Assuming you have enough memory, this makes /tmp faster, and I guess it sort of stresses the "temporary" in /tmp, as it will certainly be cleared on reboot.

The downside is that you might run out of memory (oops!). However, you can set a maximum size for the tmpfs device to allocate.

In my case, however, I have 768MB of RAM, 2GB of swap, and only 1 GB of spare space on my root partition. In normal use, I never exceed about 5% of swap, so by setting my tmpfs limit at about 1GB, it is extremely unlikely I'll run out of virtual memory, and it is no more likely that I'll run out of space in /tmp than it would be in the normal configuration.

For all the commands and details, here is a great explanation, which I can't top, so I won't bother:
http://www-106.ibm.com/developerworks/library/l-fs3.html
Back to top
View user's profile Send private message
truekaiser
l33t
l33t


Joined: 05 Mar 2004
Posts: 801

PostPosted: Sun Dec 19, 2004 4:47 am    Post subject: Reply with quote

maybe the person who worte the power management guide for laptops in user doc's needs to read this...
Back to top
View user's profile Send private message
WladyX
Guru
Guru


Joined: 25 Nov 2004
Posts: 503
Location: Romania

PostPosted: Sun Dec 19, 2004 11:23 am    Post subject: Reply with quote

Any problems with it so far?
_________________
We are not alone.
Back to top
View user's profile Send private message
adsmith
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1386
Location: NC, USA

PostPosted: Sun Dec 19, 2004 2:57 pm    Post subject: Reply with quote

I've only been running it for a day, but no problems yet.

I've created a file in /tmp over 1GB to make sure the size limit works, and it does.

Are there any particular tests I should try? What can you think of that depends heavily on /tmp?
Back to top
View user's profile Send private message
WladyX
Guru
Guru


Joined: 25 Nov 2004
Posts: 503
Location: Romania

PostPosted: Sun Dec 19, 2004 3:04 pm    Post subject: Reply with quote

I heard but i'm not sure that mandrake uses tmpfs.
_________________
We are not alone.
Back to top
View user's profile Send private message
jwj
Apprentice
Apprentice


Joined: 07 May 2004
Posts: 240

PostPosted: Sun Dec 19, 2004 3:22 pm    Post subject: Reply with quote

I have exactly the same setup as adsmith running without no problems for about a year now. In /etc/fstab I use
Code:

tmpfs   /tmp   tmpfs   defaults,nosuid,size=1024M,mode=1777   0 0

to mount it.
Back to top
View user's profile Send private message
WladyX
Guru
Guru


Joined: 25 Nov 2004
Posts: 503
Location: Romania

PostPosted: Sun Dec 19, 2004 3:27 pm    Post subject: Reply with quote

How much ram/swap do you have?
_________________
We are not alone.
Back to top
View user's profile Send private message
jwj
Apprentice
Apprentice


Joined: 07 May 2004
Posts: 240

PostPosted: Sun Dec 19, 2004 3:29 pm    Post subject: Reply with quote

As adsmith I have 768MB RAM and 2GB of swap.
Back to top
View user's profile Send private message
WladyX
Guru
Guru


Joined: 25 Nov 2004
Posts: 503
Location: Romania

PostPosted: Sun Dec 19, 2004 3:33 pm    Post subject: Reply with quote

I have 1 GB ram and 1 GB swap, i don't think there will be any problems, i'll try the tmpfs soon!
_________________
We are not alone.
Back to top
View user's profile Send private message
Gherald
Veteran
Veteran


Joined: 23 Aug 2004
Posts: 1399
Location: CLUAConsole

PostPosted: Sun Dec 19, 2004 4:44 pm    Post subject: Reply with quote

interesting would be to figure out which parts of /var would do well in a tmpfs
Back to top
View user's profile Send private message
adsmith
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1386
Location: NC, USA

PostPosted: Sun Dec 19, 2004 4:57 pm    Post subject: Reply with quote

Yes, I was thinking about that for the temporary files arising from emerging stuff.

However, considering that emerging some things from source (*ahem* openoffice *ahem*) takes several GB, very few people could do this effectively.

The more one feels comfortable putting in tmpfs, though, is more evidence that he spent too much money on RAM. :D
Back to top
View user's profile Send private message
Gherald
Veteran
Veteran


Joined: 23 Aug 2004
Posts: 1399
Location: CLUAConsole

PostPosted: Sun Dec 19, 2004 5:16 pm    Post subject: Reply with quote

well if you make your swap big enough, I can't think of too many negative aspects

it's not like poeple emerge openoffice every day

but I wasn't limiting my thought to just portage... for example pid, lockfiles, etc have no real business being on disk


Last edited by Gherald on Sun Dec 19, 2004 5:18 pm; edited 1 time in total
Back to top
View user's profile Send private message
Taladar
Guru
Guru


Joined: 09 Oct 2004
Posts: 458
Location: Bielefeld, Germany

PostPosted: Sun Dec 19, 2004 5:17 pm    Post subject: Reply with quote

Sourcemage (another source-based Distro I used before Gentoo) uses tmpfs for compilation AFAIK and this reduces Disk I/O and speeds up compilation if you are dealing with lots of small files.
Back to top
View user's profile Send private message
adsmith
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1386
Location: NC, USA

PostPosted: Sun Dec 19, 2004 5:50 pm    Post subject: Reply with quote

Actually, if I had a laptop, I'd consider tossing /var/log into a tmpfs (and have them save to disk on shutdown or in a cron job or something), since logs are often the only reason for disk access.
Back to top
View user's profile Send private message
WladyX
Guru
Guru


Joined: 25 Nov 2004
Posts: 503
Location: Romania

PostPosted: Sun Dec 19, 2004 9:42 pm    Post subject: Reply with quote

What does mode=1777 do?
_________________
We are not alone.
Back to top
View user's profile Send private message
jwj
Apprentice
Apprentice


Joined: 07 May 2004
Posts: 240

PostPosted: Sun Dec 19, 2004 10:10 pm    Post subject: Reply with quote

mode=1777 sets sticky bit on directory. Only file owners can delete files in this directory.
Back to top
View user's profile Send private message
WladyX
Guru
Guru


Joined: 25 Nov 2004
Posts: 503
Location: Romania

PostPosted: Sun Dec 19, 2004 10:14 pm    Post subject: Reply with quote

Thank you!
_________________
We are not alone.
Back to top
View user's profile Send private message
Jinidog
Guru
Guru


Joined: 26 Nov 2003
Posts: 593
Location: Berlin

PostPosted: Mon Dec 20, 2004 11:24 am    Post subject: Reply with quote

What is when using this with a system with less RAM (e. g. 128 MB RAM).
Of course, there will be many swapping, but it would use all available memory.
Would it still be faster using tmpfs for /tmp and /var/tmp/portage or would that be a slowdown?
_________________
Just unused Microsoft-Software is good Microsoft-Software
Back to top
View user's profile Send private message
Gherald
Veteran
Veteran


Joined: 23 Aug 2004
Posts: 1399
Location: CLUAConsole

PostPosted: Mon Dec 20, 2004 11:36 am    Post subject: Reply with quote

Well of course it will be considerably slower. I am curious just *how* much slower, but all my systems have lots of RAM so it's difficult for me to test what happens when tmpfs starts using virtual memory.

How about you benchmark it for us and post the results?
Back to top
View user's profile Send private message
adsmith
Veteran
Veteran


Joined: 26 Sep 2004
Posts: 1386
Location: NC, USA

PostPosted: Mon Dec 20, 2004 1:10 pm    Post subject: Reply with quote

The problem with that is that I'm not sure how the kernel deals with the priority of tmpfs versus actual memory usage. Perhaps tmp might run at a speed no slower than it would on disk, but the system itself could come to a grinding halt.
In that case, I'd rather have slow /tmp than a non-responsive system.....
Back to top
View user's profile Send private message
Jinidog
Guru
Guru


Joined: 26 Nov 2003
Posts: 593
Location: Berlin

PostPosted: Mon Dec 20, 2004 2:23 pm    Post subject: Reply with quote

strange.
On a system with 512 MB of RAM I tested the performance of being /var/tmp/portage a tmpfs.
The results:

without tmpfs:
real 2m41.081s
user 1m48.505s
sys 0m20.697s

with tmpfs:
real 2m58.270s
user 1m50.086s
sys 0m21.272s

Concluding the filesystem in the memory gave worse performance than having a normal Reiser3.6 Filesystem on the harddisk.
CCache was not activated.

I said it, strange.
_________________
Just unused Microsoft-Software is good Microsoft-Software
Back to top
View user's profile Send private message
Gherald
Veteran
Veteran


Joined: 23 Aug 2004
Posts: 1399
Location: CLUAConsole

PostPosted: Mon Dec 20, 2004 2:56 pm    Post subject: Reply with quote

And for something funny, try: http://www.google.com/search?btnI&q=tmpfs

third paragraph wrote:
Tmpfs is recommended for systems that do a lot of compiling and loading of programs
and have large amounts of memory (> 16 MB) and swap space.
:D
Back to top
View user's profile Send private message
Config
Retired Dev
Retired Dev


Joined: 25 May 2003
Posts: 187
Location: Zurich, Switzerland

PostPosted: Mon Dec 20, 2004 5:17 pm    Post subject: Reply with quote

For those who have a huge tmpfs on /tmp.... here is my fstab line:

Code:
none                    /tmp            tmpfs           size=32m        0 0


And I've never run into problems so far on my laptop - and I use it heavily since may be 3 month now

Yeah, I like keeping my /tmp small ;)
_________________
Config - caught by a chronic disease called tuxmania....
Back to top
View user's profile Send private message
truekaiser
l33t
l33t


Joined: 05 Mar 2004
Posts: 801

PostPosted: Mon Dec 20, 2004 11:59 pm    Post subject: Reply with quote

Config wrote:
For those who have a huge tmpfs on /tmp.... here is my fstab line:

Code:
none                    /tmp            tmpfs           size=32m        0 0


And I've never run into problems so far on my laptop - and I use it heavily since may be 3 month now

Yeah, I like keeping my /tmp small ;)


i have to do the following or nothing starts.

Code:
tmpfs  /dev/shm  tmpfs size=32m  0 0
tmpfs  /tmp  tmpfs defaults,nosuid,size=32m,mode=1777  0 0
Back to top
View user's profile Send private message
Pink
Veteran
Veteran


Joined: 24 Jul 2003
Posts: 1062

PostPosted: Tue Dec 21, 2004 8:23 am    Post subject: Reply with quote

Code:
tmpfs         /tmp      tmpfs      size=256M         0 0


I have mine at 256M (and have for some months) and have compiled OOo, an entirely new install from stage1 and made a cup of tea and have seen no problems, everything is as slick and speedy as ever.

Out of interest I have 512MB for both RAM and swap. I think, as shown above in the brilliant quote about > 16MB RAM, that an awful lot of 'instructions' and advice are regarding much older hardware.

Now this is IMHO, but 768MB ram, with 2GB of swap, and a 1GB tmp partition and being concerned over only having 1GB root: If it was me I would immediately drop the swap to 512 or possibly the same level as the RAM, and drop the tmp to 256 or lower. Thus I would't be too concerned about the 1Gb left on my root (As I would have about 3 1/4 GB).

/me shrugs. Just thought I'd chip in a tuppence.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum