Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Discussion & Documentation Documentation, Tips & Tricks
  • Search

Tip/Trick: using tmpfs for /tmp

Unofficial documentation for various parts of Gentoo Linux. Note: This is not a support forum.
Post Reply
Advanced search
63 posts
  • 1
  • 2
  • 3
  • Next
Author
Message
adsmith
Veteran
Veteran
Posts: 1386
Joined: Sun Sep 26, 2004 6:59 pm
Location: NC, USA

Tip/Trick: using tmpfs for /tmp

  • Quote

Post by adsmith » Sun Dec 19, 2004 3:29 am

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/l ... l-fs3.html
Top
truekaiser
l33t
l33t
User avatar
Posts: 832
Joined: Fri Mar 05, 2004 11:00 pm

  • Quote

Post by truekaiser » Sun Dec 19, 2004 4:47 am

maybe the person who worte the power management guide for laptops in user doc's needs to read this...
Top
WladyX
Guru
Guru
User avatar
Posts: 503
Joined: Thu Nov 25, 2004 4:17 pm
Location: Romania
Contact:
Contact WladyX
Website

  • Quote

Post by WladyX » Sun Dec 19, 2004 11:23 am

Any problems with it so far?
We are not alone.
Top
adsmith
Veteran
Veteran
Posts: 1386
Joined: Sun Sep 26, 2004 6:59 pm
Location: NC, USA

  • Quote

Post by adsmith » Sun Dec 19, 2004 2:57 pm

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?
Top
WladyX
Guru
Guru
User avatar
Posts: 503
Joined: Thu Nov 25, 2004 4:17 pm
Location: Romania
Contact:
Contact WladyX
Website

  • Quote

Post by WladyX » Sun Dec 19, 2004 3:04 pm

I heard but i'm not sure that mandrake uses tmpfs.
We are not alone.
Top
jwj
Apprentice
Apprentice
User avatar
Posts: 240
Joined: Fri May 07, 2004 7:03 pm

  • Quote

Post by jwj » Sun Dec 19, 2004 3:22 pm

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

Code: Select all

tmpfs	/tmp	tmpfs	defaults,nosuid,size=1024M,mode=1777	0 0
to mount it.
Top
WladyX
Guru
Guru
User avatar
Posts: 503
Joined: Thu Nov 25, 2004 4:17 pm
Location: Romania
Contact:
Contact WladyX
Website

  • Quote

Post by WladyX » Sun Dec 19, 2004 3:27 pm

How much ram/swap do you have?
We are not alone.
Top
jwj
Apprentice
Apprentice
User avatar
Posts: 240
Joined: Fri May 07, 2004 7:03 pm

  • Quote

Post by jwj » Sun Dec 19, 2004 3:29 pm

As adsmith I have 768MB RAM and 2GB of swap.
Top
WladyX
Guru
Guru
User avatar
Posts: 503
Joined: Thu Nov 25, 2004 4:17 pm
Location: Romania
Contact:
Contact WladyX
Website

  • Quote

Post by WladyX » Sun Dec 19, 2004 3:33 pm

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.
Top
Gherald
Veteran
Veteran
User avatar
Posts: 1399
Joined: Mon Aug 23, 2004 10:19 pm
Location: CLUAConsole

  • Quote

Post by Gherald » Sun Dec 19, 2004 4:44 pm

interesting would be to figure out which parts of /var would do well in a tmpfs
US.EF.UL | mine | Stage 1/3 | console login | use cd -
Top
adsmith
Veteran
Veteran
Posts: 1386
Joined: Sun Sep 26, 2004 6:59 pm
Location: NC, USA

  • Quote

Post by adsmith » Sun Dec 19, 2004 4:57 pm

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
Top
Gherald
Veteran
Veteran
User avatar
Posts: 1399
Joined: Mon Aug 23, 2004 10:19 pm
Location: CLUAConsole

  • Quote

Post by Gherald » Sun Dec 19, 2004 5:16 pm

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.
US.EF.UL | mine | Stage 1/3 | console login | use cd -
Top
Taladar
Guru
Guru
Posts: 458
Joined: Sat Oct 09, 2004 4:26 pm
Location: Bielefeld, Germany

  • Quote

Post by Taladar » Sun Dec 19, 2004 5:17 pm

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.
Top
adsmith
Veteran
Veteran
Posts: 1386
Joined: Sun Sep 26, 2004 6:59 pm
Location: NC, USA

  • Quote

Post by adsmith » Sun Dec 19, 2004 5:50 pm

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.
Top
WladyX
Guru
Guru
User avatar
Posts: 503
Joined: Thu Nov 25, 2004 4:17 pm
Location: Romania
Contact:
Contact WladyX
Website

  • Quote

Post by WladyX » Sun Dec 19, 2004 9:42 pm

What does mode=1777 do?
We are not alone.
Top
jwj
Apprentice
Apprentice
User avatar
Posts: 240
Joined: Fri May 07, 2004 7:03 pm

  • Quote

Post by jwj » Sun Dec 19, 2004 10:10 pm

mode=1777 sets sticky bit on directory. Only file owners can delete files in this directory.
Top
WladyX
Guru
Guru
User avatar
Posts: 503
Joined: Thu Nov 25, 2004 4:17 pm
Location: Romania
Contact:
Contact WladyX
Website

  • Quote

Post by WladyX » Sun Dec 19, 2004 10:14 pm

Thank you!
We are not alone.
Top
Jinidog
Guru
Guru
User avatar
Posts: 593
Joined: Wed Nov 26, 2003 7:21 pm
Location: Berlin
Contact:
Contact Jinidog
Website

  • Quote

Post by Jinidog » Mon Dec 20, 2004 11:24 am

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
Top
Gherald
Veteran
Veteran
User avatar
Posts: 1399
Joined: Mon Aug 23, 2004 10:19 pm
Location: CLUAConsole

  • Quote

Post by Gherald » Mon Dec 20, 2004 11:36 am

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?
US.EF.UL | mine | Stage 1/3 | console login | use cd -
Top
adsmith
Veteran
Veteran
Posts: 1386
Joined: Sun Sep 26, 2004 6:59 pm
Location: NC, USA

  • Quote

Post by adsmith » Mon Dec 20, 2004 1:10 pm

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.....
Top
Jinidog
Guru
Guru
User avatar
Posts: 593
Joined: Wed Nov 26, 2003 7:21 pm
Location: Berlin
Contact:
Contact Jinidog
Website

  • Quote

Post by Jinidog » Mon Dec 20, 2004 2:23 pm

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
Top
Gherald
Veteran
Veteran
User avatar
Posts: 1399
Joined: Mon Aug 23, 2004 10:19 pm
Location: CLUAConsole

  • Quote

Post by Gherald » Mon Dec 20, 2004 2:56 pm

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
US.EF.UL | mine | Stage 1/3 | console login | use cd -
Top
Config
Retired Dev
Retired Dev
User avatar
Posts: 187
Joined: Sun May 25, 2003 7:18 am
Location: Zurich, Switzerland

  • Quote

Post by Config » Mon Dec 20, 2004 5:17 pm

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

Code: Select all

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....
Top
truekaiser
l33t
l33t
User avatar
Posts: 832
Joined: Fri Mar 05, 2004 11:00 pm

  • Quote

Post by truekaiser » Mon Dec 20, 2004 11:59 pm

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

Code: Select all

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: Select all

tmpfs  /dev/shm  tmpfs size=32m  0 0
tmpfs  /tmp  tmpfs defaults,nosuid,size=32m,mode=1777  0 0
Top
Pink
Veteran
Veteran
User avatar
Posts: 1062
Joined: Thu Jul 24, 2003 11:52 am

  • Quote

Post by Pink » Tue Dec 21, 2004 8:23 am

Code: Select all

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.
Top
Post Reply

63 posts
  • 1
  • 2
  • 3
  • Next

Return to “Documentation, Tips & Tricks”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic