You are not logged in.

#1 2009-08-23 07:21:40

guzz46
Member
From: New Zealand
Registered: 2009-06-18
Posts: 190

tmpfs not using swap [Solved]

i have set up /tmp as tmpfs for compiling but i get errors when i run out of memory, i was under the assumption that when tmpfs runs out of memory it uses swap space but swap never gets used even when swappiness is set to 100

 df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              19G  729M   18G   4% /
none                  1.9G  1.8M  1.9G   1% /dev/shm
none                  1.9G  864M  983M  47% /tmp
none                   10M  332K  9.7M   4% /var/log
none                   10M   44K   10M   1% /var/run
none                   10M     0   10M   0% /var/lock
/dev/sda2              19G  1.6G   17G   9% /usr
/dev/sda3             185G  3.1G  172G   2% /home
mount
/dev/sda1 on / type ext4 (rw,noatime)
none on /dev type ramfs (rw,relatime)
none on /proc type proc (rw,relatime)
none on /sys type sysfs (rw,relatime)
none on /dev/pts type devpts (rw)
none on /dev/shm type tmpfs (rw)
none on /tmp type tmpfs (rw)
none on /var/log type tmpfs (rw,size=10m)
none on /var/run type tmpfs (rw,size=10m)
none on /var/lock type tmpfs (rw,size=10m)
/dev/sda2 on /usr type ext4 (rw,noatime)
/dev/sda3 on /home type ext4 (rw,noatime)
free
             total       used       free     shared    buffers     cached
Mem:       3780388    1494456    2285932          0      42884    1084512
-/+ buffers/cache:     367060    3413328
Swap:      8000360          0    8000360

Last edited by guzz46 (2009-08-23 23:51:48)

Offline

#2 2009-08-23 10:53:49

keenerd
Package Maintainer (PM)
Registered: 2007-02-22
Posts: 647
Website

Re: tmpfs not using swap [Solved]

guzz46 wrote:

i have set up /tmp as tmpfs

I do not think you do.  No where in your mount stats do I see a tmpfs.

Here's mine:

df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2             7.3G  6.7G  359M  95% /
none                  886M     0  886M   0% /dev/shm
tmpfs                 886M   24M  862M   3% /tmp

mount

/dev/sda2 on / type ext2 (rw,noatime)
none on /dev type ramfs (rw,relatime)
none on /proc type proc (rw,relatime)
none on /sys type sysfs (rw,relatime)
none on /dev/pts type devpts (rw)
none on /dev/shm type tmpfs (rw)
none on /ram type ramfs (rw,nosuid,nodev)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev)

And here is the relevant line from my fstab:
    tmpfs        /tmp        tmpfs    nosuid,nodev        0 0

Could you post your /etc/fstab?

Last edited by keenerd (2009-08-23 10:54:21)

Offline

#3 2009-08-23 11:16:24

guzz46
Member
From: New Zealand
Registered: 2009-06-18
Posts: 190

Re: tmpfs not using swap [Solved]

# /etc/fstab: static file system information
#
# <file system>        <dir>         <type>    <options>          <dump> <pass>
none                   /dev/pts      devpts    defaults            0      0
none                   /dev/shm      tmpfs     defaults            0      0
none                   /tmp          tmpfs     defaults            0      0
none                   /var/log      tmpfs     defaults,size=10m   0      0
none                   /var/run      tmpfs     defaults,size=10m   0      0
none                   /var/lock     tmpfs     defaults,size=10m   0      0

#/dev/cdrom             /media/cd   auto    ro,user,noauto,unhide   0      0
#/dev/dvd               /media/dvd  auto    ro,user,noauto,unhide   0      0
#/dev/fd0               /media/fl   auto    user,noauto             0      0

/dev/sda1 / ext4 defaults,noatime 0 1
/dev/sda2 /usr ext4 defaults,noatime 0 2
/dev/sda3 /home ext4 defaults,noatime 0 2
/dev/sda4 swap swap defaults 0 0

do you have to specify tmpfs instead of none under file system?

Edit: i also tried

# /etc/fstab: static file system information
#
# <file system>        <dir>         <type>    <options>          <dump> <pass>
none                   /dev/pts      devpts    defaults            0      0
tmpfs                  /dev/shm      tmpfs     defaults            0      0
tmpfs                  /tmp          tmpfs     defaults            0      0
tmpfs                  /var/log      tmpfs     defaults,size=10m   0      0
tmpfs                  /var/run      tmpfs     defaults,size=10m   0      0
tmpfs                  /var/lock     tmpfs     defaults,size=10m   0      0

#/dev/cdrom             /media/cd   auto    ro,user,noauto,unhide   0      0
#/dev/dvd               /media/dvd  auto    ro,user,noauto,unhide   0      0
#/dev/fd0               /media/fl   auto    user,noauto             0      0

/dev/sda1 / ext4 defaults,noatime 0 1
/dev/sda2 /usr ext4 defaults,noatime 0 2
/dev/sda3 /home ext4 defaults,noatime 0 2
/dev/sda4 swap swap defaults 0 0
mount
/dev/sda1 on / type ext4 (rw,noatime)
none on /dev type ramfs (rw,relatime)
none on /proc type proc (rw,relatime)
none on /sys type sysfs (rw,relatime)
none on /dev/pts type devpts (rw)
tmpfs on /dev/shm type tmpfs (rw)
tmpfs on /tmp type tmpfs (rw)
tmpfs on /var/log type tmpfs (rw,size=10m)
tmpfs on /var/run type tmpfs (rw,size=10m)
tmpfs on /var/lock type tmpfs (rw,size=10m)
/dev/sda2 on /usr type ext4 (rw,noatime)
/dev/sda3 on /home type ext4 (rw,noatime)

but nothings changed, i'm sure it's a tmpfs because /tmp reads 1.9gb and everythings in there is gone after a reboot but it still doesn't use swap as backup

Last edited by guzz46 (2009-08-23 12:38:43)

Offline

#4 2009-08-23 19:26:31

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: tmpfs not using swap [Solved]

I don't think it makes any real difference what you put in the device column when fstype=tmpfs. That just shows up in some error messages and messages to the user, for example the output of "mount." Do

man mount

and search for "proc" to see what this impression is based on. (Also, in my experience, it seems not to affect anything.)

Offline

#5 2009-08-23 19:42:34

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

Re: tmpfs not using swap [Solved]

Perhaps you would prefer to use:

mount -o remount,size=3G /

This will give you all the ram available up to 3G max.


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

#6 2009-08-23 20:48:07

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: tmpfs not using swap [Solved]

lilsirecho wrote:

Perhaps you would prefer to use:

mount -o remount,size=3G /

This will give you all the ram available up to 3G max.

Yes, or you could put the size=3G (or whatever) in the options column of your fstab. Whatever you declare here is the maximum size of the tmpfs disk. It will only actually take up as much space as it needs, and will grow automatically up to that size. If you don't declare any max size, I think it defaults to 1/2 your physical ram. You're probably not using any swap because your ram is able to accommodate your entire tmpfs up to its (implicit) max size. Make the max size bigger, and then fill the tmpfs enough/put enough other demands on your ram, and you should see swap start to get used.

Offline

#7 2009-08-23 23:15:36

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: tmpfs not using swap [Solved]

I agree with Profjim, it seems that your ram is able to accommodate the space you have allocated for tmpfs so it doesn't run out of ram and doesn't use swap, try using some value that that exceeds the ram you have (by a reasonably small amount) and try to fill your /tmp and check if it uses swap.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#8 2009-08-23 23:51:06

guzz46
Member
From: New Zealand
Registered: 2009-06-18
Posts: 190

Re: tmpfs not using swap [Solved]

yea i just tried that and it worked, i set /tmp as 8gb (twice as much ram as i actually have) as an experiment and it used swap for the first time, thanks
now i'm not sure what size to make /tmp, i have 4gb of ram and an 8gb swap.

Offline

#9 2009-08-24 00:20:12

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: tmpfs not using swap [Solved]

It depends on what you're going to be saving in /tmp. A few text files? Torrents?

Why not just stay with the default for now, and when you find you need more, do what lilsirecho said:

lilsirecho wrote:

Perhaps you would prefer to use:

mount -o remount,size=3G /

This will give you all the ram available up to 3G max.

Over time you'll figure out what's the best setting for your usage, and you can update your fstab so you don't need to remount by hand.

Offline

#10 2009-08-24 00:42:56

guzz46
Member
From: New Zealand
Registered: 2009-06-18
Posts: 190

Re: tmpfs not using swap [Solved]

It depends on what you're going to be saving in /tmp. A few text files? Torrents?

i mainly use it for compiling, some things can be quite large though so i might leave it at 8gb and see how it goes, nothing worse than spending an hour compiling something then getting a "no space left on device error"

Offline

Board footer

Powered by FluxBB