View previous topic :: View next topic |
Author |
Message |
Erik Andersson n00b
Joined: 19 Apr 2002 Posts: 27 Location: Sweden
|
Posted: Fri May 31, 2002 4:23 pm Post subject: Do I need a swap partition? |
|
|
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 |
|
|
lx Veteran
Joined: 28 May 2002 Posts: 1012 Location: Netherlands
|
Posted: Fri May 31, 2002 4:31 pm Post subject: |
|
|
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 |
|
|
Malakin Veteran
Joined: 14 Apr 2002 Posts: 1692 Location: Victoria BC Canada
|
Posted: Fri May 31, 2002 5:01 pm Post subject: |
|
|
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 |
|
|
Erik Andersson n00b
Joined: 19 Apr 2002 Posts: 27 Location: Sweden
|
Posted: Fri May 31, 2002 5:07 pm Post subject: |
|
|
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 |
|
|
BradN Advocate
Joined: 19 Apr 2002 Posts: 2391 Location: Wisconsin (USA)
|
Posted: Fri May 31, 2002 5:13 pm Post subject: |
|
|
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 |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20067
|
Posted: Fri May 31, 2002 7:12 pm Post subject: |
|
|
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 |
|
|
arkane l33t
Joined: 30 Apr 2002 Posts: 918 Location: Phoenix, AZ
|
Posted: Fri May 31, 2002 7:40 pm Post subject: |
|
|
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 |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20067
|
Posted: Fri May 31, 2002 7:47 pm Post subject: |
|
|
I left Win95 long ago. Win2K is still stuck on the bottom of my shoe though. _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
Ian Goldby Guru
Joined: 18 May 2002 Posts: 539 Location: (Inactive member)
|
Posted: Fri May 31, 2002 7:55 pm Post subject: Although you might like to consider |
|
|
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 |
|
|
Utoxin Guru
Joined: 19 Apr 2002 Posts: 413 Location: American Fork, UT
|
Posted: Fri May 31, 2002 9:59 pm Post subject: |
|
|
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 |
|
|
ch3 n00b
Joined: 21 May 2002 Posts: 24 Location: Belgium
|
Posted: Sat Jun 01, 2002 2:16 pm Post subject: |
|
|
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 |
|
|
BradN Advocate
Joined: 19 Apr 2002 Posts: 2391 Location: Wisconsin (USA)
|
Posted: Sat Jun 01, 2002 8:00 pm Post subject: |
|
|
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 |
|
|
BinaryAlchemy n00b
Joined: 31 May 2002 Posts: 42 Location: Ca, US
|
Posted: Sat Jun 01, 2002 8:17 pm Post subject: |
|
|
But gentoo uses tmpfs for builds, and that /will/ fill up your memory. |
|
Back to top |
|
|
BradN Advocate
Joined: 19 Apr 2002 Posts: 2391 Location: Wisconsin (USA)
|
Posted: Sat Jun 01, 2002 8:40 pm Post subject: |
|
|
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 |
|
|
Malakin Veteran
Joined: 14 Apr 2002 Posts: 1692 Location: Victoria BC Canada
|
Posted: Sat Jun 01, 2002 8:51 pm Post subject: |
|
|
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 |
|
|
Erik Andersson n00b
Joined: 19 Apr 2002 Posts: 27 Location: Sweden
|
Posted: Sat Jun 01, 2002 8:53 pm Post subject: |
|
|
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 |
|
|
lx Veteran
Joined: 28 May 2002 Posts: 1012 Location: Netherlands
|
Posted: Sat Jun 01, 2002 10:59 pm Post subject: |
|
|
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. _________________ "Remember there's a big difference between kneeling down and bending over.", Frank Zappa |
|
Back to top |
|
|
|