Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
/tmp and swap
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
easy_coder
n00b
n00b


Joined: 24 Apr 2005
Posts: 23

PostPosted: Sat Apr 30, 2005 5:54 pm    Post subject: /tmp and swap Reply with quote

is /tmp and swap the same thing? If I have a /tmp dir do i need swap?
Back to top
View user's profile Send private message
nixnut
Bodhisattva
Bodhisattva


Joined: 09 Apr 2004
Posts: 10974
Location: the dutch mountains

PostPosted: Sat Apr 30, 2005 6:06 pm    Post subject: Reply with quote

They are not the same thing. Swap is used by the kernel for memory management, /tmp is used for temporary files. You can do without swap, and if you have 512 MB of ram or more, you won't normally miss it. If you have less memory, your system might want to use swap if it's available.
_________________
Please add [solved] to the initial post's subject line if you feel your problem is resolved. Help answer the unanswered

talk is cheap. supply exceeds demand
Back to top
View user's profile Send private message
JB318
n00b
n00b


Joined: 26 Apr 2005
Posts: 27
Location: Tulsa, Oklahoma

PostPosted: Mon May 02, 2005 9:55 pm    Post subject: tmpfs Reply with quote

Also, Google for "tmpfs". It lets you keep your temporary files in memory, spilling over to swap if there's not enough free RAM. (In essence, it's a ramdisk in virtual memory... don't think about that too hard if you start to get a headache. :wink:)

I have a tmpfs mounted on /tmp on my box, with a symlink /var/tmp -> /tmp, and it works great for me. The symlink is to allow Portage to compile things in memory, so temporary files don't touch disk at all. (It's also possible to tell Portage where to put temporary files other than /var/tmp, without needing a symlink; maybe I'm just lazy.) The only thing I have to watch for is I need to add a swapfile to increase my available swap, and remount to increase both size= and nr_inodes=, if I recompile OpenOffice.org from source.

I've heard it said, though, that once you start using swap space for your compiles, that a dedicated ext2 partition (not ext3--no journalling needed for a temporary filesystem) is faster than tmpfs. But if you've got enough RAM to hold everything that's going on, or nearly so, tmpfs is a net win.

-- JB318
_________________
"The life of every man is a diary, in which he means to write one story, and writes another."
-- _Cheers For Miss Bishop_ (1941)
Back to top
View user's profile Send private message
sloppy
n00b
n00b


Joined: 25 Jan 2003
Posts: 34
Location: Albuquerque, NM USA

PostPosted: Sat May 07, 2005 12:55 am    Post subject: Re: tmpfs Reply with quote

As an old Amiga RAMdisk user, I think tmpfs is a really neat thing. But I've found that I use /tmp for so much stuff (more than just OpenOffice compiles -- though that takes a big hit too) that there just isn't quite enough address space (regardless of how much RAM and swap I have) on a 32-bit system, to be able to rely on tmpfs for everything. But now that AMD has made 64-bit addressing so affordable, I see a VERY bright future for tmpfs.
_________________
Have a Sloppy day!
Back to top
View user's profile Send private message
JB318
n00b
n00b


Joined: 26 Apr 2005
Posts: 27
Location: Tulsa, Oklahoma

PostPosted: Sat May 07, 2005 1:01 am    Post subject: Re: tmpfs Reply with quote

sloppy wrote:
As an old Amiga RAMdisk user, I think tmpfs is a really neat thing. But I've found that I use /tmp for so much stuff (more than just OpenOffice compiles -- though that takes a big hit too) that there just isn't quite enough address space (regardless of how much RAM and swap I have) on a 32-bit system, to be able to rely on tmpfs for everything. But now that AMD has made 64-bit addressing so affordable, I see a VERY bright future for tmpfs.


Wow... how did you know you were out of address space?? I've run out of space allocated to the tmpfs before (which requires mounting with size= set however big I need it) and I've run out of inodes before (ditto on nr_inodes=) but I've never seen any errors pertaining to "address space"...

-- JB318
_________________
"The life of every man is a diary, in which he means to write one story, and writes another."
-- _Cheers For Miss Bishop_ (1941)
Back to top
View user's profile Send private message
sloppy
n00b
n00b


Joined: 25 Jan 2003
Posts: 34
Location: Albuquerque, NM USA

PostPosted: Sat May 07, 2005 1:14 am    Post subject: Re: tmpfs Reply with quote

JB318 wrote:
Wow... how did you know you were out of address space?? I've run out of space allocated to the tmpfs before (which requires mounting with size= set however big I need it) ...

Well, I run out of address space, in the sense that my peak /tmp usage can exceed 4 Gigabytes. That's rare, but it happens. So I would need to be able to set tmpfs' size= mount parameter higher than the highest allowable value.

But that problem should totally go away if/when I heat up the plastic and buy some Opterons. :-) Until then, my /tmp is a conventional filesystems on a raid0. I don't really have any complaints about having to do that, but giving those hd partitions to swap and using tmpfs would be more elegant and efficient.
_________________
Have a Sloppy day!
Back to top
View user's profile Send private message
JB318
n00b
n00b


Joined: 26 Apr 2005
Posts: 27
Location: Tulsa, Oklahoma

PostPosted: Sat May 07, 2005 2:05 am    Post subject: Re: tmpfs Reply with quote

sloppy wrote:
Well, I run out of address space, in the sense that my peak /tmp usage can exceed 4 Gigabytes. That's rare, but it happens. So I would need to be able to set tmpfs' size= mount parameter higher than the highest allowable value.


:? I just added 4GB more swap, mounted a new tmpfs with size=5000m, and created a file with dd that was 4100MB in size (4,299,161,600 bytes). Not a peep from mount or from dd. ls and Perl's "-s" operator both report that the file is the exact size I wanted it to be--no silent truncation. df -H reports:

Code:
Filesystem             Size   Used  Avail Use% Mounted on
none                   5.3G   4.4G   940M  83% /home/root/tmp2


So evidently tmpfs not only supports more than 4GB, but it supports it in one large file. So I'm confused how you got different results. This was on kernel 2.6.11-gentoo-r6 with util-linux-2.12i-r1; what versions did you encounter this on?

(I added the swap by creating files in /home/root using dd. Then I swapon'd them and mounted the tmpfs, and created a file inside them using dd. I'm sure Douglas Hofstadter would be proud. :wink:)

sloppy wrote:
I don't really have any complaints about having to do that, but giving those hd partitions to swap and using tmpfs would be more elegant and efficient.


See my earlier comment. If the person I heard that from was right, then ext2 is in fact more efficient than tmpfs under load. But then, I guess with enough people like us actually using tmpfs the way it was intended (well, the way we think it should be intended), maybe we'll be able to help, or at least encourage, the pertinent kernel developers to make tmpfs more efficient.

-- JB318
_________________
"The life of every man is a diary, in which he means to write one story, and writes another."
-- _Cheers For Miss Bishop_ (1941)
Back to top
View user's profile Send private message
sloppy
n00b
n00b


Joined: 25 Jan 2003
Posts: 34
Location: Albuquerque, NM USA

PostPosted: Sat May 07, 2005 8:32 am    Post subject: Re: tmpfs Reply with quote

JB318 wrote:
I just added 4GB more swap, mounted a new tmpfs with size=5000m, and created a file with dd that was 4100MB in size (4,299,161,600 bytes). Not a peep from mount or from dd. ls and Perl's "-s" operator both report that the file is the exact size I wanted it to be--no silent truncation. df -H reports:

Code:
Filesystem             Size   Used  Avail Use% Mounted on
none                   5.3G   4.4G   940M  83% /home/root/tmp2


So evidently tmpfs not only supports more than 4GB, but it supports it in one large file. So I'm confused how you got different results. This was on kernel 2.6.11-gentoo-r6 with util-linux-2.12i-r1; what versions did you encounter this on?


Interesting! To tell the truth, I never really encountered a problem, it's just that I assumed that I would, so I never tried to create so much swap. It shouldn't work. I guess I misunderstood how tmpfs (or maybe even Linux itself) works, as I didn't think I could possibly have more than 4GB of total virtual memory. When you add all that swap, what does your /proc/meminfo look like?
_________________
Have a Sloppy day!
Back to top
View user's profile Send private message
JB318
n00b
n00b


Joined: 26 Apr 2005
Posts: 27
Location: Tulsa, Oklahoma

PostPosted: Sat May 07, 2005 8:58 am    Post subject: Re: tmpfs Reply with quote

sloppy wrote:
When you add all that swap, what does your /proc/meminfo look like?


This is readding the swap without remounting the tmpfs or anything:

Code:
MemTotal:       515592 kB
MemFree:          7648 kB
Buffers:          6060 kB
Cached:         334432 kB
SwapCached:       4460 kB
Active:         302072 kB
Inactive:       168276 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:       515592 kB
LowFree:          7648 kB
SwapTotal:     6194324 kB
SwapFree:      6176836 kB
Dirty:              24 kB
Writeback:           0 kB
Mapped:         165548 kB
Slab:            18276 kB
CommitLimit:   6452120 kB
Committed_AS:   194948 kB
PageTables:       1852 kB
VmallocTotal:   516020 kB
VmallocUsed:     13076 kB
VmallocChunk:   502184 kB


-- JB318
_________________
"The life of every man is a diary, in which he means to write one story, and writes another."
-- _Cheers For Miss Bishop_ (1941)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
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