LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 09-30-2009, 02:09 PM   #1
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,512
Blog Entries: 27

Rep: Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174
To have swap or not to have swap?


Hello

Given adequate RAM to avoid the need for any swapping (4 GB and no memory-intensive processes AFAIK) what are the benefits, risks, costs etc. of having swap and not having swap?

Best

Charles
 
Old 09-30-2009, 02:37 PM   #2
rg3
Member
 
Registered: Jul 2007
Distribution: Slackware Linux
Posts: 498

Rep: Reputation: Disabled
If you want to hibernate, set up a swap partition. That's the most common reason to have one. On the other hand, if you hit the memory limit and you don't have swap, some process will crash or be killed.
 
Old 09-30-2009, 02:39 PM   #3
Ilgar
Member
 
Registered: Jan 2005
Location: Istanbul, Turkey
Distribution: Slackware 14.1, Slackware64 14.1
Posts: 916

Rep: Reputation: 87
It doesn't hurt to have swap, unless you're short of disk space. Risks? If swap gets used, anything stored in the memory in unencrypted form may get written on the swap partition, but honestly I don't know of any cases where somebody stole sensitive information this way. Still, there's a workaround for that, for example I'm using LUKS encryption on my /home, /tmp and swap partitions.

Benefits: Suspend to disk ability, emergency space for unforeseen RAM shortages...
 
Old 09-30-2009, 02:48 PM   #4
windtalker10
Member
 
Registered: Nov 2007
Location: Kentucky
Distribution: Slackware13.1
Posts: 214

Rep: Reputation: 38
I have 2 gigs of ram and prefer the kde3.5 desktop.
I tried running with no swap at one time just to see.
Everything ran fine but was noticeably slower, especially the boot process.
How 4 gigs of ram would run with no swap, dunno but would probably be fine as long as you're not hibernating or using some really graphics intensive builders or programs.
 
Old 09-30-2009, 03:48 PM   #5
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
AFAIK, while I still make them out of habit, there are virtually no advantages to a swap partition. As others have mentioned, you can benefit from having swap if you hibernate or if you have something go wild and need to go into swap to avoid resource starvation, but you can just make a swapfile for that. The big knock against swapfiles was that they were slower but, as I understand it, things have changed such that the performance difference is negligible. The only thing is you can just separate your swap from your actual fs and forget about it. A swapfile might get in the way. But a swapfile, with most any filesystem, is going to be more flexible. Repartitioning is a pain and resizing, where possible, isn't much better.

For the file, I think it's still
Code:
dd if=/dev/zero of=YOURFILE bs=1k count=YOURSIZE
mkswap YOURFILE
sync
swapon YOURFILE
and add it to fstab like any device.

So if you don't hibernate and think your system won't go haywire and you don't want swap, you can try going without. If anything Bad Happens, you can create a swapfile to prevent that happening again. Or you can just be safe and conservative and keep making swap partitions that never get used for anything.

If I'm wrong in any of this, particularly regarding the efficiency of modern swap files, someone please correct me.
 
Old 09-30-2009, 06:35 PM   #6
rigelan
Member
 
Registered: Jul 2005
Location: Iowa
Distribution: Slackware
Posts: 171

Rep: Reputation: 19
I haven't used a swap partition on my personal computer in the last 4 years. I use my 2 GB ram to run fluxbox as a window manager and KDE control programs. I have had no speed issues or issues in general. Then again, I don't hibernate.

I suppose you might come across an issue in video or image editing where the image is too big.
 
Old 10-01-2009, 03:53 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,512
Blog Entries: 27

Original Poster
Rep: Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174
Hello

Thanks to all for replies Summarising:

For swap
  • Enables hibernation. Not significant if hibernation not required.
  • Increases virtual memory space. Not significant if more than enough RAM.
Against swap
  • Needs disk space. Not significant if plenty of disk space.
  • Makes some memory content visible. Not significant if privacy not required. Fix by encrypting swap.
Performance is not an issue as it once was, when significant performance increases reported when running without swap, at least for some other distros.

Best, Charles

Last edited by catkin; 10-01-2009 at 03:54 AM. Reason: Added "Not significant if hibernation not required."
 
Old 10-01-2009, 09:04 AM   #8
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266Reputation: 1266
Here's probably the best option for you, and it's what I do now. Just don't make a swap partition and run the system without any swap. If you have problems, you can quickly and easily make a swap file and use it as swap. Then later on, if you realize you do not need it, you can just turn off swap, delete the file and that's it.

See here for more on swap files:
http://tldp.org/HOWTO/Partition/setting_up_swap.html
 
Old 10-01-2009, 09:31 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,512
Blog Entries: 27

Original Poster
Rep: Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174
Thanks H_TeXMeX_H

That's a sweet solution (already suggested by slakmagik), a least cost "suck-it-and-see" approach.

I'm going to go for the swap partition for hibernation, even though it's not for a laptop. It appeals for environmental reasons -- I'd forgotten about hibernation 'cos it never worked on ubuntu but hopefully it "just works" on Slackware and the penguins will benefit from the reduced polution.
 
  


Reply

Tags
slackware13, swap


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can swap file or a swap partition be mounted and read? Mr-Bisquit Linux - General 3 06-08-2009 02:16 PM
SWAP - having trouble with swap auto mounting at boot lostdj Linux - General 2 08-05-2008 12:47 PM
Linux swap / solaris not appearing as swap in Ubuntu? Erik_the_Red Linux - Newbie 1 07-30-2005 12:57 PM
How to unmount actual swap and mount a new(bigger) swap space? isaac Linux - Newbie 1 06-06-2004 01:23 AM
Difference between Swap Virtrual memory and Swap Parition Nappa Slackware 4 11-27-2003 07:58 PM


All times are GMT -5. The time now is 11:14 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration