LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 04-02-2007, 09:32 PM   #1
phreakshew
Member
 
Registered: Aug 2005
Distribution: Ubuntu, Kubuntu, Linux Mint
Posts: 97

Rep: Reputation: 16
Question increasing ram, need to increase swap


hello all,

I'm running Ubuntu 6.06 on a Toshiba Satellite laptop with 256mb (PC133) RAM. I want to increase the RAM to 512 and I have read that it is good to make the swap twice the size of available RAM. How can I do this without reinstalling the OS? I have read similar threads but wasn't sure if those directions would work in Ubuntu so I'm asking it here.

Please and Thank You
 
Old 04-02-2007, 09:58 PM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Swap is swap; the distribution doesn't much matter. The easiest way to add swap is to add a second level of swap in a file. For example, to add 512MB of swap (as root):

1. Prepare the swapfile:
Code:
# dd if=/dev/zero of=/swapfile bs=1M count=512
512+0 records in
512+0 records out
536870912 bytes (537 MB) copied, 22.0228 seconds, 24.4 MB/s
2. Format it as swap:
Code:
# mkswap /swapfile
Setting up swapspace version 1, size = 536866 kB
3. Add it to /etc/fstab:
Code:
/swapfile   swap   swap   defaults   0 0
4. Start using it (will happen automatically at boot in the future):
Code:
# swapon /swapfile
You can verify it's now available with:
Code:
# swapon -s
Filename                                Type            Size    Used    Priority
/dev/hda3                               partition       2032212 1648    -1
/swapfile                               file            524280  0       -2
 
Old 04-02-2007, 11:44 PM   #3
phreakshew
Member
 
Registered: Aug 2005
Distribution: Ubuntu, Kubuntu, Linux Mint
Posts: 97

Original Poster
Rep: Reputation: 16
Thanx! That was very helpful! So, with this setup, if the computer uses up one swap partition it will then automatically dip into the next swap? How much swap do YOU recommend?
 
Old 04-02-2007, 11:59 PM   #4
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Yes, when the primary (partition) is full, it will use the swapfile. This is actually more efficient than a single large area, as it keep seeks short.

There's no "one size fits all" with swap. As your real memory increases, you actually need less. I'd recommend 4x real at 128MB, but decreasing to 1/4 real (256MB) at 1GB. Your usage pattern may be different, but I typically have a dozen or more windows/applications running, and that's fine for me.

That's another nice thing about using a swapfile; you can estimate low and add it if necessary on the fly. You may want to run for a while without increasing your swap after increasing your RAM, and see what your usage is. If you don't need it, don't add it.
 
Old 04-03-2007, 12:15 AM   #5
phreakshew
Member
 
Registered: Aug 2005
Distribution: Ubuntu, Kubuntu, Linux Mint
Posts: 97

Original Poster
Rep: Reputation: 16
how do I know when I'm using swap?

one last thing- how do I check to see how much / how often swap is accessed?

thanks again for your help!

 
Old 04-03-2007, 12:30 AM   #6
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
The 'swapon -s' will give you a current snapshot. The 'top' command will also provide the swap usage in the header. You can also run one of the many system monitors, like gkrellm, conky, etc. They can display swapping information in near-realtime if you want to keep an eye on it.

If you don't want to install anything Gnome comes with a monitor for the panel... Right-click on an empty area on your panel (usually at the top/bottom of the screen), and select 'Add to Panel'. Scroll down to the 'System Monitor' and click on Add, then close. The monitor will be added to the panel. You can right click on it and select 'Preferences' to add a monitor for swap.
 
Old 04-03-2007, 12:48 AM   #7
phreakshew
Member
 
Registered: Aug 2005
Distribution: Ubuntu, Kubuntu, Linux Mint
Posts: 97

Original Poster
Rep: Reputation: 16
Thumbs up

that's great! I've actually been using system monitor but never right clicked on it! Still a
 
Old 12-26-2016, 11:23 PM   #8
shipon_97
Member
 
Registered: Oct 2005
Location: Bangladesh
Posts: 504

Rep: Reputation: 31
i have a question .

From where this /swapfile takes 512M space ? is it take space from available RAM or from Local HDD ?
 
Old 12-26-2016, 11:49 PM   #9
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
You have replied to a thread which has been inactive for almost ten years.

You are encouraged to open your own thread with a complete description of your problem so that your question will receive better exposure and attract more relevant answers.

Swap is always allocated on a storage device such as a HDD or SSD, either as a partition or a file. It is used to temporarily free blocks of used but inactive RAM for use by higher priority processes.

You may find this page helpful, ArchWiki: Swap.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help Increasing Swap by creating a swap file froggo Red Hat 3 06-13-2006 08:04 AM
mem and swap usage increasing daily epoo Linux - General 5 05-01-2005 11:49 PM
increasing swap on a slow pc ejbest Linux - Newbie 1 10-24-2004 10:30 AM
Increasing swap space rupesh_pulikool Linux - Networking 1 09-12-2004 10:40 PM
Increasing swap partition suneet123 Linux - Software 3 12-16-2002 03:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration