LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   increasing the swap space after installing linux (https://www.linuxquestions.org/questions/linux-newbie-8/increasing-the-swap-space-after-installing-linux-212389/)

LinToWinWin 08-02-2004 02:02 AM

increasing the swap space after installing linux
 
Hi,

I have installed Mandrake Linux. I find that the swap space is used above 90% always. Hence, I want to increase the swap memory space. Please let me know how to do it.

Regards,
Shyam

osvaldomarques 08-02-2004 02:25 AM

Hi LinToWinWin,
It is easy to do. As you have already partitioned your disk, the most recommendable is to create a partition file. You must first create a file of desired length with "dd", then use mkswap to prepare it and after just enable swap. It is important the file be created with "dd" because it has to be a contiguous, not an sparse file. So, the commands to do it are
Code:

dd if=/dev/zero of="/path/to/your/swap-file" bs=1k count="your-need-in-MB"x1kx1k
mkswap="/path/to/your/swap-file"
swapon "/path/to/your/swap-file"

To swapon it on the start up, you have to add the following line in "/etc/fstab"
Code:

"/path/to/your/swap-file" swap swap defaults 0 0
"/path/to/your/swap-file" you must replace with your directory and file
"your-need-in MB" means the number of mega bytes you want. Observe we are multiplying bye 1kB two times. So, if you want 256MB, the command will be 256x1kx1k. If you want 1GB, you can put 1kx1kx1k.
Have fun!
PS. you can get more information on manual page for mkswap. Linux can work with more than one swap area.

Kroenecker 08-02-2004 02:26 AM

This probably will involve fdisk as long as you have extra, unused, unformated space laying around on a hd. Read up about making a new swap partition using fdisk. Then change /etc/fstab to include a swap partition. Use man fstab to see the man pages about fstab.

thegeekster 08-03-2004 09:41 PM

Hi osvaldomarques

Ummm............I think your calculations are wrong in the "count=" option for the 'dd' command.............Since you're using a block size of 1k (bs=1k) the count will be in 1k blocks, so the count= option should be

count="your-need-in-MB"x1k

and not

count="your-need-in-MB"x1kx1k

(drop the extra x1k)


And to simplify it even more for the n00b, since you specifying a file size in MB, why not use a block size of 1MB (bs=1M) and then specify the count= option as a number of megabytes. For example, to create an empty file of 200 MB, use this command:

dd if=/dev/zero of=/path/to/your/swap-file bs=1M count=200

:)

osvaldomarques 08-03-2004 09:51 PM

HI thegeekster,
Man, you are right! Double right! I was consulting an old "man" where the multipliers went just until "1k". A translated manual. The reason I don't like translations. And you are also right of the excess of 1k's.
Thanks for the correction.

Osvaldo


All times are GMT -5. The time now is 06:27 AM.