LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   how do i make a swapfile in debian? (https://www.linuxquestions.org/questions/debian-26/how-do-i-make-a-swapfile-in-debian-134995/)

jogurt666 01-15-2004 02:48 AM

how do i make a swapfile in debian?
 
i've tried to make a swapfile for my system. i've done the following things:

# dd if=/dev/zero of=/swapfile bs=1024 count=524288
# mkswap /swapfile
# swapon /swapfile

but i'm told that /swapfile is an invalid argument? well i've added a swapfile this way in redhat9 and it worked. what should i do here?

kilgoretrout 01-15-2004 07:19 AM

The "dd" part looks alright, but I think your suppose to include the block count with the mkswap command:

# mkswap /swap 524288

Also, I believe your suppose to run the "sync" command after you run mkswap to make sure the format info has been written to the new swap file.

You can do it that way with a swap file, but most people would use a separate swap partition. It's suppose to give better performance because the blocks on a swap partition will always be contigous. Not so if you use a swap file.

jogurt666 01-15-2004 12:52 PM

it works thnx. well i already have a swap partition, however every linux documentation says that my swap space should be at least my RAM multiplied by two. well i have 512MB of RAM, and i've got no free space on my HDD where i could make another swap partition, so i need a swapfile.

HappyTux 01-15-2004 01:05 PM

Quote:

Originally posted by jogurt666
it works thnx. well i already have a swap partition, however every linux documentation says that my swap space should be at least my RAM multiplied by two. well i have 512MB of RAM, and i've got no free space on my HDD where i could make another swap partition, so i need a swapfile.
That can be misleading you really do not need much swap space when you start to get larger amounts of ram installed. I noticed when I had 512mb in my main computer the /swap rarely if ever got used and when I put another 256mb in it then the /swap never gets used.

kilgoretrout 01-15-2004 01:11 PM

That's an old rule that has little relevance with todays high memory configurations. You don't need 1GB of swap if you have 512MB of ram. Check your memory usage and see how often you even go into swap with 512MB of ram. Hardly at all I'd venture to guess unless your doing some really intensive, wierd multitasking. 500MB of swap is more than enough with your ram and I doubt that you'll ever use even a fraction of that swap. I wouldn't bother with the swap file unless your running into a lot of out of memory conditions.

jogurt666 01-15-2004 02:23 PM

well i thought that i may run out of it, since my system hangs sometimes. i've got no idea why. during kernel configuration i've chosen my processor type (that is Athlon) and enabled kernel support for big memory systems. it now works more stabile, but sometimes still hangs. if not by adding swap, how can i root the problem out?

and btw

how do i check memory usage?

leonscape 01-15-2004 02:42 PM

Simply type free to get a read out of your memory consumption.

vectordrake 01-15-2004 06:00 PM

I read an interesting article somewhere that advocates a swap partition (not always the biggest though) regardless of RAM size. Had to do with swapping out processes that were inactive. I wish I remembered where I found that...

ac1980 01-18-2004 03:44 AM

1. A good way to know if your swap is being used is to put a "system monitor" applet into your Gnome/KDE panel and configure it toshow swap. Note that memory will always appear almost full, unless you change the color for buffer/cache
2. There is a good reason to always have some swap: if a process for any reason go crazy and starts forking on and on, without swap it may fill memory before you actually know, making it hard even to manage to kill it. If you have swap, after a while the pc will not hang, but slow down a lot, so further forks will not be as fast, and you can get a console and killall the process.

vectordrake 01-18-2004 09:11 AM

An effective way with number values is to have TOP running in a minimized terminal. Then you have a numerical value to work with. I suggest something really light like RXVT, which will snap to attention and not take up mant more resources


All times are GMT -5. The time now is 10:56 AM.