# FreeBSD is safer without swap memory !



## javanunes (Jul 15, 2010)

I have a box running FreeBSD 7.2 with limits procs enable in login.conf and loader.conf.
when I run desktop KDE 4 and make a crash script code like this:

```
#!/bin/sh
$0&
kwrite
$0&
$0&
$0&
```

I exec it, many kwrite windows open, doing then almost to crash and freeze the system, I press ALT + F2, open xterm terminal and do `killall kwrite` this make system crash and reboot force shutdown.

But when I do `swapoff /dev/swap_device` my system not crash and not shutdown, i do killall in kwrite and sh and i have my system accepted my order nice, it not crash.

Swap on in FreeBSD then can vulnerable to explore security.

I have 1 GB RAM in box and it run very nice without swap.


----------



## Alt (Jul 15, 2010)

javanunes said:
			
		

> FreeBSD is safer without swap memory !
> Swap on in FreeBSD then can vulnerable to explore security.


You must get some more competent testing methodology before saying loud word...

Move swap to other disk i think its hw errror


----------



## mix_room (Jul 15, 2010)

Just encrypt your swap-space if you are worried about people reading important data from it. 

http://www.freebsd.org/doc/en/books/handbook/swap-encrypting.html


----------



## dennylin93 (Jul 15, 2010)

A lot of people use FreeBSD with swap, and people rarely complain about problems, so you might want to look for other possibilities.


----------



## javanunes (Jul 16, 2010)

Any server using FreeBSD with swap on is easy crash or shutdown do scripts loops, it is true.


----------



## Alt (Jul 16, 2010)

Give a script that crash it. I have only 512M i can test if this bug is really present =)
I have seen situations where freebsd kills most heavy process if its really looping/eating all memory


----------



## javanunes (Jul 16, 2010)

mix_room said:
			
		

> Just encrypt your swap-space if you are worried about people reading important data from it.
> 
> http://www.freebsd.org/doc/en/books/handbook/swap-encrypting.html



Swap encrypted do it to freezer when run script, It no shutdown, no rebooting but no answering any more.


----------



## javanunes (Jul 16, 2010)

*See Video in Youtube with the crash*

The my crash box script video
http://www.youtube.com/watch?v=Z9gS1P7Xtnc

See


----------



## Alt (Jul 16, 2010)

I have 512M RAM and kde4(with some programs running) not work at all without swap (reboots). Note i have big swap partition (really big).

Just tried your script. With swap it lives about 3min and then reboot. /var/log/messages:
	
	



```
Jul 16 11:04:14  kernel: Approaching the limit on PV entries, consider increasing either the vm.pmap.shpgperproc or the vm.pmap.pv_entry_max tunable.
Jul 16 11:04:14  kernel: panic: get_pv_entry: increase vm.pmap.shpgperproc
Jul 16 11:04:14  kernel: cpuid = 1
```
Without swap, about 30 secs and total freeze. /var/log/messages:
	
	



```
Jul 16 11:10:11  kernel: pid 1246 (Xorg), uid 0, was killed: out of swap space
```
Note that Xorg is not killed, system freezed.

I dont know what is better, i belive on server reboot is better than freeze. But, problem is repeatable.. Seems kernel is out of process descriptors or somewhat like this..


----------



## javanunes (Jul 16, 2010)

Alt said:
			
		

> I have 512M RAM and kde4(with some programs running) not work at all without swap (reboots). Note i have big swap partition (really big).
> 
> Just tried your script. With swap it lives about 3min and then reboot. /var/log/messages:
> 
> ...



Your accounting_enable="YES" is enabled in rc.conf?
Your maxproc is enabled for 599 process ?
If maxproc is limited and swapoff, it no reboot and no freeze.

See my limits:

```
Resource limits (current):
  cputime          infinity secs
  filesize          4194304 kB
  datasize          1048576 kB
  stacksize           65536 kB
  coredumpsize     infinity kB
  memoryuse        infinity kB
  memorylocked     infinity kB
  maxprocesses          599
  openfiles            1198
  sbsize           infinity bytes
  vmemoryuse       infinity kB
```

my loader.conf have the line:

```
kern.maxproc="666"
```
it would not have reboot or freeze


----------



## Alt (Jul 16, 2010)

I had default config about accounting and sysctls


----------



## vivek (Jul 16, 2010)

Do you see any errors or log messages in files or core files? Sure there is a limit on how much you can put on everything and that is why we have clusters and powerful cpu that can support gig load of RAM. However,swap space is not your problem, you are running out of resources and it can be tracked with logs files or core dumps only.


----------

