Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Do I need a swap partition?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Erik Andersson
n00b
n00b


Joined: 19 Apr 2002
Posts: 27
Location: Sweden

PostPosted: Fri May 31, 2002 4:23 pm    Post subject: Do I need a swap partition? Reply with quote

I wonder how necessary the swap partition really is. I have 512MB of memory and I don't really need any more than that for the programs I run.
However, since I don't know exactly how virtual memory is handled in Linux I'm not sure if there are problems with this making it slower than expected.
Back to top
View user's profile Send private message
lx
Veteran
Veteran


Joined: 28 May 2002
Posts: 1012
Location: Netherlands

PostPosted: Fri May 31, 2002 4:31 pm    Post subject: Reply with quote

Well you can try to run without it and just wait until you get some error, I have 256Mb memory and 512Mb partitions, which is very rarely used. You can also use a file for swap when you run into trouble and can't make a swap partitions anymore. I think you should..... well forget about it, I don't know how to create it anymore, but it's possible and maybe a better solution then using swappartition. In times of trouble (if there are any) make a swapfile and use swapon or something,.... :)
_________________
"Remember there's a big difference between kneeling down and bending over.", Frank Zappa
Back to top
View user's profile Send private message
Malakin
Veteran
Veteran


Joined: 14 Apr 2002
Posts: 1692
Location: Victoria BC Canada

PostPosted: Fri May 31, 2002 5:01 pm    Post subject: Reply with quote

You don't need a swap partition. Not having one won't make any difference, unless Linux runs out of memory (it won't make anything slower).
Back to top
View user's profile Send private message
Erik Andersson
n00b
n00b


Joined: 19 Apr 2002
Posts: 27
Location: Sweden

PostPosted: Fri May 31, 2002 5:07 pm    Post subject: Reply with quote

Thanks for the quick replies!
I'm just trying to reduce the amount of partitions, and the swap partition seemed like a good candidate. I suppose the reason for having a swap partition rather than a "regular" file has to do with file system integrity rather than speed? But since I don't have anything terribly important on my computer a file will be fine if I find that I need more memory in the future.
Back to top
View user's profile Send private message
BradN
Advocate
Advocate


Joined: 19 Apr 2002
Posts: 2391
Location: Wisconsin (USA)

PostPosted: Fri May 31, 2002 5:13 pm    Post subject: Reply with quote

It's really easy to make a swap file if you need to, and personally I don't really see the need for a swap partition much anymore, as I've only had maybe 5 megs in swap with my 448 meg system, but never came remotely close to running out of memory considering the file cache and buffers.

If you need to make a swap file (not partition), Just use dd to create a file of whatever size you want:

dd if=/dev/zero of=/swapfile bs=1024 count=4096

That example would make a 4 meg file (obviously you'd want a bit more) - change the 4096 appropriately. Then...

mkswap /swapfile
swapon /swapfile

should work. The mkswap is needed because the kernel will refuse to use something that isn't swap as a swap file (imagine specifying a wrong partition accidentally...)
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20053

PostPosted: Fri May 31, 2002 7:12 pm    Post subject: Reply with quote

Is there a way to do this dynamically? If not, there should be ;). System is close to running out of memory, so it creates a swapfile of some predefined size/location.
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
arkane
l33t
l33t


Joined: 30 Apr 2002
Posts: 918
Location: Phoenix, AZ

PostPosted: Fri May 31, 2002 7:40 pm    Post subject: Reply with quote

kanuslupus wrote:
Is there a way to do this dynamically? If not, there should be ;). System is close to running out of memory, so it creates a swapfile of some predefined size/location.


Win95 did it that way... well, it created the swap at boot, but it was dynamic.

I considered it one hell of alot better than that huge swap file win3.1 used.
I know they are different breeds than Linux (by a large margin), but the paging is about the same in idea.

--
Dan
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20053

PostPosted: Fri May 31, 2002 7:47 pm    Post subject: Reply with quote

I left Win95 long ago. Win2K is still stuck on the bottom of my shoe though.
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
Ian Goldby
Guru
Guru


Joined: 18 May 2002
Posts: 539
Location: (Inactive member)

PostPosted: Fri May 31, 2002 7:55 pm    Post subject: Although you might like to consider Reply with quote

IRIX uses the swap partition for emergency recovery purposes as a temporary storage space that is guaranteed not to touch any 'real' data on your disk. I just wonder whether there is anything in Linux that does the same? You wouldn't want to find out on the day that your disk gets trashed...
Back to top
View user's profile Send private message
Utoxin
Guru
Guru


Joined: 19 Apr 2002
Posts: 413
Location: American Fork, UT

PostPosted: Fri May 31, 2002 9:59 pm    Post subject: Reply with quote

I personally would recommend having a swap partition, even if it's just 64 megs or less. Linux gets /very/ unhappy when it runs out of memory. It's one of the few things I've seen that can truly crash a linux system. (Bad memory being another.)
Back to top
View user's profile Send private message
ch3
n00b
n00b


Joined: 21 May 2002
Posts: 24
Location: Belgium

PostPosted: Sat Jun 01, 2002 2:16 pm    Post subject: Reply with quote

As Utoxin, I would recommend a swap partition.
Because a swap file use the underlying filesystem, it introduce a
perfomance hit, as the opposite of a partition, wich allow raw access
to the disk.

Personnaly I think you always need a swap file/partition because
compiling require a huge amount of memory (and obviously, using Gentoo
, you will compile a lot :) ), and if you use KDE, you may hit the swap more
easilly...
_________________
Tell a man there are 300 billion stars in the universe and he'll believe you.
Tell him a bench has wet paint on it and he'll have to touch to be sure.
Back to top
View user's profile Send private message
BradN
Advocate
Advocate


Joined: 19 Apr 2002
Posts: 2391
Location: Wisconsin (USA)

PostPosted: Sat Jun 01, 2002 8:00 pm    Post subject: Reply with quote

hmm... one point I kinda see is that if you run out of memory with a 512 meg system and you don't expect it at all otherwise, something is probably very wrong. Personally, I'd rather not have it start thrashing on a swap partition/file at that point... instead, wouldn't linux just go and kill that process at that point if it didn't have swap, or have they changed that behavior?
Back to top
View user's profile Send private message
BinaryAlchemy
n00b
n00b


Joined: 31 May 2002
Posts: 42
Location: Ca, US

PostPosted: Sat Jun 01, 2002 8:17 pm    Post subject: Reply with quote

But gentoo uses tmpfs for builds, and that /will/ fill up your memory.
Back to top
View user's profile Send private message
BradN
Advocate
Advocate


Joined: 19 Apr 2002
Posts: 2391
Location: Wisconsin (USA)

PostPosted: Sat Jun 01, 2002 8:40 pm    Post subject: Reply with quote

Oh, I didn't know that...

Perhaps it would be better then to have a swap partition after all, although I'd still think you could get away without one.
Back to top
View user's profile Send private message
Malakin
Veteran
Veteran


Joined: 14 Apr 2002
Posts: 1692
Location: Victoria BC Canada

PostPosted: Sat Jun 01, 2002 8:51 pm    Post subject: Reply with quote

Running kde 3, some browsers, and emerging 2 things simultaneously I'm still only using about 120M (other then caches). I've never seen this box use anywhere near it's 512M.
Back to top
View user's profile Send private message
Erik Andersson
n00b
n00b


Joined: 19 Apr 2002
Posts: 27
Location: Sweden

PostPosted: Sat Jun 01, 2002 8:53 pm    Post subject: Reply with quote

I am running without a swap partition now, and it seems to work fine (or at least as well as it did before). Before upgrading I used 256MB physical + 256MB swap, and only having 512MB physical can hardly be worse, can it? (Ok, it can be worse depending on the VM-implementation, but since it seems to change quite often I don't plan to browse the source code looking for potential problems)
Back to top
View user's profile Send private message
lx
Veteran
Veteran


Joined: 28 May 2002
Posts: 1012
Location: Netherlands

PostPosted: Sat Jun 01, 2002 10:59 pm    Post subject: Reply with quote

We're talking about a swap partition/file of 256/512Mb or so, damn if I don't use it I have no way of filling up my huge disk. :wink:
_________________
"Remember there's a big difference between kneeling down and bending over.", Frank Zappa
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum