Adding swap space to a running linux system



There are acouple situations where my systems memory needs have exceeded the supply. The most likely cases are running virtual machines and building cd/dvd images. Those things realistically take LOT’s of memory. I have a swap partition – I don’t recall the size right off. I have about 512 MB on the desktop and probably for what I do could use to double that. Swap space, of course, is what the operating system uses when all the physical memory (RAM) is used.


The situations I’ve seen needing more memory are this. Building a cd or dvd image… the process starts off quite well, fairly quickly. But as it progresses, let’s say to 70% or so in the cd image building the desktop responsiveness slows, the hard drive is thrashing and if you manage to look at “top” or free, you find a VERY minimal amount of memory is actually free swap or RAM. So, what to do? If you’re lucky enough to be able to get to a console you can actually add swap on the fly and return to some responsiveness. If it’s swapping too hard, you may just wind up waiting it out (or rebooting, to many people it looks like a hard system freeze.)

Linux can deal with a swap partition, or a file designated as a swapfile (or multiple files…) Here’s how to add swap space.

Create a 1GB swap file with the following

dd if=/dev/zero of=swapfile bs=1024 count=1M

Next Use the following to “format” the new swap file. Similarly for a new swap partition.
/sbin/mkswap -c swapfile

Now Set swap file ownership and permissions

chown root.root swapfile; chmod 0600 swapfile

Optionally add the new swap space entry to /etc/fstab. (if swap is to be activated at each boot.)

Eg. swapfile swap swap defaults 0 0

Finally Enable the new swapspace(s) with

/sbin/swapon -a (if entry is in fstab)
or
/sbin/swapon /path/to/newswap (if this is to be temporary.)

Related Posts

Blog Traffic Exchange Related Posts
  • Remote tech support with anything - would I do it? I've tried to ask myself if I'd trust someone enough to let them run a remote session on my own desktop to solve a problem. I think the answer is "it depends". If you think about it, I do tech support for home users quite a bit and they let......
  • Linux Software Raid Notes - Replacing Drives This post is going to be somewhat of a "link dump" for me of some pages that I've been perusing lately. After playing with RT (request tracker) - I added a few ticket items for the home network. Now, if you've been a longtime reader and sorted through ALL of......
  • Remote Tech Support using VNC (Ultravnc SC and x11vnc+wrapper script) Ok, some time back I'd done a writeup on UltraVNC SC, which is a nice customizable (windows version) VNC server that essentially let's someone doing remote support build their own downloadable .exe that runs and automatically tries to make a direct connection to a "listening" vnc viewer. It's good for......
Blog Traffic Exchange Related Websites
  • Solidifying WP Security Designed with PHP, and powered by mySQL directories, WordPress is used by an amazing 8.5% of all websites. Web delivered spyware and web page hacking are becoming progressively more common. With such a lot of web content using WordPress as a CMS, any security weaknesses in the CMS structure or......
  • FireFox 3 FireFox 3 Launches Download Day Arrives Today June 17th at 10AM PST marks the long promised FireFox 3.0 Download Day Release. Up to 5 million downloads are expected to occur which if reached, would set a Guinness World Record for the most single piece of software downloads in a single......
  • Retractable Awnings in your Garden Space Adding a retractable awning to your homes exterior is a great way to provide shade from both the sun and the rain with a distinct look. Here the types of retractable awnings will be discussed, along with how they add value to a home. Retractable awnings make an economical and......
www.pdf24.org    Send article as PDF   

Similar Posts


See what happened this day in history from either BBC Wikipedia
Search:
Keywords:
Amazon Logo

Comments are closed.


Switch to our mobile site