[SOLVED] tmp is not using swap space

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post please read this

[SOLVED] tmp is not using swap space

Postby Emerson Prado on Wed Oct 31, 2012 3:30 pm

(I first posted this in the Newbie forum but, after STFW, I realized this is all but a newbie question, so I'm moving it here)

Hi all,
I'm trying to watch a big video in Firefox, but video download always stops at around 300MB. I noticed that's what's available in /tmp:

Code: Select all
me@host ~ $ df -h | grep tmp
tmpfs                                                   151M  372K    151M   1% /run
tmpfs                                                   5,0M     0    5,0M   0% /run/lock
tmpfs                                                   302M   32K    302M   1% /tmp
tmpfs                                                   302M     0    302M   0% /run/shm


When I start loading the video, the memory usage under /tmp goes up and up until it reaches 100%, then the video stops downloading. After searching for a while, I learned that tmpfs will use RAM first (if I got it correctly, the 302MB in /tmp), then going for swap space. But it seems not to be using my swap space.
Swap space seems to be correctly mounted and activated:

Code: Select all
me@host ~ $ sudo swapon -s
[sudo] password for me:
Filename            Type      Size   Used   Priority
/dev/sda2                               partition   1930236   176   -1
/dev/sdb2                               partition   2097148   0   -2
me@host ~ $ free
             total       used       free     shared    buffers     cached
Mem:       1545820    1436728     109092          0      59808     421548
-/+ buffers/cache:     955372     590448
Swap:      4027384        156    4027228


/etc/fstab also seems to match UUIDs:

Code: Select all
me@host ~ $ sudo blkid
/dev/sda2: LABEL="Swap Linux" UUID="0f9485ef-0fbc-4233-a48f-3db50e2eb654" TYPE="swap"
/dev/sdb1: LABEL="Arquivos" UUID="bc178dac-2204-4d25-8b5f-4cbd91d6446f" TYPE="ext4"
/dev/sdb2: LABEL="Swap Linux" UUID="b2f74e85-0453-418f-bf08-37ec376d363a" TYPE="swap"
/dev/sda1: UUID="67fa5754-e3ad-47cf-b88a-0b76f00577dd" TYPE="ext4"
me@host ~ $ cat /etc/fstab
(Comments - removed for clarity)
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# /dev/sda1   /   ext4   rw,errors=remount-ro      0   0
UUID=67fa5754-e3ad-47cf-b88a-0b76f00577dd   /   ext4   rw,errors=remount-ro      0   0
proc            /proc           proc    defaults        0       0
# /dev/sda1   /   ext3   errors=remount-ro   0   1
UUID=67fa5754-e3ad-47cf-b88a-0b76f00577dd   /   ext3   errors=remount-ro   0   1
# swap was on /dev/sda5 during installation
UUID=0f9485ef-0fbc-4233-a48f-3db50e2eb654   none            swap    sw              0       0
# /dev/sdb2   none   swap   sw            0   0
UUID=b2f74e85-0453-418f-bf08-37ec376d363a   none   swap   sw      00
/dev/scd0       /media/cdrom0   udf,iso9660 user,noauto      0   0
/dev/fd0        /media/floppy0  auto    rw,user,noauto     0       0
proc      /proc   proc   nodev,noexec,nosuid      0   0
# /dev/sdb1   /home   ext4   defaults,errors=remount-ro   0   2
UUID=bc178dac-2204-4d25-8b5f-4cbd91d6446f   /home   ext4   defaults,errors=remount-ro   0   2
(LAN drives - removed for clarity)
cgroup      /cgroup   cgroup   defaults


First of all, are my assumptions above correct? That is: fstab is properly indicating my swap drives, swap is correctly mounted and activated and tmps should be but isn't using swap. Then, why am I not able to use more virtual memory for downloading the video?
I read suggestions on moving Firefox cache to a directory in the hard drive, but this would make it quite slower for not so huge files. I also read directions to increase the /tmp RAM file, but I'm afraid this would make other stuff suffer on lack of RAM (plus it involves creating scripts I'm not comfortable with yet).
What can I do?

Some more info:

Code: Select all
me@host ~ $ inxi
CPU[-Single core Intel Pentium 4 (-HT-) clocked at 3000.006 Mhz-] Kernel[-3.2.0-3-686-pae i686-] Up[-1:00-] Mem[-929.7/1509.6MB-] HDD[-180.1GB(61.8% used)-] Procs[-129-] Client[-Shell-] inxi[-1.4.23-]
me@host ~ $ sudo dpkg-query -s firefox | grep Version
Version: 14.0.1


Thanks,
Emerson
Last edited by Emerson Prado on Thu Nov 01, 2012 8:54 am, edited 1 time in total.
Emerson Prado
Level 1
Level 1
 
Posts: 37
Joined: Thu Nov 04, 2010 1:42 pm

Linux Mint is funded by ads and donations.
 

Re: tmp is not using swap space

Postby xenopeek on Wed Oct 31, 2012 3:53 pm

AFAIK if tmpfs is set to 302 MiB size then it would never use more than that. The tmpfs filesystem shrinks and grows as needed, but you have set it to a limit of 302 MiB so it will never grow beyond that. It will swap out pages when not enough RAM is available to have 302 MiB, but never more than the 302 MiB size limit you have configured. If you want /tmp to be bigger than 302 MiB, make it so.

Looking at your fstab, I can't see how you have configured /tmp to be tmpfs? Perhaps this is something done automatically by LMDE? You should be able to add an entry to fstab to override any LMDE defaults. For example as such to give it a 500 MiB size limit:
Code: Select all
none /tmp tmpfs nodev,nosuid,mode=1777,size=500M 0 0

Perhaps it would be easier to download the video instead 8)

Also note this weird bit in your fstab. Make up your mind, is /dev/sda1 ext4 or ext3? :) It seem faulty, especially as the first entry to mount /dev/sda1 is not doing a fsck.
# /dev/sda1 / ext4 rw,errors=remount-ro 0 0
UUID=67fa5754-e3ad-47cf-b88a-0b76f00577dd / ext4 rw,errors=remount-ro 0 0
proc /proc proc defaults 0 0
# /dev/sda1 / ext3 errors=remount-ro 0 1
UUID=67fa5754-e3ad-47cf-b88a-0b76f00577dd / ext3 errors=remount-ro 0 1

Edit: looking at the blkid output it is ext4. So delete the second entry for /dev/sda1 (the ext3 one), and replace the final 0 (zero) on the first entry for /dev/sda1 (the ext4 one) to 1 (one) to indicate you want fsck to check this filesystem on boot.
Forum Rules | IRC Channel Rules
Image
Arch Linux / 64-bit / Gnome Shell
User avatar
xenopeek
Level 21
Level 21
 
Posts: 13692
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: tmp is not using swap space

Postby Emerson Prado on Wed Oct 31, 2012 4:44 pm

Yes, this is all automatically done by LMDE. I'm not much experienced in Linux, so I don't mess too much on things unless I have a problem.
So the problem is that tmpfs was limited by the system defaults. So it would never grow enough to use swap, even when required to grow more.
I learned that I can set limits for /tmp (and other directories mounted as tmpfs, like /run, /run/lock or /run/shm) in fstab, but this is an option. There's another way to set those limits, and also the global tmpfs limit. They are spec'ed in /etc/default/tmpfs (deprecated, so I'll probably use fstab in the future):

Code: Select all
me@host /etc/default $ cat tmpfs | grep SIZE=
...
TMPFS_SIZE=30%
RUN_SIZE=10%
LOCK_SIZE=5242880 # 5MiB
SHM_SIZE=
TMP_SIZE=


The "TMPFS_SIZE" variable sets the global limit, and was set to 20%. Since I have 1.5GiB of RAM, then my global tmpfs size was 302MiB, less than the video size.
I ran top with lots of apps opened (including VirtualBox and Firefox with several tabs open) and saw I still had almost 200MiB of free RAM. So I changed the global tmpfs limit to 30% as shown above. Rebooted (since I don't know how to restart tmpfs) and watched the video without problems.

As for the weird inputs in fstab: man, I had double inputs for both /dev/sda1 and /proc! Commented out the wrong /dev/sda1 line and corrected the fsck argument as you said. Do you have a hint on how to tell which of the /proc lines is correct? Only the mount options are different:

Code: Select all
me@host /etc/default $ cat /etc/fstab | grep proc
proc      /proc   proc   defaults   0   0
proc      /proc   proc   nodev,noexec,nosuid      0   0


Thanks a lot,
Emerson
Emerson Prado
Level 1
Level 1
 
Posts: 37
Joined: Thu Nov 04, 2010 1:42 pm

Re: tmp is not using swap space

Postby xenopeek on Wed Oct 31, 2012 5:32 pm

The second line is correct; you want the nodev,noexec,nosuid options.
Forum Rules | IRC Channel Rules
Image
Arch Linux / 64-bit / Gnome Shell
User avatar
xenopeek
Level 21
Level 21
 
Posts: 13692
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: tmp is not using swap space

Postby Emerson Prado on Thu Nov 01, 2012 8:54 am

Thanks a lot!
Emerson Prado
Level 1
Level 1
 
Posts: 37
Joined: Thu Nov 04, 2010 1:42 pm


Return to Other Topics

Who is online

Users browsing this forum: No registered users and 3 guests