What is swap partition?

The place to post if you need help or advice

Moderators: ChrisThornett, LXF moderators

What is swap partition?

Postby Narendra » Wed Sep 07, 2011 8:48 am

Hello,
I have created a swap partition of 8 gb and installed ubuntu with 30 gb of space.
When the Ubuntu fills up with its all 30 gbs, will the rest of the files get swapped to this SWAP partition?
Please advise.
Narendra
Narendra
LXF regular
 
Posts: 323
Joined: Wed Mar 14, 2007 4:32 pm
Location: East Midlands, UK.

Postby RedWillow » Wed Sep 07, 2011 9:13 am

No. A swap partition is analogous to the pagefile.sys file in Windows. It is used to swap stuff out of RAM if your RAM is getting too full.

Wikipedia article on paging:

http://en.wikipedia.org/wiki/Swap_partition
RedWillow
LXF regular
 
Posts: 719
Joined: Thu May 29, 2008 1:05 pm

Postby Dutch_Master » Wed Sep 07, 2011 12:12 pm

An 8 GB swap is quite big. In general: the more RAM you have, the less likely the kernel needs swap to be used. Right now, the machines I've build have 16GB RAM, on a harddrive of just 30 GB any swap larger then 4 GB is a waste of space. In fact, using SSD's for the system make swap effectively unnecessary as these are so quick it'll have minimal impact on performance.
Dutch_Master
LXF regular
 
Posts: 2445
Joined: Tue Mar 27, 2007 1:49 am

Postby Narendra » Wed Sep 07, 2011 1:34 pm

Thank you very much for your replies.

i tried deleted the swap partition but then the computer won't boot up, showed grub error!
I had backed up Home Folder, the Thunderbird and the Firefox. And I do not now how to fix up the Grub Error, So I reinstalled Ubuntu, without the swap partion. I already have 4 Gb of DDR3 Ram.
Narendra
Narendra
LXF regular
 
Posts: 323
Joined: Wed Mar 14, 2007 4:32 pm
Location: East Midlands, UK.

Postby Ram » Wed Sep 07, 2011 2:27 pm

DM, with only a quarter of the swap to actual memory, are you able to suspend / hibernate your system?

lubuntu LXDE 13.10 running on AMD Phenom II*4; ASUS Crosshair III Formula MB; 4 GB Ram.....
User avatar
Ram
LXF regular
 
Posts: 1675
Joined: Thu Apr 07, 2005 9:44 pm
Location: Guisborough

Postby Dutch_Master » Wed Sep 07, 2011 3:21 pm

@RAM: I don't suspend nor hibernate any of my systems, so... ;)

However, theoretically it should be possible, as long as you close all running applications so it's only the kernel that needs room for its suspended state. In light of the above, it'll be no surprise that I haven't tried it myself :P
Dutch_Master
LXF regular
 
Posts: 2445
Joined: Tue Mar 27, 2007 1:49 am

Postby nelz » Wed Sep 07, 2011 5:25 pm

The full contents of active memory are saved, compressed if you want, but you can suspend to a file so a large swap is unnecessary.
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8489
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

Postby Rhakios » Thu Sep 08, 2011 12:15 pm

nelz wrote:The full contents of active memory are saved, compressed if you want, but you can suspend to a file so a large swap is unnecessary.

Is that the subject for a future tutorial, nelz, suspend to a file?
Bye, Rhakios
User avatar
Rhakios
Moderator
 
Posts: 7634
Joined: Wed Apr 06, 2005 11:18 pm
Location: Midlands, UK

Postby nelz » Thu Sep 08, 2011 1:43 pm

If you're using TuxonIce to suspend, it's a matter of changing one line in the config file. That would make for a rather short tutorial.

If you're not using TuxOnIce, you deserve what you get :)
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8489
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

Postby Rhakios » Thu Sep 08, 2011 1:56 pm

nelz wrote:If you're using TuxonIce to suspend, it's a matter of changing one line in the config file. That would make for a rather short tutorial.

If you're not using TuxOnIce, you deserve what you get :)

Until you mentioned it I'd never heard of it, but then I only use suspend, which works well enough on my netbook.
Bye, Rhakios
User avatar
Rhakios
Moderator
 
Posts: 7634
Joined: Wed Apr 06, 2005 11:18 pm
Location: Midlands, UK

Postby nelz » Thu Sep 08, 2011 2:00 pm

It's an enhanced suspend that adds extra options, like suspending to a disk file, aborting a suspend and a couple of other goodies. I've used it for so long, I'd forgotten about the standard offering being more limited.
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8489
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

Postby pastychomper » Thu Sep 08, 2011 2:35 pm

Impressive. I'm assured swap files have been as fast as swap partitions for some time, so if TuxonIce is as good as it sounds then presumably there's no longer a need to have a swap partition at all.

I suppose having a dedicated partition means you can keep the swap on the fastest edge of the disc, so maybe it's still worthwhile - but would that be offset by the drive heads having to travel further from the filesystem partition(s) to do a read?
pastychomper
 
Posts: 52
Joined: Wed Apr 07, 2010 10:54 am

Postby nordle » Thu Sep 08, 2011 10:01 pm

Can't be arsed to fact check.
But does Suspend not go to RAM (assuming STR in bios), so swap is not essential anyway?
Hibernate may require disk space, but STR does not.

I've got 2GB RAM and 512MB swap. Never had a problem suspending PC. Longest I think was 30 something days with a daily suspend, then kernel update forced actual reboot.
I think, therefore I compile
User avatar
nordle
LXF regular
 
Posts: 1500
Joined: Fri Apr 08, 2005 9:56 pm

Two Topics Here?

Postby Nuke » Wed Sep 14, 2011 12:58 pm

pastychomper wrote:.. swap files have been as fast as swap partitions for some time, so if TuxonIce is .. good .. there's no longer a need to have a swap partition at all.

I suppose having a dedicated partition means you can keep the swap on the fastest edge of the disc, .. - but would that be offset by the drive heads having to travel further from the filesystem partition(s) to do a read?


It looks like two issues have got mixed in this thread : (1) Need for a swap partition, and (2) Suspending the OS. I never knew that suspending used the swap space - can someone confirm that? I thought the RAM power was maintained while all other power consuming stuff was switched off.

However Suspend works, I understand that you should always have a swap partion as some software (probably older stuff) is written to use it, even if there is plenty of memory. You should not need much though, mine's only 500 Mb.

As for having the swap as a file, not in a partition, what's the point again? I can see swap file (as opposed to a partition) getting fragmented all over the place mixed in with data files. Hardly efficient. Windows does that (from NT/XP) : ever looked at the frag map of a Windows HDD?

Anyway, as this thread has said, the swap is little used these days so a few less nanoseconds don't matter. But have you thought of trying to recover data from a corrupted disk? With valuable data mixed in with bits of swap (and therefore similar stuff appearing many times over) your disk is going to be a real mess to sort out!

I have always had two or more HDDs in my builds (four once). When I put in a bigger HDD I keep the previous one and put two partitions (at least) on it, one for the swap and the other for a first level backup. So effectively the disc is dedicated to swapping.
User avatar
Nuke
LXF regular
 
Posts: 217
Joined: Wed Feb 09, 2011 12:11 pm
Location: Chepstow, UK

Postby Ram » Wed Sep 14, 2011 4:27 pm

If suspend suspends to ram (power still consumed) where is hibernate stored no power used.

lubuntu LXDE 13.10 running on AMD Phenom II*4; ASUS Crosshair III Formula MB; 4 GB Ram.....
User avatar
Ram
LXF regular
 
Posts: 1675
Joined: Thu Apr 07, 2005 9:44 pm
Location: Guisborough

Next

Return to Help!

Who is online

Users browsing this forum: No registered users and 3 guests