LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices

Reply
 
Search this Thread
Old 11-09-2010, 10:55 AM   #16
dougunder
LQ Newbie
 
Registered: Nov 2010
Location: Massachusetts
Distribution: gentoo
Posts: 8

Rep: Reputation: 0

I haven't had a swap partition in a long while.

I recently started using hibernation, and simply made a swap file.

dd if=/dev/zero of=/var/swap bs=1M count=2048 and add it to fstab.

So no, a dedicated swap partition is not needed, though it could be advantageous.
 
Old 11-16-2010, 08:54 AM   #17
Willrandship
Member
 
Registered: Oct 2009
Location: Utah
Distribution: Debian Testing (Wheezy atm.)
Posts: 109

Rep: Reputation: 17
Why not have a swap? In my mind, it's an easy way to reduce memory-related crashes. My 1G computer had a noticeable difference with rather than without, even though it's never reported as being "used" You probably won't need as much as you used to have, though.
 
Old 11-16-2010, 09:08 AM   #18
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,528
Blog Entries: 27

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by dougunder View Post
I haven't had a swap partition in a long while.

I recently started using hibernation, and simply made a swap file.

dd if=/dev/zero of=/var/swap bs=1M count=2048 and add it to fstab.
Why did you zero it out?
 
Old 11-16-2010, 12:53 PM   #19
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
Quote:
Originally Posted by catkin View Post
Why did you zero it out?
That is the standard way of creating a swap file:
http://tldp.org/LDP/sag/html/swap-space.html

It must be done with dd, because it must be contiguous = not fragmented.
 
1 members found this post helpful.
Old 11-16-2010, 09:14 PM   #20
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,528
Blog Entries: 27

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Thanks H_TeXMeX_H Good to know.
 
Old 11-17-2010, 07:01 AM   #21
teebones
Member
 
Registered: Aug 2005
Location: /home/teebones
Distribution: sometimes this, sometimes that..
Posts: 500

Rep: Reputation: 56
anyway, the answer to the original question is: Yes.. you can install linux without a swap partition/file. But.. there are strings attached when doing so.
 
Old 11-18-2010, 10:09 AM   #22
dougunder
LQ Newbie
 
Registered: Nov 2010
Location: Massachusetts
Distribution: gentoo
Posts: 8

Rep: Reputation: 0
Quote:
Originally Posted by Willrandship View Post
Why not have a swap? In my mind, it's an easy way to reduce memory-related crashes. My 1G computer had a noticeable difference with rather than without, even though it's never reported as being "used" You probably won't need as much as you used to have, though.
Basically cause I'm an experimenter

After never seeing any swap usage in the lifetime of my last pc(1g ram), i thought why not give it a go not using it on the new setup (2g)

After more that a year with no memory related crashes, even with all night compiles (i run gentoo) I've come to the conclusion that it's not necessary on modern desktop systems.

I need to play around with suspend2, once i have suspend to file working, I'll take swap support back out of my kernel as i notice a not insignificant performance increase without it. I should add I'm a little obsessed with efficient computing, my way of doing things may not work as well with a standard distro.
 
Old 11-18-2010, 11:19 AM   #23
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,036

Rep: Reputation: 372Reputation: 372Reputation: 372Reputation: 372
First thing is that rules of thumb are never valid. Just like measuring things in inches (until someone decided to regulate what exactly a metric "inch" is). That's because the size of the thumb vary from one person to the next one.

Jokes aside, there can be a number of situations where the kernel will be happy to have some swap space, and it in fact increases system performance, it doesn't reduce it.

For example, imagine this case where you have a thousand web sites open in firefox, probably some of them are two days old and you won't ever go back into these sites. You are just too lazy to close them. If you have no swap they are into RAM, such RAM can probably be better used as cache memory for files and data structures, and having these in RAM will actually improve the system responsiveness and performance. But you can't have as much data in RAM unless you actually have a place to page out all the firefox cruft (just an example).

Another detail is that if there's swap and you start running out of RAM the performance degradation can server as an alarm: it's time to save some data and close stuff, or maybe look at top and kill some buggy thing. If you don't have swap space there's no alarm. You will only notice you are out of virtual memory when the OOM killer shutdown any random program (or hopefully the right one) and you lose all the data you've been working on the last hour.

Right, probably 99% of the time you don't need swap. The right question is: does it really do any harm to have an sparse file (yes, you read well, you don't even have to bother with a partition if that angers you) of a couple GB's on an HD nowadays? The answer is "nope".

Last edited by i92guboj; 11-18-2010 at 11:33 AM.
 
Old 11-18-2010, 11:28 AM   #24
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,528
Blog Entries: 27

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by dougunder View Post
I'll take swap support back out of my kernel as i notice a not insignificant performance increase without it.
Have you taken measurements or is that an impression?
 
Old 11-24-2010, 04:55 PM   #25
athel.davis
LQ Newbie
 
Registered: Nov 2010
Posts: 5

Rep: Reputation: 0
To execute a program in Windows, it is require to be loaded into memory. Your Windows run multiple programs simultaneously and so many chances are that they won't all fit into memory at a same time. For that window has to swap all files one be one from memory to disk
and disk to memory.Wihout swap file swapping is not possible and without swapping window or linux can not run more than one programs at a same time.So swap file is so much important.
 
Old 11-24-2010, 05:17 PM   #26
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Gentoo
Posts: 15,411
Blog Entries: 2

Rep: Reputation: 3995Reputation: 3995Reputation: 3995Reputation: 3995Reputation: 3995Reputation: 3995Reputation: 3995Reputation: 3995Reputation: 3995Reputation: 3995Reputation: 3995
Quote:
Originally Posted by athel.davis View Post
without swapping window or linux can not run more than one programs at a same time.
Definitely not true. I can turn swap off on my systems, and run many programs, as long as they fit int my RAM. And with modern systems RAM sizes you can run many apps, before you run out off RAM, except of course you run really memory-hungry apps, like VMs or something.
 
Old 11-25-2010, 05:03 AM   #27
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Distribution: Mageia Studio-13.37 Kubuntu.
Posts: 3,325
Blog Entries: 33

Rep: Reputation: 199Reputation: 199
Yeah, I agree,

your swap and/or /tmp combination needs to be > (larger than) the largest file that

may require deleting without imposing on the system memory. eg, a dvd....

Regards Glenn

<edit> I'm a bit behind on my reading, sorry I missed that, GW</edit>

Last edited by GlennsPref; 11-25-2010 at 05:05 AM. Reason: edit
 
Old 11-25-2010, 05:17 AM   #28
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Gentoo
Posts: 15,411
Blog Entries: 2

Rep: Reputation: 3995Reputation: 3995Reputation: 3995Reputation: 3995Reputation: 3995Reputation: 3995Reputation: 3995Reputation: 3995Reputation: 3995Reputation: 3995Reputation: 3995
Quote:
Originally Posted by GlennsPref View Post
Yeah, I agree,

your swap and/or /tmp combination needs to be > (larger than) the largest file that

may require deleting without imposing on the system memory. eg, a dvd....

Regards Glenn

<edit> I'm a bit behind on my reading, sorry I missed that, GW</edit>
Can you explain that to me? I understand it so: " I need at least 2 GB of RAM and 2 GB of swap space to delete a file that is 4 GB in size." How would that be so?
 
Old 11-25-2010, 07:39 AM   #29
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Distribution: Mageia Studio-13.37 Kubuntu.
Posts: 3,325
Blog Entries: 33

Rep: Reputation: 199Reputation: 199
No, not ram. swap and /tmp.

I have a set size for the /tmp partition.

Maybe that's what limits me....

More ram helps though.
 
Old 11-25-2010, 08:58 AM   #30
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,036

Rep: Reputation: 372Reputation: 372Reputation: 372Reputation: 372
I don't think I understand you.

First thing is that, there's no difference (for programs like rm) between "swap" and "RAM". They do not ask for "swap", they do not ask for "RAM", they can't even do that. They only see "virtual memory", where that memory will live physically is up to the kernel which will do its best to improve the performance on any given situation.

Second thing is that paged memory has nothing to do with storage space. A program can't use storage space + paged memory for the same purpose. They have nothing to do with each other.

Third, if it was true that you need so much free space+swap to delete a file, then there wouldn't be a way to delete all these TB-sized files that we use nowadays. Because most boxes have at most a few GBs of RAM, and typical setups put /tmp either in / or on a separate 2GB partition or something like that.

Of course, you need 4GB free space if you want to MOVE a 4GB-sized file into your Recycle Bin, but that's another story.
 
  


Reply


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
swap file vs. swap partition verndog Ubuntu 16 07-09-2012 08:49 PM
Can swap file or a swap partition be mounted and read? Mr-Bisquit Linux - General 3 06-08-2009 02:16 PM
swap file or swap space? simonb1975uk Linux - General 11 08-15-2008 02:39 PM
swap space (or) swap file yusufs Linux - Newbie 8 07-17-2008 02:02 AM
Need Help Increasing Swap by creating a swap file froggo Red Hat 3 06-13-2006 08:04 AM


All times are GMT -5. The time now is 07:17 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