# swap size



## varda (Apr 12, 2009)

Hello Gentlemen!

I have FreebBSD 7.1 powered server which acts as a corporate data/documents storage for a small company, 30 users/workstations. Usual Internet stuff, web site, mail hub, mail web interface, ftp, samba PDC for windows client and so on. It equipped with 8GB of memory, Intel 2-port 1000Mbit NIC, two qmirrored 1TB HDDs.

So I'm interesting how to choose a swap size. I've tried it equal to RAM size (i.e. 8GB) and completely without swap partition. But I have not noticed use of swap at my usual load in pair dozens of clients simultaneously. Also I did not noticed lack of memory in the same situation even at full absence of a swap.

It is possible to remove it completely? Keep it as crash dump device? Are there any recommendations on the swap size?

Thank You.


----------



## trev (Apr 13, 2009)

This has been covered in some depth previously. You can find the  last discussion here: http://forums.freebsd.org/showthread.php?t=1561

The forum search feature will no doubt help you find others.


----------



## graudeejs (Apr 13, 2009)

trev said:
			
		

> This has been covered in some depth previously. You can find the  last discussion here: http://forums.freebsd.org/showthread.php?t=1561
> 
> The forum search feature will no doubt help you find others.



since that thread, I've seen Fosdem 2009: My system is slow
http://fosdem.unixheads.org/2009/maintracks/my_system_is_slow.xvid.avi

It's very interesting movie about system performance.


On of interesting things was swap based /tmp.
So i tried and implemented it. I also did some tests with gstat.

It was interesting that at first it was writing to memory, and then to swap. and since i had swap split to 2 disks, it was writing about the same amount in each of them (I knew about this in theory, but now I have seen myself)

In then end i made 2x9G swap
and made 14G /tmp and i feel pretty happy about it 

I will post my entry in fstab (and in /etc/rc.conf if i have one) when i get home (later today)


----------



## graudeejs (Apr 13, 2009)

/etc/fstab :

```
md /tmp mfs rw,[color="Red"]-s14336m[/color],[color="Lime"]-oasync[/color],[color="SandyBrown"]-onoatime[/color],-S,[color="MediumTurquoise"]-Otime[/color] 0 0
```


Size of /tmp
Asynchronous
Optimize for speed
Don't want to record access time


----------



## Djn (Apr 13, 2009)

Kind of like having /tmp on a RAID0 with an extremely aggressive caching policy.


----------



## varda (Apr 13, 2009)

Thank you for your posts and provided links Gentelmen.

I've visited links and made a decision. Just have left for any emergency cases 2G swap spreaded across two HDDs.

killasmurf86, interesting idea with /tmp on swap. Thanks for tip.


----------



## hedwards (Apr 14, 2009)

I'd consider just making it at least equal to the amount of RAM. Not because it's necessarily needed, but because it allows you to dump the kernel if there's ever a panic.

You might not want to do that if there's likely to be sensitive information in the dump, but it's nice to have the option if need be so that the panic can be fixed.


----------



## graudeejs (Apr 14, 2009)

I don't believe anyone will want to debug my 2GB dump


----------



## varda (Apr 16, 2009)

hedwards, yes I'm keeping in mind about crash/paninc dumps.

I asked about usual practice but not about extreme cases of debugging kernel crashes. From several years of experience with FreeBDS, I was interested in the exploration of kernel dumps just a few times. If I will encounter problems with the kernel or want to explore something I'll simply add separate disk entirely for swap partition.

There was question about usual practice and as I saw in links of posters many of them also used not so huge swap.

It's not a problem for me because I've enough disk space. Also I understand that it depends of load, situation and purpose. But in my conditions swap practically not used.

Thanks to all responders.


----------



## graudeejs (Apr 18, 2009)

I used to use 0M swap... until one day.... i ran some thing like
*convert *.pjg ....*

somehow i ran out of memory (and i have 2GB of it) and X chrashed

after that i used 128M swap....
Usually my swap was used max 64K


----------

