LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Setting swap memory size... (https://www.linuxquestions.org/questions/linux-newbie-8/setting-swap-memory-size-689630/)

Ashhere 12-10-2008 12:28 PM

Setting swap memory size...
 
Hi,

How can I change the swap file settings in ubuntu?

jailbait 12-10-2008 12:53 PM

You use the swapon and swapoff commands.

See:

man swapon

man swapoff

---------------------------
Steve Stites

Ashhere 12-10-2008 01:14 PM

Sorry. Its that I am not upto with the commands.

Can you please explain a bit more. I mean if I need to set the memory in a drive,say D(hope its possible),of size 1gb, how to specify the arguments? And also, what does this a,e,v and s in the terminal? If you could temme a link where I can get the command descriptions...!!

Thanks.

malaprop 12-10-2008 01:54 PM

You set the swap size while partitioning a disk.
That can get tricky, as you can completely destroy things if you mess up.

do you have a swap space you are wanting to resize? Or did you add a new drive to the mix that you want to use for swap space?

michaelk 12-10-2008 02:48 PM

It would help if you actually asked a proper question. Do you want more or less swap?

How much RAM do you have (Just for reference)? How much swap do you presently have? How much swap do you need. Is this computer a desktop or a laptop?

linux's primary swap area is a separate partition vs windows which uses a file. Setting swap size is slightly more complex then windows.

There are actually three ways to increase the size of swap.
1. Resize your current swap partition.
2. Create an additional swap partition
3. Create a swap file.

The first two depend on how the drive is partitioned and if you have some unused space. The third is the easiest. A swap file is slower then a partition.

To decrease would be to perform the opposite operation.

jailbait 12-10-2008 03:52 PM

Quote:

Originally Posted by Ashhere (Post 3370724)
Can you please explain a bit more. I mean if I need to set the memory in a drive,say D(hope its possible),of size 1gb, how to specify the arguments?

If you have at least 256 Meg of RAM you can probably run without any swap at all. Use the swapoff command to turn swap off completely:
swapoff -a

Then you can do whatever you want to do with your swap partition, make it bigger, smaller, create two or more, or whatever. After you get the swap partition(s) set up the way you want then you format the swap partition(s) with the mkswap command (see: man mkswap)

You can also create one or more swap files instead of swap partitions but as michaelk said swap partitions run faster than swap files.

You then change /etc/fstab to describe your new swap configuration correctly. Then you turn swap on with the swapon command:

swapon -a

-----------------------
Steve Stites

jay73 12-10-2008 06:16 PM

Quote:

You can also create one or more swap files instead of swap partitions but as michaelk said swap partitions run faster than swap files.
Would this still be valid? I seem to remember and interview with Linus where he said that the difference has become negligeable.

syg00 12-10-2008 07:13 PM

No difference since 2.5 - swap now uses the normal block driver(s) for I/O for both.


All times are GMT -5. The time now is 05:04 AM.